From: jpbruyere Date: Tue, 18 Oct 2016 16:09:47 +0000 (+0200) Subject: Different temp items in Obj property tab depending on property type X-Git-Tag: v0.5.1~28^2~23 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=9c20917cbb721669d9078e1858d2733827253326;p=jp%2Fcrow.git Different temp items in Obj property tab depending on property type modifié : CrowIDE/CrowIDE.csproj modifié : CrowIDE/src/MembersView.cs modifié : CrowIDE/ui/imlEditor.crow --- diff --git a/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index 8c8f4bf9..0320b343 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -17,7 +17,7 @@ - 0.4 + 0.5 CrowIDE.CrowIDE @@ -99,4 +99,4 @@ PreserveNewest - \ No newline at end of file + diff --git a/CrowIDE/src/MembersView.cs b/CrowIDE/src/MembersView.cs index 52f8da04..3f250dd9 100644 --- a/CrowIDE/src/MembersView.cs +++ b/CrowIDE/src/MembersView.cs @@ -27,12 +27,57 @@ using System.Collections.Generic; namespace CrowIDE { - public class PropertyContainer { + public class PropertyContainer : IBindable + { + public object DataSource { + get { + throw new NotImplementedException (); + } + set { + throw new NotImplementedException (); + } + } + + #region IBindable implementation + List bindings = new List (); + public List Bindings { + get { return bindings; } + } + #endregion + PropertyInfo pi; object instance; public string Name { get { return pi.Name; }} - public object Value { get { return pi.GetValue(instance); }} + public object Value { + get { return pi.GetValue(instance); } + set { + try { + if (pi.PropertyType != value.GetType() && pi.PropertyType != typeof(string)){ + if (pi.PropertyType.IsEnum) { + pi.SetValue (instance, value); + } else { + MethodInfo me = pi.PropertyType.GetMethod + ("Parse", BindingFlags.Static | BindingFlags.Public, + System.Type.DefaultBinder, new Type [] {typeof (string)},null); + pi.SetValue (instance, me.Invoke (null, new object[] { value }), null); + } + }else + pi.SetValue(instance, value); + } catch (Exception ex) { + System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString()); + } + + } + } + public string Type { get { return pi.PropertyType.IsEnum ? + "System.Enum" + : pi.PropertyType.FullName; }} + public string[] Choices { + get { + return Enum.GetNames (pi.PropertyType); + } + } public PropertyContainer(PropertyInfo prop, object _instance){ pi = prop; diff --git a/CrowIDE/ui/imlEditor.crow b/CrowIDE/ui/imlEditor.crow index dae1c84f..984394f6 100644 --- a/CrowIDE/ui/imlEditor.crow +++ b/CrowIDE/ui/imlEditor.crow @@ -48,17 +48,75 @@ - - - + + + + + + + + + +- + - - - - - +