public string DynMethodId {
get { return dynMethodId; }
}
-
+ public bool Resolved = false;
public MemberReference Source;
public MemberReference Target;
if (tmp == null)
return false;
if (bindingExp [ptr] == "..")
- tmp = tmp.Parent as ILayoutable;
+ tmp = tmp.LogicalParent;
else if (bindingExp [ptr] == ".") {
if (ptr > 0)
throw new Exception ("Syntax error in binding, './' may only appear in first position");
{
Target = null;
dynMethodId = "";
+ Resolved = false;
+ }
+ public override string ToString ()
+ {
+ return string.Format ("[Binding: {0}.{1} <= {2}]", Source.Instance, Source.Member.Name, Expression);
}
}
#region private fields
LayoutingType registeredLayoutings = LayoutingType.None;
+ ILayoutable logicalParent;
ILayoutable _parent;
string _name = "unamed";
Fill _background = Color.Transparent;
#region public fields
/// <summary>
- /// The logical parent (used mainly for bindings) as opposed to the parent in the graphic tree
- /// </summary>
- public GraphicObject LogicalParent;
- /// <summary>
/// Original size and position 0=Stretched; -1=Fit
/// </summary>
public Rectangle Bounds;
}
}
+ public ILayoutable LogicalParent {
+ get { return logicalParent == null ? Parent : logicalParent; }
+ set { logicalParent = value; }
+ }
[XmlIgnore]public virtual Rectangle ClientRectangle {
get {
}
get {
return dataSource == null ?
- LogicalParent == null ?
- Parent is GraphicObject ? (Parent as GraphicObject).DataSource : null : LogicalParent.DataSource : dataSource;
+ (LogicalParent as GraphicObject).DataSource : dataSource;
}
}
#endregion
#if DEBUG_BINDING
Debug.WriteLine ("ResolveBinding => " + this.ToString ());
#endif
-
+ if (Bindings.Count == 0)
+ return;
Dictionary<object,List<Binding>> resolved = new Dictionary<object, List<Binding>>();
foreach (Binding b in Bindings) {
- if (!string.IsNullOrEmpty (b.DynMethodId))
+ if (b.Resolved)
continue;
if (b.Source.Member.MemberType == MemberTypes.Event) {
if (b.Expression.StartsWith("{")){
MethodInfo addHandler = b.Source.Event.GetAddMethod ();
Delegate del = Delegate.CreateDelegate (b.Source.Event.EventHandlerType, b.Target.Instance, b.Target.Method);
addHandler.Invoke (this, new object[] { del });
+ b.Resolved = true;
continue;
}
List<Binding> bindings = null;
resolved [b.Target.Instance] = bindings;
}
bindings.Add (b);
+ b.Resolved = true;
}
MethodInfo stringEquals = typeof(string).GetMethod
throw new Exception ("unhandle target member type in binding");
}
- if (!targetValueType.IsValueType)
+ if (b.Source.Property.PropertyType == typeof(string)) {
+ MemberReference tostring = new MemberReference (b.Source.Instance);
+ if (!tostring.FindMember ("ToString"))
+ throw new Exception ("ToString method not found");
+ il.Emit (OpCodes.Callvirt, tostring.Method);
+ }else if (!targetValueType.IsValueType)
il.Emit(OpCodes.Castclass, targetValueType);
else if (b.Source.Property.PropertyType != targetValueType)
il.Emit(OpCodes.Callvirt, CompilerServices.GetConvertMethod( b.Source.Property.PropertyType ));
Delegate del = dm.CreateDelegate(binding.Source.Event.EventHandlerType,this);
MethodInfo addHandler = binding.Source.Event.GetAddMethod ();
addHandler.Invoke(this, new object[] {del});
+
+ binding.Resolved = true;
}
/// <summary>
/// Remove dynamic delegates by ids from dataSource
{
return r;
}
- public Rectangle ScreenCoordinates (Rectangle r)
- {
- return r;
- }
+ public Rectangle ScreenCoordinates (Rectangle r) => r;
public ILayoutable Parent {
- get {
- return null;
- }
- set {
- throw new NotImplementedException ();
- }
+ get { return null; }
+ set { throw new NotImplementedException (); }
+ }
+
+ public ILayoutable LogicalParent {
+ get { return null; }
+ set { throw new NotImplementedException (); }
}
+
Rectangle ILayoutable.ClientRectangle {
get { return new Size(this.ClientRectangle.Size.Width,this.ClientRectangle.Size.Height); }
}