diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-27 18:18:42 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-27 18:18:42 +0100 |
| commit | 508b53d725958e6a8c8be51db04033aeff1df0da (patch) | |
| tree | 8495cf890a9cee3466aa8eaceb073f391fb5d628 /CrowIDE/src/MembersView.cs | |
| parent | f4c05f6b4ddd426a87492b51aca5147d5def2bc5 (diff) | |
crowide wip, DesignIDS
Diffstat (limited to 'CrowIDE/src/MembersView.cs')
| -rw-r--r-- | CrowIDE/src/MembersView.cs | 74 |
1 files changed, 57 insertions, 17 deletions
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<string,PropertyContainer[]> propContainersCache = new Dictionary<string, PropertyContainer[]>(); [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<PropertyContainer> props = new List<PropertyContainer> (); + 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<PropertyContainer> props = new List<PropertyContainer> (); - 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) |