]> O.S.I.I.S - jp/crow.git/commitdiff
remove old ResolveBinding call, remove IBindable, DataSourceChanged event
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 4 Nov 2016 07:56:28 +0000 (08:56 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 5 Nov 2016 08:16:31 +0000 (09:16 +0100)
19 files changed:
Crow.csproj
Tests/Interfaces/Divers/welcome.crow
src/CompilerServices/Bindings.cs
src/GraphicObjects/Button.cs
src/GraphicObjects/DataSourceChangeEventArgs.cs [new file with mode: 0644]
src/GraphicObjects/Expandable.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/IBindable.cs [deleted file]
src/GraphicObjects/Label.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TemplatedContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/Window.cs
src/IMLReader.cs
src/Interface.cs

index 58eed914982ed6eb48f3bfb76713cba0913dfb33..6c44395e1c519cd1ad77da27ae70883f3415f4ec 100644 (file)
     <Compile Include="src\rsvg\RsvgSharp.SizeFuncNative.cs" />
     <Compile Include="src\rsvg\SizeFunc.cs" />
     <Compile Include="src\MouseCursorChangedEventArgs.cs" />
-    <Compile Include="src\GraphicObjects\IBindable.cs" />
     <Compile Include="src\Input\KeyPressEventArgs.cs" />
     <Compile Include="src\Configuration.cs" />
     <Compile Include="src\Measure.cs" />
     <Compile Include="src\GraphicObjects\MenuItem.cs" />
     <Compile Include="src\GraphicObjects\Menu.cs" />
     <Compile Include="src\Command.cs" />
+    <Compile Include="src\GraphicObjects\DataSourceChangeEventArgs.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
index 65fc3577b0fa2860374c2165bfd773f6be77f452..c4ec889f11bd47b92949ea2d2ce2baeecdeb948f 100644 (file)
@@ -3,4 +3,5 @@
        Margin="10" CornerRadius="10">
        <Label Font="20" Text="Press &lt;F3&gt; to cycle into the examples"/>
        <Label Font="20" Text="Those are basic tests used to validate changes"/>
+       <Label Font="20" Text="{fps}"/>
 </VerticalStack>
\ No newline at end of file
index 64f412f6cd0fd961c328a349aeb0688e46083558..2f4077b28670f0b6be4419972a57a06cce2ef5b6 100644 (file)
@@ -199,10 +199,10 @@ namespace Crow
 
                        if (Target.TryFindMember (memberName)) {
                                if (TwoWayBinding) {
-                                       IBindable source = Target.Instance as IBindable;
-                                       if (source == null)
-                                               throw new Exception (Source.Instance + " does not implement IBindable for 2 way bindings");
-                                       source.Bindings.Add (new Binding (Target, Source));
+//                                     IBindable source = Target.Instance as IBindable;
+//                                     if (source == null)
+//                                             throw new Exception (Source.Instance + " does not implement IBindable for 2 way bindings");
+//                                     source.Bindings.Add (new Binding (Target, Source));
                                }
                        }
                        #if DEBUG_BINDING
index 597621827264fb3f6c1d199bcb933cd62cc7c993..1cfbe85c722272b798ca161c1295daf001b3fed7 100644 (file)
@@ -47,12 +47,6 @@ namespace Crow
                #endregion
 
                #region GraphicObject Overrides
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (Content != null)
-                               Content.ResolveBindings ();
-               }
                public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
                        IsPressed = true;
diff --git a/src/GraphicObjects/DataSourceChangeEventArgs.cs b/src/GraphicObjects/DataSourceChangeEventArgs.cs
new file mode 100644 (file)
index 0000000..78a81f3
--- /dev/null
@@ -0,0 +1,37 @@
+//
+//  DataSourceChangeEventArg.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2016 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;
+
+namespace Crow
+{
+       public class DataSourceChangeEventArgs : EventArgs
+       {
+               public object OldDataSource;
+               public object NewDataSource;
+
+               public DataSourceChangeEventArgs (object oldDataSource, object newDataSource) : base()
+               {
+                       OldDataSource = oldDataSource;
+                       NewDataSource = newDataSource;
+               }
+       }
+}
+
index 70451f415b447512a0b0bb375a4e63dae658376f..fe9519afe47cb2c0ffd21b060662a2290ed614b0 100644 (file)
@@ -70,12 +70,6 @@ namespace Crow
 
                        _contentContainer = this.child.FindByName ("Content") as Container;
                }
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (Content != null)
-                               Content.ResolveBindings ();
-               }
 
                #region Public properties
                [XmlAttributeAttribute()][DefaultValue("Expandable")]
index 093664d11a16573e8b9584bd69a9ed5667095f29..5cc2ae784baee3a2c54cd3090be889dd7543f814 100644 (file)
@@ -12,16 +12,8 @@ using System.IO;
 
 namespace Crow
 {
-       public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange, ICloneable, IBindable
+       public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange, ICloneable
        {
-               #region IBindable implementation
-               List<Binding> bindings = new List<Binding> ();
-               public List<Binding> Bindings {
-                       get { return bindings; }
-               }
-
-               #endregion
-
                internal static ulong currentUid = 0;
                internal ulong uid = 0;
 
@@ -87,7 +79,7 @@ namespace Crow
                Size minimumSize = "0,0";
                bool cacheEnabled = false;
                bool clipToClientRect = true;
-               object dataSource;
+               protected object dataSource;
                string style;
                #endregion
 
@@ -136,7 +128,15 @@ namespace Crow
                }
                [XmlIgnore]public ILayoutable LogicalParent {
                        get { return logicalParent == null ? Parent : logicalParent; }
-                       set { logicalParent = value; }
+                       set { 
+                               if (logicalParent == value)
+                                       return;
+                               if (logicalParent != null)
+                                       (logicalParent as GraphicObject).DataSourceChanged -= onLogicalParentDataSourceChanged;
+                               logicalParent = value; 
+                               if (logicalParent != null)
+                                       (logicalParent as GraphicObject).DataSourceChanged += onLogicalParentDataSourceChanged;
+                       }
                }
                [XmlIgnore]public virtual Rectangle ClientRectangle {
                        get {
@@ -177,6 +177,7 @@ namespace Crow
                public event EventHandler Enabled;
                public event EventHandler Disabled;
                public event EventHandler<LayoutingEventArgs> LayoutChanged;
+               public event EventHandler<DataSourceChangeEventArgs> DataSourceChanged;
                #endregion
 
                #region public properties
@@ -365,6 +366,10 @@ namespace Crow
                                        return;
 
                                hasFocus = value;
+                               if (hasFocus)
+                                       onFocused (this, null);
+                               else
+                                       onUnfocused (this, null);
                                NotifyValueChanged ("HasFocus", hasFocus);
                        }
                }
@@ -515,25 +520,25 @@ namespace Crow
                                RegisterForLayouting (LayoutingType.Sizing);
                        }
                }
+               /// <summary>
+               /// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
+               /// a not null dataSource that will be active for all descendants having dataSource=null
+               /// </summary>
                [XmlAttributeAttribute][DefaultValue(null)]
                public virtual object DataSource {
                        set {
                                if (dataSource == value)
                                        return;
-                               #if DEBUG_BINDING
-                               Debug.WriteLine("******************************");
-                               Debug.WriteLine("New DataSource for => " + this.ToString());
-                               Debug.WriteLine("\t- " + DataSource);
-                               Debug.WriteLine("\t+ " + value);
-                               #endif
 
-                               this.ClearBinding ();
+                               DataSourceChangeEventArgs dse = new DataSourceChangeEventArgs (dataSource, null);
 
                                dataSource = value;
 
-                               this.ResolveBindings();
+                               dse.NewDataSource = DataSource;
+
+                               OnDataSourceChanged (this, dse);
 
-                               NotifyValueChanged ("DataSource", dataSource);
+                               NotifyValueChanged ("DataSource", DataSource);
                        }
                        get {
                                return dataSource == null ? LogicalParent == null ? null :
@@ -541,6 +546,25 @@ namespace Crow
                                        (LogicalParent as GraphicObject).DataSource : null : dataSource;
                        }
                }
+               protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){
+                       ILayoutable tmp = Parent;
+                       while (tmp != sender) {
+                               if (!(tmp as GraphicObject).localDataSourceIsNull) {
+                                       OnDataSourceChanged (sender, e);
+                                       return;
+                               }
+                               tmp = tmp.Parent;
+                       }
+               }
+               internal bool localDataSourceIsNull { get { return dataSource == null; } }
+
+               public virtual void OnDataSourceChanged(object sender, DataSourceChangeEventArgs e){                    
+                       DataSourceChanged.Raise (sender, e);
+                       //#if DEBUG_BINDING
+                       Debug.WriteLine("New DataSource for => {0} \n\t{1}=>{2}", this.ToString(),e.OldDataSource,e.NewDataSource);
+                       //#endif
+               }
+                       
                [XmlAttributeAttribute]
                public virtual string Style {
                        get { return style; }
@@ -1183,20 +1207,17 @@ namespace Crow
                }
                #endregion
 
-               public virtual void onFocused(object sender, EventArgs e){
+               protected virtual void onFocused(object sender, EventArgs e){
                        #if DEBUG_FOCUS
                        Debug.WriteLine("Focused => " + this.ToString());
                        #endif
                        Focused.Raise (this, e);
-                       this.HasFocus = true;
                }
-               public virtual void onUnfocused(object sender, EventArgs e){
+               protected virtual void onUnfocused(object sender, EventArgs e){
                        #if DEBUG_FOCUS
                        Debug.WriteLine("UnFocused => " + this.ToString());
                        #endif
-
                        Unfocused.Raise (this, e);
-                       this.HasFocus = false;
                }
                public virtual void onEnable(object sender, EventArgs e){
                        Enabled.Raise (this, e);
@@ -1206,84 +1227,84 @@ namespace Crow
                }
 
                #region Binding
-               public void BindMember(string _member, string _expression){
-                       Bindings.Add(new Binding (this, _member, _expression));
-               }
-               public virtual void ResolveBindings()
-               {
-                       if (Bindings.Count == 0)
-                               return;
-                       #if DEBUG_BINDING
-                       Debug.WriteLine ("Resolve Bindings => " + this.ToString ());
-                       #endif
-
-                       CompilerServices.ResolveBindings (Bindings);
-               }
+//             public void BindMember(string _member, string _expression){
+//                     Bindings.Add(new Binding (this, _member, _expression));
+//             }
+//             public virtual void ResolveBindings()
+//             {
+//                     if (Bindings.Count == 0)
+//                             return;
+//                     #if DEBUG_BINDING
+//                     Debug.WriteLine ("Resolve Bindings => " + this.ToString ());
+//                     #endif
+//
+//                     CompilerServices.ResolveBindings (Bindings);
+//             }
 
                /// <summary>
                /// Remove dynamic delegates by ids from dataSource
                ///  and delete ref of this in Shared interface refs
                /// </summary>
-               public virtual void ClearBinding(){
-                       //dont clear binding if dataSource is not null,
-                       foreach (Binding b in Bindings) {
-                               try {
-                                       if (!b.Resolved)
-                                               continue;
-                                       //cancel compiled events
-                                       if (b.Target == null){
-                                               continue;
-                                               #if DEBUG_BINDING
-                                               Debug.WriteLine("Clear binding canceled for => " + b.ToString());
-                                               #endif
-                                       }
-                                       if (b.Target.Instance != DataSource){
-                                               #if DEBUG_BINDING
-                                               Debug.WriteLine("Clear binding canceled for => " + b.ToString());
-                                               #endif
-                                               continue;
-                                       }
-                                       #if DEBUG_BINDING
-                                       Debug.WriteLine("ClearBinding => " + b.ToString());
-                                       #endif
-                                       if (string.IsNullOrEmpty (b.DynMethodId)) {
-                                               b.Resolved = false;
-                                               if (b.Source.Member.MemberType == MemberTypes.Event)
-                                                       removeEventHandler (b);
-                                               //TODO:check if full reset is necessary
-                                               continue;
-                                       }
-                                       MemberReference mr = null;
-                                       if (b.Target == null)
-                                               mr = b.Source;
-                                       else
-                                               mr = b.Target;
-                                       Type dataSourceType = mr.Instance.GetType();
-                                       EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");
-                                       FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");
-                                       MulticastDelegate multicastDelegate = evtFi.GetValue (mr.Instance) as MulticastDelegate;
-                                       if (multicastDelegate != null) {
-                                               foreach (Delegate d in multicastDelegate.GetInvocationList()) {
-                                                       if (d.Method.Name == b.DynMethodId)
-                                                               evtInfo.RemoveEventHandler (mr.Instance, d);
-                                               }
-                                       }
-                                       b.Reset ();
-                               } catch (Exception ex) {
-                                       Debug.WriteLine("\t Error: " + ex.ToString());
-                               }
-                       }
-               }
-               void removeEventHandler(Binding b){
-                       FieldInfo fiEvt = CompilerServices.GetEventHandlerField (b.Source.Instance.GetType(), b.Source.Member.Name);
-                       MulticastDelegate multiDel = fiEvt.GetValue (b.Source.Instance) as MulticastDelegate;
-                       if (multiDel != null) {
-                               foreach (Delegate d in multiDel.GetInvocationList()) {
-                                       if (d.Method.Name == b.Target.Member.Name)
-                                               b.Source.Event.RemoveEventHandler (b.Source.Instance, d);
-                               }
-                       }
-               }
+//             public virtual void ClearBinding(){
+//                     //dont clear binding if dataSource is not null,
+//                     foreach (Binding b in Bindings) {
+//                             try {
+//                                     if (!b.Resolved)
+//                                             continue;
+//                                     //cancel compiled events
+//                                     if (b.Target == null){
+//                                             continue;
+//                                             #if DEBUG_BINDING
+//                                             Debug.WriteLine("Clear binding canceled for => " + b.ToString());
+//                                             #endif
+//                                     }
+//                                     if (b.Target.Instance != DataSource){
+//                                             #if DEBUG_BINDING
+//                                             Debug.WriteLine("Clear binding canceled for => " + b.ToString());
+//                                             #endif
+//                                             continue;
+//                                     }
+//                                     #if DEBUG_BINDING
+//                                     Debug.WriteLine("ClearBinding => " + b.ToString());
+//                                     #endif
+//                                     if (string.IsNullOrEmpty (b.DynMethodId)) {
+//                                             b.Resolved = false;
+//                                             if (b.Source.Member.MemberType == MemberTypes.Event)
+//                                                     removeEventHandler (b);
+//                                             //TODO:check if full reset is necessary
+//                                             continue;
+//                                     }
+//                                     MemberReference mr = null;
+//                                     if (b.Target == null)
+//                                             mr = b.Source;
+//                                     else
+//                                             mr = b.Target;
+//                                     Type dataSourceType = mr.Instance.GetType();
+//                                     EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");
+//                                     FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");
+//                                     MulticastDelegate multicastDelegate = evtFi.GetValue (mr.Instance) as MulticastDelegate;
+//                                     if (multicastDelegate != null) {
+//                                             foreach (Delegate d in multicastDelegate.GetInvocationList()) {
+//                                                     if (d.Method.Name == b.DynMethodId)
+//                                                             evtInfo.RemoveEventHandler (mr.Instance, d);
+//                                             }
+//                                     }
+//                                     b.Reset ();
+//                             } catch (Exception ex) {
+//                                     Debug.WriteLine("\t Error: " + ex.ToString());
+//                             }
+//                     }
+//             }
+//             void removeEventHandler(Binding b){
+//                     FieldInfo fiEvt = CompilerServices.GetEventHandlerField (b.Source.Instance.GetType(), b.Source.Member.Name);
+//                     MulticastDelegate multiDel = fiEvt.GetValue (b.Source.Instance) as MulticastDelegate;
+//                     if (multiDel != null) {
+//                             foreach (Delegate d in multiDel.GetInvocationList()) {
+//                                     if (d.Method.Name == b.Target.Member.Name)
+//                                             b.Source.Event.RemoveEventHandler (b.Source.Instance, d);
+//                             }
+//                     }
+//             }
                #endregion
 
                #region IXmlSerializable
@@ -1291,60 +1312,60 @@ namespace Crow
                {
                        return null;
                }
-               void affectMember(string name, string value){
-                       Type thisType = this.GetType ();
-
-                       if (string.IsNullOrEmpty (value))
-                               return;
-
-                       MemberInfo mi = thisType.GetMember (name).FirstOrDefault();
-                       if (mi == null) {
-                               Debug.WriteLine ("XML: Unknown attribute in " + thisType.ToString() + " : " + name);
-                               return;
-                       }
-                       if (mi.MemberType == MemberTypes.Event) {
-                               this.Bindings.Add (new Binding (new MemberReference(this, mi), value));
-                               return;
-                       }
-                       if (mi.MemberType == MemberTypes.Property) {
-                               PropertyInfo pi = mi as PropertyInfo;
-
-                               if (pi.GetSetMethod () == null) {
-                                       Debug.WriteLine ("XML: Read only property in " + thisType.ToString() + " : " + name);
-                                       return;
-                               }
-
-                               XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute));
-                               if (xaa != null) {
-                                       if (!string.IsNullOrEmpty (xaa.AttributeName))
-                                               name = xaa.AttributeName;
-                               }
-                               if (value.StartsWith("{",StringComparison.Ordinal)) {
-                                       //binding
-                                       if (!value.EndsWith("}", StringComparison.Ordinal))
-                                               throw new Exception (string.Format("XML:Malformed binding: {0}", value));
-
-                                       this.Bindings.Add (new Binding (new MemberReference(this, pi), value.Substring (1, value.Length - 2)));
-                                       return;
-                               }
-                               if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null)
-                                       return;
-                               if (xaa == null)//not define as xmlAttribute
-                                       return;
-
-                               if (pi.PropertyType == typeof(string)) {
-                                       pi.SetValue (this, value, null);
-                                       return;
-                               }
-
-                               if (pi.PropertyType.IsEnum) {
-                                       pi.SetValue (this, Enum.Parse (pi.PropertyType, value), null);
-                               } else {
-                                       MethodInfo me = pi.PropertyType.GetMethod ("Parse", new Type[] { typeof(string) });
-                                       pi.SetValue (this, me.Invoke (null, new string[] { value }), null);
-                               }
-                       }
-               }
+//             void affectMember(string name, string value){
+//                     Type thisType = this.GetType ();
+//
+//                     if (string.IsNullOrEmpty (value))
+//                             return;
+//
+//                     MemberInfo mi = thisType.GetMember (name).FirstOrDefault();
+//                     if (mi == null) {
+//                             Debug.WriteLine ("XML: Unknown attribute in " + thisType.ToString() + " : " + name);
+//                             return;
+//                     }
+//                     if (mi.MemberType == MemberTypes.Event) {
+//                             this.Bindings.Add (new Binding (new MemberReference(this, mi), value));
+//                             return;
+//                     }
+//                     if (mi.MemberType == MemberTypes.Property) {
+//                             PropertyInfo pi = mi as PropertyInfo;
+//
+//                             if (pi.GetSetMethod () == null) {
+//                                     Debug.WriteLine ("XML: Read only property in " + thisType.ToString() + " : " + name);
+//                                     return;
+//                             }
+//
+//                             XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute));
+//                             if (xaa != null) {
+//                                     if (!string.IsNullOrEmpty (xaa.AttributeName))
+//                                             name = xaa.AttributeName;
+//                             }
+//                             if (value.StartsWith("{",StringComparison.Ordinal)) {
+//                                     //binding
+//                                     if (!value.EndsWith("}", StringComparison.Ordinal))
+//                                             throw new Exception (string.Format("XML:Malformed binding: {0}", value));
+//
+//                                     this.Bindings.Add (new Binding (new MemberReference(this, pi), value.Substring (1, value.Length - 2)));
+//                                     return;
+//                             }
+//                             if (pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)) != null)
+//                                     return;
+//                             if (xaa == null)//not define as xmlAttribute
+//                                     return;
+//
+//                             if (pi.PropertyType == typeof(string)) {
+//                                     pi.SetValue (this, value, null);
+//                                     return;
+//                             }
+//
+//                             if (pi.PropertyType.IsEnum) {
+//                                     pi.SetValue (this, Enum.Parse (pi.PropertyType, value), null);
+//                             } else {
+//                                     MethodInfo me = pi.PropertyType.GetMethod ("Parse", new Type[] { typeof(string) });
+//                                     pi.SetValue (this, me.Invoke (null, new string[] { value }), null);
+//                             }
+//                     }
+//             }
                public virtual void ReadXml (System.Xml.XmlReader reader)
                {
                        if (reader.HasAttributes) {
@@ -1357,7 +1378,7 @@ namespace Crow
                                        if (reader.Name == "Style")
                                                continue;
 
-                                       affectMember (reader.Name, reader.Value);
+                                       //affectMember (reader.Name, reader.Value);
                                }
                                reader.MoveToElement ();
                        }else
@@ -1475,12 +1496,6 @@ namespace Crow
                /// <summary>
                /// full GraphicTree clone with binding definition
                /// </summary>
-               public virtual GraphicObject DeepClone(){
-                       GraphicObject tmp = Clone () as GraphicObject;
-                       foreach (Binding b in this.bindings)
-                               tmp.Bindings.Add (new Binding (new MemberReference (tmp, b.Source.Member), b.Expression));
-                       return tmp;
-               }
 
                public override string ToString ()
                {
index efe02d95cfd24e9521a0d0717cfdba810ba9a081..da42b8f53c203248a7bc8ecdc5b49437ebdf040b 100644 (file)
@@ -40,7 +40,6 @@ namespace Crow
                        lock (children)
                                Children.Add(g);
                        g.Parent = this;
-                       g.ResolveBindings ();
                        g.RegisteredLayoutings = LayoutingType.None;
                        g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
                        g.LayoutChanged += OnChildLayoutChanges;
@@ -48,7 +47,6 @@ namespace Crow
         public virtual void RemoveChild(GraphicObject child)        
                {
                        child.LayoutChanged -= OnChildLayoutChanges;
-                       child.ClearBinding ();
                        //child.Parent = null;
                        lock (children)
                Children.Remove(child);
@@ -65,7 +63,6 @@ namespace Crow
                        while(Children.Count > 0){
                                GraphicObject g = Children[Children.Count-1];
                                g.LayoutChanged -= OnChildLayoutChanges;
-                               g.ClearBinding ();
                                g.Parent = null;
                                Children.RemoveAt(Children.Count-1);
                        }
@@ -94,11 +91,12 @@ namespace Crow
                }
 
                #region GraphicObject overrides
-               public override void ResolveBindings ()
+               public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
                {
-                       base.ResolveBindings ();
-                       foreach (GraphicObject w in Children)
-                               w.ResolveBindings ();
+                       base.OnDataSourceChanged (sender, e);
+                       foreach (GraphicObject g in children)
+                               if (g.localDataSourceIsNull)
+                                       g.OnDataSourceChanged (sender, e);
                }
                public override GraphicObject FindByName (string nameToFind)
                {
@@ -365,17 +363,5 @@ namespace Crow
     
                #endregion
 
-               public override void ClearBinding(){
-                       foreach (GraphicObject c in Children)
-                               c.ClearBinding ();
-                       base.ClearBinding ();
-               }
-               public override GraphicObject DeepClone ()
-               {
-                       Group tmp = base.DeepClone () as Group;
-                       foreach (GraphicObject c in Children)
-                               tmp.AddChild (c.DeepClone ());
-                       return tmp;
-               }
        }
 }
diff --git a/src/GraphicObjects/IBindable.cs b/src/GraphicObjects/IBindable.cs
deleted file mode 100644 (file)
index 45ff586..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-//  IValueChange.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.Collections.Generic;
-
-namespace Crow
-{
-       public interface IBindable
-       {
-               List<Binding> Bindings { get; }
-               object DataSource { get; set; }
-       }
-}
-
index 666f00a28d80853d8feaaddeec2224572b9e2f39..2f35c223de2259e51132d855804a7dad13b278cc 100644 (file)
@@ -670,7 +670,7 @@ namespace Crow
                        base.onMouseLeave (sender, e);
                        CurrentInterface.MouseCursor = XCursor.Default;
                }
-               public override void onFocused (object sender, EventArgs e)
+               protected override void onFocused (object sender, EventArgs e)
                {
                        base.onFocused (sender, e);
 
@@ -680,7 +680,7 @@ namespace Crow
                        SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1);
                        RegisterForRedraw ();
                }
-               public override void onUnfocused (object sender, EventArgs e)
+               protected override void onUnfocused (object sender, EventArgs e)
                {
                        base.onUnfocused (sender, e);
 
index 1bfdf19ce89e5c14590ad1a7dd18d7c83571e078..e4cde7ed550eb475e9e80586a39c571f22692632 100644 (file)
@@ -175,21 +175,6 @@ namespace Crow
                                _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
                }
 
-               public override void ClearBinding ()
-               {
-                       //ensure popped window is cleared
-                       if (Content != null) {
-                               if (Content.Parent != null)
-                                       CurrentInterface.DeleteWidget (Content);
-                       }
-                       base.ClearBinding ();
-               }
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (Content != null)
-                               Content.ResolveBindings ();
-               }
 
                public override void onMouseClick (object sender, MouseButtonEventArgs e)
                {
index 2a5deeaaa6866c0bf673e177d418324e9fa7c26c..06f0c2132368bfbde5d483f7044c89cefd9163ea 100644 (file)
@@ -47,7 +47,6 @@ namespace Crow
                {
 
                        if (child != null) {
-                               child.ClearBinding ();
                                contentSize = new Size (0, 0);
                                child.LayoutChanged -= OnChildLayoutChanges;
                                child.Parent = null;
@@ -66,16 +65,7 @@ namespace Crow
                }
 
                #region GraphicObject Overrides
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (child != null)
-                               child.ResolveBindings ();
-               }
-               protected void ResolveBindingsWithNoRecurse ()
-               {
-                       base.ResolveBindings ();
-               }
+
                public override GraphicObject FindByName (string nameToFind)
                {
                        if (Name == nameToFind)
@@ -88,6 +78,13 @@ namespace Crow
                        return child == goToFind ? true : 
                                child == null ? false : child.Contains(goToFind);
                }
+               public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
+               {
+                       base.OnDataSourceChanged (sender, e);
+                       if (child != null)
+                               if (child.localDataSourceIsNull)
+                                       child.OnDataSourceChanged (sender, e);
+               }
                public override bool UpdateLayout (LayoutingType layoutType)
                {
                        if (child != null) {
@@ -197,19 +194,6 @@ namespace Crow
                }
                #endregion
 
-               public override void ClearBinding ()
-               {
-                       if (child != null)
-                               child.ClearBinding ();
-                       base.ClearBinding ();
-               }
-               public override GraphicObject DeepClone ()
-               {
-                       PrivateContainer tmp = base.DeepClone () as PrivateContainer;
-                       if (child != null)
-                                       tmp.SetChild (child.DeepClone ());
-                       return tmp;
-               }
        }
 }
 
index e14a7815ec4c1d882eee491868f2b1dcca7253b0..078fd04d7dadbc9cdaa10bc5a0142df3019c28ef 100644 (file)
@@ -49,12 +49,6 @@ namespace Crow
                                _contentContainer.SetChild(value);
                        }
                }
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (_contentContainer != null)
-                               _contentContainer.ResolveBindings ();
-               }
                protected override void loadTemplate(GraphicObject template = null)
                {
                        base.loadTemplate (template);
index 7a4649a495212fd4761044b3484901b8a75aac6c..44c2ad08931294194a42963a08f2d935ba60986c 100644 (file)
@@ -34,19 +34,6 @@ namespace Crow
                [XmlIgnore]public abstract GraphicObject Content{ get; set;}
 
                #region GraphicObject overrides
-               public override void ClearBinding ()
-               {
-                       if (Content != null)
-                               Content.ClearBinding ();
-
-                       base.ClearBinding ();
-               }
-//             public override void ResolveBindings ()
-//             {
-//                     base.ResolveBindings ();
-//                     if (Content != null)
-//                             Content.ResolveBindings ();
-//             }
                public override GraphicObject FindByName (string nameToFind)
                {
                        if (Name == nameToFind)
index 7f2e1b87b3bf13f7ef962f97a27c2a920391f7c1..ba49f44fd0d854f7017527ee089464641b797562 100644 (file)
@@ -94,8 +94,6 @@ namespace Crow
                                this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
                        }else
                                this.SetChild (template);
-
-                       this.ResolveBindings ();
                }
 
                //TODO:IXmlSerializable is not used anymore
index 500e5ea658df86782f0cac756098fd8adbb5979b..7b7f897c82b8958da3cec32f1283d6890ae3a950 100644 (file)
@@ -307,8 +307,8 @@ namespace Crow
 //                     //because items total size is forced to approx size
 //                     if (_gsList.Orientation == Orientation.Horizontal) {
 //                             page.Width = Measure.Fit;
-                               page.BindMember ("Height", "../HeightPolicy");
-                               page.BindMember ("Width", "../WidthPolicy");
+                               //page.BindMember ("Height", "../HeightPolicy");
+                               //page.BindMember ("Width", "../WidthPolicy");
 //                     } else {
 //                             page.Height = Measure.Fit;
 //                             page.BindMember ("Width", "../WidthPolicy");
index 9ef9e6429eb8f4cbdfa45dbde6670031cc17d705..86f05d8646771a115f013fbcc501a4e6459f5379 100644 (file)
@@ -134,12 +134,6 @@ namespace Crow
                #endregion
 
                #region GraphicObject Overrides
-               public override void ResolveBindings ()
-               {
-                       base.ResolveBindings ();
-                       if (Content != null)
-                               Content.ResolveBindings ();
-               }
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseMove (sender, e);
index f9df89fffd5a55fdd5dce425a2a6a411f0022c00..55317abac9f1e565b25713129d86e1bf0b364ba1 100644 (file)
@@ -196,6 +196,12 @@ namespace Crow
                        emitLoader(RootType);
                        Read();//close tag
                }
+
+               void createBindingDelegates(){
+//                     foreach (Dictionary<string, MemberAddress> pb in IMLCtx.PropertyBindings) {
+//                             
+//                     }
+               }
                /// <summary>
                /// Inits il generator, RootType must have been read first
                /// </summary>
@@ -363,7 +369,7 @@ namespace Crow
                                                if (reader.Value.StartsWith ("{")) {
                                                        readPropertyBinding(reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
 
-                                                       CompilerServices.emitBindingCreation (reader.il, reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
+                                                       //CompilerServices.emitBindingCreation (reader.il, reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
                                                }else
                                                        CompilerServices.EmitSetValue (reader.il, pi, reader.Value);
 
@@ -445,11 +451,16 @@ namespace Crow
                                        }
                                }
                                Node[] origine = new Node[nodeIdx + 1];
-                               Array.Copy (target, origine, nodeIdx + 1);
+                               try {
+                                       Array.Copy (target, origine, nodeIdx + 1);
 
-                               int destLength = target.Length - nodeIdx;
-                               Node[] dest = new Node[destLength];
-                               Array.Copy (target, nodeIdx, dest, 0, destLength);
+                                       int destLength = target.Length - nodeIdx;
+                                       Node[] dest = new Node[destLength];
+                                       Array.Copy (target, nodeIdx, dest, 0, destLength);
+
+                               } catch (Exception ex) {
+                                       System.Diagnostics.Debug.WriteLine (ex.ToString ());
+                               }
 
 
                                nodeId = Node.AddressToString (origine);
index 1659c0ea29a9ea8ac9c48b5a103d13a3246cd5f1..941b96f93f5b3db74bc6dfb7cdc50e4c95b1aba0 100644 (file)
@@ -312,10 +312,10 @@ namespace Crow
                                if (_focusedWidget == value)
                                        return;
                                if (_focusedWidget != null)
-                                       _focusedWidget.onUnfocused (this, null);
+                                       _focusedWidget.HasFocus = false;
                                _focusedWidget = value;
                                if (_focusedWidget != null)
-                                       _focusedWidget.onFocused (this, null);
+                                       _focusedWidget.HasFocus = true;
                        }
                }
                #endregion
@@ -499,7 +499,6 @@ namespace Crow
                public void DeleteWidget(GraphicObject g)
                {
                        g.Visible = false;//trick to ensure clip is added to refresh zone
-                       g.ClearBinding();
                        GraphicTree.Remove (g);
                }
                public void PutOnTop(GraphicObject g)
@@ -520,7 +519,6 @@ namespace Crow
                                //to ObjectToRedraw list, and without parent, it fails
                                GraphicObject g = GraphicTree [i];
                                g.Visible = false;
-                               g.ClearBinding ();
                                GraphicTree.RemoveAt (0);
                        }
                        #if DEBUG_LAYOUTING