]> O.S.I.I.S - jp/crow.git/commitdiff
root data level
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 15 Mar 2018 02:27:35 +0000 (03:27 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 15 Mar 2018 02:27:35 +0000 (03:27 +0100)
src/GraphicObjects/GraphicObject.cs

index 2533fb1b74d0fe34d4b57335d9c3468da1d21041..f404b5f1b71e8abf77b29802220f37014452c4b9 100644 (file)
@@ -298,6 +298,7 @@ namespace Crow
                bool cacheEnabled = false;
                bool clipToClientRect = true;
                protected object dataSource;
+               bool rootDataLevel;
                string style;
                object tag;
                bool isDragged;
@@ -944,19 +945,36 @@ namespace Crow
 
                                if (dse.NewDataSource == dse.OldDataSource)
                                        return;
-                       
-                               OnDataSourceChanged (this, dse);
-
 
-                               NotifyValueChanged ("DataSource", DataSource);
+                               if (value != null)
+                                       rootDataLevel = true;
+                               
+                               lock (IFace.LayoutMutex) {
+                                       OnDataSourceChanged (this, dse);
+                                       NotifyValueChanged ("DataSource", DataSource);
+                               }
                        }
                        get {
-                               return dataSource == null ?
+                               return rootDataLevel ? dataSource : dataSource == null ?
                                        LogicalParent == null ? null :
                                        LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null :
                                        dataSource;
                        }
                }
+               /// <summary>
+               /// If true, rendering of GraphicObject is clipped inside client rectangle
+               /// </summary>
+               [DesignCategory ("Data")][DefaultValue(false)]
+               public virtual bool RootDataLevel {
+                       get { return rootDataLevel; }
+                       set {
+                               if (rootDataLevel == value)
+                                       return;
+                               rootDataLevel = value;
+                               NotifyValueChanged ("RootDataLevel", rootDataLevel);
+                               this.RegisterForRedraw ();
+                       }
+               }
                protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){
                        if (localDataSourceIsNull)
                                OnDataSourceChanged (this, e);