diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-14 12:30:20 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-14 12:30:20 +0200 |
| commit | 42d9e260840d46ab9d960ae45d71dc47a03fb6cf (patch) | |
| tree | faa408edb9857300146ac3666aefd8f0ae60d2f7 /src/GraphicObjects | |
| parent | 4161571104964c0d309b338595e497b78eb54cda (diff) | |
Clear Bindings when GraphicObject is destroyed
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 42 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 6 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 7 |
3 files changed, 53 insertions, 2 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index f8ffb511..c9f7a39f 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -21,6 +21,8 @@ namespace go {
public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange
{
+ internal List<int> DynamicMethodIds = new List<int> ();
+
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
public virtual void NotifyValueChanged(string MemberName, object _value)
@@ -304,7 +306,17 @@ namespace go get { return _minimumSize; }
set { _minimumSize = value; }
}
- [XmlIgnore]public object DataSource;
+ object dataSource;
+
+ [XmlIgnore]public object DataSource {
+ set {
+ dataSource = value;
+ }
+ get {
+ return dataSource == null ?
+ Parent is GraphicObject ? (Parent as GraphicObject).DataSource : null : dataSource;
+ }
+ }
#endregion
/// <summary>
@@ -632,7 +644,7 @@ namespace go using (ImageSurface draw =
new ImageSurface(bmp, Format.Argb32, Slot.Width, Slot.Height, stride)) {
using (Context gr = new Context (draw)) {
- gr.Antialias = Antialias.Subpixel;
+ gr.Antialias = Antialias.Gray;
onDraw (gr);
}
draw.Flush ();
@@ -917,5 +929,31 @@ namespace go }
#endregion
+ /// <summary>
+ /// Remove dynamic delegates by ids from dataSource
+ /// and delete ref of this in Shared interface refs
+ /// </summary>
+ public virtual void ClearBinding(){
+ if (this.DataSource == null)
+ return;
+ object ds = this.DataSource;
+ Type dataSourceType = ds.GetType ();
+ EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");
+ FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");
+ MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;
+ if (multicastDelegate != null){
+ foreach (Delegate d in multicastDelegate.GetInvocationList())
+ {
+ string dn = d.Method.Name;
+ if (!dn.StartsWith ("dynHandle_"))
+ continue;
+ int did = int.Parse (dn.Substring (10));
+ if (this.DynamicMethodIds.Contains(did))
+ evtInfo.RemoveEventHandler (ds, d);
+ }
+ }
+
+ Interface.References.Remove (this);
+ }
}
}
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index d9e35aa8..87a9ee5c 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -278,5 +278,11 @@ namespace go }
#endregion
+
+ public override void ClearBinding(){
+ foreach (GraphicObject c in children)
+ c.ClearBinding ();
+ base.ClearBinding ();
+ }
}
}
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index b6391621..010fca71 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -146,6 +146,13 @@ namespace go child.checkHoverWidget (e); } #endregion + + public override void ClearBinding () + { + if (child != null) + child.ClearBinding (); + base.ClearBinding (); + } } } |