diff options
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/Combobox.cs | 28 | ||||
| -rw-r--r-- | src/GraphicObjects/Expandable.cs | 7 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 34 | ||||
| -rw-r--r-- | src/GraphicObjects/ListBox.cs | 10 | ||||
| -rw-r--r-- | src/GraphicObjects/Popper.cs | 9 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedContainer.cs | 11 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 3 |
7 files changed, 74 insertions, 28 deletions
diff --git a/src/GraphicObjects/Combobox.cs b/src/GraphicObjects/Combobox.cs index 02040570..3e841793 100644 --- a/src/GraphicObjects/Combobox.cs +++ b/src/GraphicObjects/Combobox.cs @@ -22,7 +22,7 @@ namespace go {
[DefaultTemplate("#go.Templates.Combobox.goml")]
[DefaultOverlayTemplate("#go.Templates.ComboboxOverlay.goml")]
- public class Combobox : TemplatedContainer
+ public class Combobox : TemplatedControl
{
#region CTOR
public Combobox() : base(){ }
@@ -48,21 +48,22 @@ namespace go base.loadTemplate (template);
loadOverlayTemplate (null);
}
- public override GraphicObject Content {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
+// public override GraphicObject Content {
+// get {
+// throw new NotImplementedException ();
+// }
+// set {
+// throw new NotImplementedException ();
+// }
+// }
#endregion
protected virtual void loadOverlayTemplate(GraphicObject overlayTemplate)
{
if (overlayTemplate == null) {
DefaultOverlayTemplate dt = (DefaultOverlayTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultOverlayTemplate), true).FirstOrDefault ();
- Overlay = Interface.Load (dt.Path, this, !Interface.DontResoveGOML);
+ Overlay = Interface.Load (dt.Path);
+ Overlay.ResolveBindings ();
} else
Overlay = overlayTemplate;
_list = Overlay.FindByName ("List") as Group;
@@ -173,8 +174,9 @@ namespace go lock (pendingChildrenAddition) {
if (!threadedLoadingFinished && pendingChildrenAddition.Count < 50)
return;
- while (pendingChildrenAddition.Count > 0)
+ while (pendingChildrenAddition.Count > 0) {
_list.addChild (pendingChildrenAddition.Dequeue ());
+ }
}
}
@@ -198,7 +200,8 @@ namespace go foreach (var item in data) {
ms.Seek(0,SeekOrigin.Begin);
- GraphicObject g = Interface.Load (ms, t, item);
+ GraphicObject g = Interface.Load (ms, t);
+ g.DataSource = item;
g.MouseClick += itemClick;
lock (pendingChildrenAddition) {
@@ -348,5 +351,6 @@ namespace go base.ClearBinding ();
}
+
}
}
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 0bc5d067..3d4ef229 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -116,6 +116,11 @@ namespace go IsExpanded = !IsExpanded;
base.onMouseClick (sender, e);
}
-
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Content != null)
+ Content.ResolveBindings ();
+ }
}
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 5d7e0dae..1496e0e5 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -76,6 +76,7 @@ namespace go #endregion
#region public fields
+ public GraphicObject LogicalParent;
public Rectangle Bounds;
public Rectangle Slot = new Rectangle ();
public object Tag;
@@ -85,8 +86,20 @@ namespace go #region ILayoutable
[XmlIgnore]public ILayoutable Parent {
get { return _parent; }
- set { _parent = value; }
+ set {
+// if (_parent == value)
+// return;
+// if (_parent != null)
+// ClearBinding ();
+//
+ _parent = value;
+//
+// if (DataSource != null)
+// ResolveBindings ();
+ }
}
+
+
[XmlIgnore]public virtual Rectangle ClientRectangle {
get {
Rectangle cb = Slot.Size;
@@ -336,7 +349,7 @@ namespace go }
object dataSource;
- [XmlIgnore]public object DataSource {
+ [XmlIgnore]public virtual object DataSource {
set {
if (dataSource == value)
return;
@@ -351,7 +364,8 @@ namespace go }
get {
return dataSource == null ?
- Parent is GraphicObject ? (Parent as GraphicObject).DataSource : null : dataSource;
+ LogicalParent == null ?
+ Parent is GraphicObject ? (Parent as GraphicObject).DataSource : null : LogicalParent.DataSource : dataSource;
}
}
#endregion
@@ -799,6 +813,8 @@ namespace go {
List<Binding> resolved = new List<Binding> ();
foreach (Binding b in Bindings) {
+ if (!string.IsNullOrEmpty (b.DynMethodId))
+ continue;
if (b.Source.Member.MemberType == MemberTypes.Event) {
if (b.Expression.StartsWith("{")){
CompileEventSource(b);
@@ -854,9 +870,13 @@ namespace go Type[] args = {typeof(object), typeof(object),handlerArgsType};
dm = new DynamicMethod(grouped[0].NewDynMethodId,
- typeof(void),
+ MethodAttributes.Family | MethodAttributes.FamANDAssem | MethodAttributes.NewSlot,
+ CallingConventions.Standard,
+ typeof(void),
args,
- sourceType);
+ sourceType,true);
+
+
il = dm.GetILGenerator(256);
@@ -905,7 +925,7 @@ namespace go }else
throw new Exception ("unandled source member type for binding");
}else if (string.IsNullOrEmpty(b.Expression))
- targetValue= grouped [0].Target;//empty binding exp=> bound to target object by default
+ targetValue= grouped [0].Target.Instance;//empty binding exp=> bound to target object by default
//TODO: handle other dest type conversions
if (b.Source.Property.PropertyType == typeof(string)){
if (targetValue == null){
@@ -925,7 +945,7 @@ namespace go if (b.Target.Member != null)
il.Emit (OpCodes.Ldstr, b.Target.Member.Name);
else
- il.Emit (OpCodes.Ldstr, b.Expression);
+ il.Emit (OpCodes.Ldstr, b.Expression.Split('/').LastOrDefault());
il.Emit (OpCodes.Callvirt, stringEquals);
il.Emit (OpCodes.Brtrue, jumpTable[i]);
i++;
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 9f408b5a..15752f80 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -91,10 +91,15 @@ namespace go Thread t = new Thread (loadingThread); t.Start (); + t.Join (); } } - + public override void UpdateLayout (LayoutingType layoutType) + { + CheckPendingChildrenAddition (); + base.UpdateLayout (layoutType); + } internal void CheckPendingChildrenAddition() { if (pendingChildrenAddition == null) @@ -127,7 +132,8 @@ namespace go foreach (var item in data) { ms.Seek(0,SeekOrigin.Begin); - GraphicObject g = Interface.Load (ms, t, item); + GraphicObject g = Interface.Load (ms, t); + g.DataSource = item; g.MouseClick += itemClick; lock (pendingChildrenAddition) { diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index e1a02fc6..2ec4396f 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -38,6 +38,7 @@ namespace go get { return _content; }
set {
if (_content != null) {
+ _content.LogicalParent = null;
_content.LayoutChanged -= _content_LayoutChanged;
_content.MouseLeave -= _content_MouseLeave;
}
@@ -47,6 +48,7 @@ namespace go if (_content == null)
return;
+ _content.LogicalParent = this;
_content.Focusable = true;
_content.LayoutChanged += _content_LayoutChanged;
_content.MouseLeave += _content_MouseLeave;
@@ -93,7 +95,12 @@ namespace go }
}
base.ClearBinding ();
-
+ }
+ public override void ResolveBindings ()
+ {
+ base.ResolveBindings ();
+ if (Content != null)
+ Content.ResolveBindings ();
}
[XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index dcea97d7..cef8266b 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -35,14 +35,17 @@ namespace go #region GraphicObject overrides public override void ClearBinding () { - if (Content != null) { - //fix datasource = null to clear bindings, but it's illogic - Content.DataSource = this.DataSource; + 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) diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index e203c0cf..d6c7243d 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -115,7 +115,8 @@ namespace go { if (template == null) { DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault(); - this.SetChild (Interface.Load (dt.Path, this,!Interface.DontResoveGOML)); + this.SetChild (Interface.Load (dt.Path, this)); + this.child.ResolveBindings (); }else this.SetChild (template); } |