aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/GraphicObject.cs39
-rw-r--r--src/GraphicObjects/Group.cs4
-rw-r--r--src/GraphicObjects/PrivateContainer.cs4
-rw-r--r--src/GraphicObjects/TabItem.cs6
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs3
5 files changed, 32 insertions, 24 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index a2f9be7c..1be9d4cf 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -140,9 +140,12 @@ namespace Crow
return;
if (logicalParent != null)
(logicalParent as GraphicObject).DataSourceChanged -= onLogicalParentDataSourceChanged;
+ DataSourceChangeEventArgs dsce = new DataSourceChangeEventArgs (LogicalParent, null);
logicalParent = value;
+ dsce.NewDataSource = LogicalParent;
if (logicalParent != null)
(logicalParent as GraphicObject).DataSourceChanged += onLogicalParentDataSourceChanged;
+ onLogicalParentChanged (this, dsce);
}
}
[XmlIgnore]public virtual Rectangle ClientRectangle {
@@ -186,6 +189,7 @@ namespace Crow
public event EventHandler<LayoutingEventArgs> LayoutChanged;
public event EventHandler<DataSourceChangeEventArgs> DataSourceChanged;
public event EventHandler<DataSourceChangeEventArgs> ParentChanged;
+ public event EventHandler<DataSourceChangeEventArgs> LogicalParentChanged;
#endregion
#region public properties
@@ -535,37 +539,30 @@ namespace Crow
[XmlAttributeAttribute][DefaultValue(null)]
public virtual object DataSource {
set {
- if (dataSource == value)
+ if (DataSource == value)
return;
- DataSourceChangeEventArgs dse = new DataSourceChangeEventArgs (dataSource, value);
+ DataSourceChangeEventArgs dse = new DataSourceChangeEventArgs (DataSource, null);
dataSource = value;
+ dse.NewDataSource = DataSource;
OnDataSourceChanged (this, dse);
NotifyValueChanged ("DataSource", DataSource);
}
get {
- return dataSource == null ? LogicalParent == null ? null :
- LogicalParent is GraphicObject ?
- (LogicalParent as GraphicObject).DataSource : null : dataSource;
+ return dataSource == null ?
+ LogicalParent == null ? null :
+ LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null :
+ dataSource;
}
}
protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){
- ILayoutable tmp = Parent;
- if (tmp == null) {
- Debug.WriteLine ("parent is null for: " + this.ToString ());
- return;
- }
- while (tmp != sender) {
- if (!(tmp as GraphicObject).localDataSourceIsNull) {
- OnDataSourceChanged (sender, e);
- return;
- }
- tmp = tmp.Parent;
- }
+ if (localDataSourceIsNull)
+ OnDataSourceChanged (this, e);
}
internal bool localDataSourceIsNull { get { return dataSource == null; } }
+ internal bool localLogicalParentIsNull { get { return logicalParent == null; } }
public virtual void OnDataSourceChanged(object sender, DataSourceChangeEventArgs e){
DataSourceChanged.Raise (this, e);
@@ -1254,9 +1251,13 @@ namespace Crow
Disabled.Raise (this, e);
}
protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) {
- ParentChanged.Raise (sender, e);
+ ParentChanged.Raise (this, e);
+ if (logicalParent == null)
+ LogicalParentChanged.Raise (this, e);
+ }
+ protected virtual void onLogicalParentChanged(object sender, DataSourceChangeEventArgs e) {
+ LogicalParentChanged.Raise (this, e);
}
-
#region IXmlSerializable
public virtual System.Xml.Schema.XmlSchema GetSchema ()
{
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index da42b8f5..a285e282 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -93,9 +93,9 @@ namespace Crow
#region GraphicObject overrides
public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
{
- base.OnDataSourceChanged (sender, e);
+ base.OnDataSourceChanged (this, e);
foreach (GraphicObject g in children)
- if (g.localDataSourceIsNull)
+ if (g.localDataSourceIsNull & g.localLogicalParentIsNull)
g.OnDataSourceChanged (sender, e);
}
public override GraphicObject FindByName (string nameToFind)
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index 06f0c213..0afefeb9 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -80,9 +80,9 @@ namespace Crow
}
public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
{
- base.OnDataSourceChanged (sender, e);
+ base.OnDataSourceChanged (this, e);
if (child != null)
- if (child.localDataSourceIsNull)
+ if (child.localDataSourceIsNull & child.localLogicalParentIsNull)
child.OnDataSourceChanged (sender, e);
}
public override bool UpdateLayout (LayoutingType layoutType)
diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs
index 078fd04d..cd57b221 100644
--- a/src/GraphicObjects/TabItem.cs
+++ b/src/GraphicObjects/TabItem.cs
@@ -46,7 +46,13 @@ namespace Crow
return _contentContainer == null ? null : _contentContainer.Child;
}
set {
+ if (Content != null) {
+ Content.LogicalParent = null;
+ _contentContainer.SetChild (null);
+ }
_contentContainer.SetChild(value);
+ if (value != null)
+ value.LogicalParent = this;
}
}
protected override void loadTemplate(GraphicObject template = null)
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index 7b7f897c..1664f671 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -42,7 +42,6 @@ namespace Crow
public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
#endregion
- Group _list;
IList data;
int _selectedIndex;
Color selBackground, selForeground;
@@ -160,10 +159,12 @@ namespace Crow
public virtual void AddItem(GraphicObject g){
items.AddChild (g);
+ g.LogicalParent = this;
NotifyValueChanged ("HasChildren", true);
}
public virtual void RemoveItem(GraphicObject g)
{
+ g.LogicalParent = null;
items.RemoveChild (g);
if (items.Children.Count == 0)
NotifyValueChanged ("HasChildren", false);