From 508b53d725958e6a8c8be51db04033aeff1df0da Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Tue, 27 Feb 2018 18:18:42 +0100 Subject: crowide wip, DesignIDS --- CrowIDE/src/MembersView.cs | 74 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 17 deletions(-) (limited to 'CrowIDE/src/MembersView.cs') diff --git a/CrowIDE/src/MembersView.cs b/CrowIDE/src/MembersView.cs index 79bcf5c4..f0c3a13a 100644 --- a/CrowIDE/src/MembersView.cs +++ b/CrowIDE/src/MembersView.cs @@ -32,6 +32,12 @@ namespace Crow.Coding public class MembersView : ListBox { object instance; + ImlProjectItem projFile; + + public MembersView () : base() {} + + //cache property containers per type + Dictionary propContainersCache = new Dictionary(); [XmlAttributeAttribute][DefaultValue(null)] public virtual object Instance { @@ -39,36 +45,70 @@ namespace Crow.Coding set { if (instance == value) return; + object lastInst = instance; + instance = value; NotifyValueChanged ("Instance", instance); - if (Instance is GraphicObject) - NotifyValueChanged ("SelectedItemName", (Instance as GraphicObject).Name); - else + + if (Instance is GraphicObject) { + NotifyValueChanged ("SelectedItemName", Instance.GetType().Name + (Instance as GraphicObject).design_id + + ":" + (Instance as GraphicObject).design_imlPath ); + }else NotifyValueChanged ("SelectedItemName", ""); - if (instance == null) { + if (instance == null) { Data = null; return; + } + + Type it = instance.GetType (); + if (!propContainersCache.ContainsKey (it.FullName)) { + MemberInfo[] members = it.GetMembers (BindingFlags.Public | BindingFlags.Instance); + List props = new List (); + foreach (MemberInfo m in members) { + if (m.MemberType == MemberTypes.Property) { + PropertyInfo pi = m as PropertyInfo; + if (!pi.CanWrite) + continue; + if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null) + continue; + props.Add (new PropertyContainer (this, pi)); + } + } + propContainersCache.Add (it.FullName, props.OrderBy (p => p.Name).ToArray ()); } - MemberInfo[] members = instance.GetType ().GetMembers (BindingFlags.Public | BindingFlags.Instance); + Data = propContainersCache [it.FullName]; - List props = new List (); - foreach (MemberInfo m in members) { - if (m.MemberType == MemberTypes.Property) { - PropertyInfo pi = m as PropertyInfo; - if (!pi.CanWrite) - continue; - if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null) - continue; - props.Add (new PropertyContainer (pi, instance)); + if (lastInst != instance) { + foreach (PropertyContainer pc in propContainersCache [it.FullName]) { + pc.NotifyValueChanged ("Value", pc.Value); } } - Data = props.OrderBy(p=>p.Name).ToArray (); } } - public MembersView () : base() - { + public ImlProjectItem ProjectNode { + get { return projFile; } + set { + if (projFile == value) + return; + +// if (projFile != null) +// projFile.UnregisterEditor (this); + + projFile = value; + +// if (projFile != null) +// projFile.RegisterEditor (this); + + NotifyValueChanged ("ProjectNode", projFile); + } + } + + public void updateSource () { + if (projFile == null) + return; + projFile.UpdateSource (this, (Instance as GraphicObject).GetIML ()); } // public override void Paint (ref Context ctx) -- cgit v1.3.1-4-g156e