diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-18 17:26:50 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-09-01 12:44:38 +0200 |
| commit | 5fc76c5f6234fcdcf208607c434a6d5d8bbf79da (patch) | |
| tree | 393b14c6c193846d33e7e5842d34250333a4cfaa /src/GraphicObjects | |
| parent | d4bc4a1aba5df1d5a93474259c5d5a52f993d475 (diff) | |
tests reorganization
modifié : Crow.csproj
modifié : Tests/BasicTests.cs
renommé : Tests/Interfaces/Expandable/0.crow -> Tests/Interfaces/TemplatedContainer/0.crow
renommé : Tests/Interfaces/Expandable/6.crow -> Tests/Interfaces/TemplatedContainer/6.crow
renommé : Tests/Interfaces/Expandable/7.crow -> Tests/Interfaces/TemplatedContainer/7.crow
renommé : Tests/Interfaces/Divers/testDirViewer2.crow -> Tests/Interfaces/TemplatedContainer/testDirViewer2.crow
renommé : Tests/Interfaces/Divers/testGroupBox.crow -> Tests/Interfaces/TemplatedContainer/testGroupBox.crow
renommé : Tests/Interfaces/Divers/testMsgBox.crow -> Tests/Interfaces/TemplatedContainer/testMsgBox.crow
renommé : Tests/Interfaces/Divers/testPopper.crow -> Tests/Interfaces/TemplatedContainer/testPopper.crow
renommé : Tests/Interfaces/Divers/testTabView.crow -> Tests/Interfaces/TemplatedContainer/testTabView.crow
renommé : Tests/Interfaces/Divers/testTreeView.crow -> Tests/Interfaces/TemplatedContainer/testTreeView.crow
renommé : Tests/Interfaces/Divers/testWindow.goml -> Tests/Interfaces/TemplatedContainer/testWindow.goml
renommé : Tests/Interfaces/Divers/testWindow2.goml -> Tests/Interfaces/TemplatedContainer/testWindow2.goml
renommé : Tests/Interfaces/Divers/testWindow3.goml -> Tests/Interfaces/TemplatedContainer/testWindow3.goml
renommé : Tests/Interfaces/Divers/test_Listbox.crow -> Tests/Interfaces/TemplatedContainer/test_Listbox.crow
renommé : Tests/Interfaces/Divers/testButton.crow -> Tests/Interfaces/TemplatedControl/testButton.crow
renommé : Tests/Interfaces/Divers/testCheckbox.crow -> Tests/Interfaces/TemplatedControl/testCheckbox.crow
renommé : Tests/Interfaces/Divers/testCombobox.crow -> Tests/Interfaces/TemplatedControl/testCombobox.crow
renommé : Tests/Interfaces/Divers/testItemTemplateTag.crow -> Tests/Interfaces/TemplatedControl/testItemTemplateTag.crow
renommé : Tests/Interfaces/Divers/testRadioButton.crow -> Tests/Interfaces/TemplatedControl/testRadioButton.crow
renommé : Tests/Interfaces/Divers/testScrollbar.goml -> Tests/Interfaces/TemplatedControl/testScrollbar.goml
renommé : Tests/Interfaces/Divers/testSpinner.goml -> Tests/Interfaces/TemplatedControl/testSpinner.goml
modifié : Tests/Tests.csproj
modifié : src/GraphicObjects/Expandable.cs
modifié : src/GraphicObjects/Group.cs
TemplatedGroup class
nouveau fichier : src/GraphicObjects/TemplatedGroup.cs
nouveau fichier : Tests/Interfaces/TemplatedGroup/0.crow
modifié : src/IMLReader.cs
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/Expandable.cs | 1 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedGroup.cs | 144 |
3 files changed, 145 insertions, 2 deletions
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 059cab8b..70451f41 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -63,6 +63,7 @@ namespace Crow NotifyValueChanged ("HasContent", HasContent); } } + //TODO: move loadTemplate and ResolveBinding in TemplatedContainer protected override void loadTemplate(GraphicObject template = null) { base.loadTemplate (template); diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 950992e2..402128b0 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -27,8 +27,6 @@ namespace Crow bool _multiSelect = false; List<GraphicObject> children = new List<GraphicObject>(); - public GraphicObject activeWidget; - public virtual List<GraphicObject> Children { get { return children; } } diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs new file mode 100644 index 00000000..12448b82 --- /dev/null +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -0,0 +1,144 @@ +// +// TemplatedContainer.cs +// +// Author: +// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; +using System.Xml.Serialization; +using System.Xml; +using System.Reflection; +using System.Collections.Generic; + +namespace Crow +{ + public abstract class TemplatedGroup : TemplatedControl + { + #region CTOR + public TemplatedGroup () : base(){} + #endregion + + protected Group items; + + public virtual List<GraphicObject> Items{ get { return items.Children; }} + + public virtual void AddItem(GraphicObject g){ + items.AddChild (g); + g.LogicalParent = this; + } + public virtual void RemoveItem(GraphicObject g) + { + items.RemoveChild (g); + } + + public virtual void ClearItems() + { + items.ClearChildren (); + } + + protected override void loadTemplate(GraphicObject template = null) + { + base.loadTemplate (template); + + items = this.child.FindByName ("ItemsContainer") as Group; + if (items == null) + throw new Exception ("TemplatedGroup template Must contain a Group named 'ItemsContainer'"); + } + + #region GraphicObject overrides + public override GraphicObject FindByName (string nameToFind) + { + if (Name == nameToFind) + return this; + + foreach (GraphicObject w in Items) { + GraphicObject r = w.FindByName (nameToFind); + if (r != null) + return r; + } + return null; + } + public override bool Contains (GraphicObject goToFind) + { + foreach (GraphicObject w in Items) { + if (w == goToFind) + return true; + if (w.Contains (goToFind)) + return true; + } + return false; + } + #endregion + + #region IXmlSerialisation Overrides + public override void ReadXml(System.Xml.XmlReader reader) + { + using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) { + subTree.Read (); + string tmp = subTree.ReadOuterXml (); + + //seek for template tag + using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) { + xr.Read (); + base.ReadXml (xr); + } + //process content + using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) { + xr.Read (); //skip current node + + while (!xr.EOF) { + xr.Read (); //read first child + + if (!xr.IsStartElement ()) + continue; + + if (xr.Name == "Template" || Name == "ItemTemplate"){ + xr.Skip (); + if (!xr.IsStartElement ()) + continue; + } + + Type t = Type.GetType ("Crow." + xr.Name); + if (t == null) { + Assembly a = Assembly.GetEntryAssembly (); + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name == xr.Name) + t = expT; + } + } + if (t == null) + throw new Exception (xr.Name + " type not found"); + + GraphicObject go = (GraphicObject)Activator.CreateInstance (t); + + (go as IXmlSerializable).ReadXml (xr); + + AddItem (go); + + xr.Read (); //closing tag + } + + } + } + } + public override void WriteXml(System.Xml.XmlWriter writer) + { + throw new NotImplementedException (); + } + #endregion + } +} |