From: jpbruyere Date: Tue, 24 Jan 2017 11:11:30 +0000 (+0100) Subject: dataType for expandable itemTemplate use 'isAssignableFrom'; GraphicTree View X-Git-Tag: v0.5.1~28^2~6 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=5c60b29867dc95138bbb544e5528b9e75d5b8435;p=jp%2Fcrow.git dataType for expandable itemTemplate use 'isAssignableFrom'; GraphicTree View --- diff --git a/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index b9f16d25..2e747f23 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -28,8 +28,6 @@ prompt 4 false - $(SolutionDir)build\obj\$(Configuration) - $(SolutionDir)build\$(Configuration) none @@ -37,8 +35,6 @@ prompt 0 false - $(SolutionDir)build\obj\$(Configuration) - $(SolutionDir)build\$(Configuration) @@ -48,15 +44,6 @@ gtk-sharp-3.0 - - gtk-sharp-2.0 - - - gio-sharp-3.0 - - - glib-sharp-3.0 - $(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll opentk @@ -91,10 +78,10 @@ CrowIDE.MembersView.template - - + + diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index b137ad8d..6bb1e7ef 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -67,7 +67,7 @@ namespace CrowIDE if (bindingExp != null) { CrowInterface.DeleteWidget (bindingExp); } - bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.bindingExplorer.crow"); + bindingExp = CrowInterface.LoadInterface ("#CrowIDE.ui.GTreeExplorer.crow"); bindingExp.DataSource = imlVE; return; } else if (e.Key == OpenTK.Input.Key.F6) { diff --git a/CrowIDE/src/Extensions.cs b/CrowIDE/src/Extensions.cs index e2897e3e..5e8981df 100644 --- a/CrowIDE/src/Extensions.cs +++ b/CrowIDE/src/Extensions.cs @@ -26,10 +26,16 @@ namespace Crow public static class Extensions { public static List GetChildren(this GraphicObject go){ - if (go is Group) + Type goType = go.GetType(); + if (typeof (Group).IsAssignableFrom (goType)) return (go as Group).Children; - if (go is Container) + if (typeof(Container).IsAssignableFrom (goType)) return new List( new GraphicObject[] { (go as Container).Child }); + if (typeof(TemplatedContainer).IsAssignableFrom (goType)) + return new List( new GraphicObject[] { (go as TemplatedContainer).Content }); + if (typeof(TemplatedGroup).IsAssignableFrom (goType)) + return (go as TemplatedGroup).Items; + return new List(); } } diff --git a/CrowIDE/src/ImlVisualEditor.cs b/CrowIDE/src/ImlVisualEditor.cs index e3975cfe..0a89bad8 100644 --- a/CrowIDE/src/ImlVisualEditor.cs +++ b/CrowIDE/src/ImlVisualEditor.cs @@ -34,6 +34,7 @@ namespace CrowIDE public ImlVisualEditor () : base() { imlVE = new Interface (); + imlVE.DesignMode = true; Thread t = new Thread (interfaceThread); t.IsBackground = true; t.Start (); @@ -78,6 +79,9 @@ namespace CrowIDE } } + public List GraphicTree { + get { return imlVE.GraphicTree; } + } void reloadFromSource(){ @@ -105,6 +109,7 @@ namespace CrowIDE using (StreamReader sr = new StreamReader (imlPath)) { ImlSource = sr.ReadToEnd (); } + NotifyValueChanged ("GraphicTree", GraphicTree); } void reload_iTor(Instantiator new_iTot){ itor = new_iTot; diff --git a/CrowIDE/ui/GTreeExpITemp.crow b/CrowIDE/ui/GTreeExpITemp.crow new file mode 100644 index 00000000..6ce59f3c --- /dev/null +++ b/CrowIDE/ui/GTreeExpITemp.crow @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/CrowIDE/ui/GTreeExplorer.crow b/CrowIDE/ui/GTreeExplorer.crow new file mode 100644 index 00000000..d498a222 --- /dev/null +++ b/CrowIDE/ui/GTreeExplorer.crow @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/CrowIDE/ui/bindingExpITemp.crow b/CrowIDE/ui/bindingExpITemp.crow deleted file mode 100644 index 0797371e..00000000 --- a/CrowIDE/ui/bindingExpITemp.crow +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - diff --git a/CrowIDE/ui/bindingExplorer.crow b/CrowIDE/ui/bindingExplorer.crow deleted file mode 100644 index 13d90be8..00000000 --- a/CrowIDE/ui/bindingExplorer.crow +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index f636786d..ee799fd0 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -106,11 +106,11 @@ namespace Crow public virtual List Items{ get { return items.Children; }} [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{ get { return _selectedIndex; } - set { + set { if (value == _selectedIndex) return; - _selectedIndex = value; + _selectedIndex = value; NotifyValueChanged ("SelectedIndex", _selectedIndex); NotifyValueChanged ("SelectedItem", SelectedItem); @@ -179,7 +179,7 @@ namespace Crow protected void raiseSelectedItemChanged(){ SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem)); } - + public virtual void AddItem(GraphicObject g){ items.AddChild (g); @@ -313,7 +313,7 @@ namespace Crow if (loadingThread == null) return; if (!loadingThread.IsAlive) - return; + return; cancelLoading = true; loadingThread.Join (); cancelLoading = false; @@ -341,7 +341,7 @@ namespace Crow page = gs; }else - page = Activator.CreateInstance (items.GetType ()) as Group; + page = Activator.CreateInstance (items.GetType ()) as Group; page.Name = "page" + pageNum; @@ -383,9 +383,20 @@ namespace Crow itempKey = getItempKey (dataType, data [i]); if (ItemTemplates.ContainsKey (itempKey)) - iTemp = ItemTemplates [itempKey]; - else - iTemp = ItemTemplates ["default"]; + iTemp = ItemTemplates [itempKey]; + else { + foreach (string it in ItemTemplates.Keys) { + Type t = Type.GetType (it); + if (t == null) + continue; + if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached + iTemp = ItemTemplates [it]; + break; + } + } + if (iTemp == null) + iTemp = ItemTemplates ["default"]; + } lock (CurrentInterface.LayoutMutex) { g = iTemp.CreateInstance(CurrentInterface);