<?xml version="1.0"?>\r
<Popper Title="TestPopper" Width="100" Background="DimGray">\r
<Border Fit="True" Background="ArmyGreen">\r
- <Image Fit="true" Path="#go.Images.Icons.tetra.png" Margin="10"/>\r
+<!-- <Image Fit="true" Path="#go.Images.Icons.tetra.png" Margin="10"/>-->\r
+ <VerticalStack Fit="true" Background="Blue">\r
+ <Checkbox Name="chk1"/>\r
+ <Checkbox Name="chk2" IsChecked="true"/>\r
+ <Checkbox Name="chk3"/>\r
+ <Checkbox Name="chk4"/>\r
+ </VerticalStack> \r
</Border>\r
</Popper>\r
dynHandleCpt++;
//register target object reference
- int dstIdx = Interface.References.IndexOf(binding.Source);
-
- if (dstIdx < 0) {
- dstIdx = Interface.References.Count;
- Interface.References.Add (binding.Source);
- }
-
-
+ int dstIdx = Interface.Reference(binding.Source);
#region IL generation
ILGenerator il = dm.GetILGenerator(256);
\r
public override string ToString ()\r
{\r
- return Name == "unamed" ? this.GetType ().ToString() : Name;\r
+ string tmp ="";\r
+ if (Parent != null)\r
+ tmp = Parent.ToString () + tmp;\r
+ return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;\r
}\r
\r
#region IXmlSerializable\r
continue;\r
}\r
if (mi.MemberType == MemberTypes.Event) {\r
- Interface.GOMLResolver.Add (new DynAttribute { \r
- Source = this, \r
- Value = attValue,\r
- MemberName = attName\r
- });\r
+ if (!Interface.DontResoveGOML) {\r
+ Interface.GOMLResolver.Add (new DynAttribute { \r
+ Source = this, \r
+ Value = attValue,\r
+ MemberName = attName\r
+ });\r
+ }\r
} else if (mi.MemberType == MemberTypes.Property) {\r
PropertyInfo pi = mi as PropertyInfo;\r
\r
} else {\r
\r
if (attValue.StartsWith("{")) {\r
+ if (Interface.DontResoveGOML)\r
+ continue;\r
//binding\r
if (!attValue.EndsWith("}"))\r
throw new Exception (string.Format("GOML:Malformed binding: {0}", attValue));\r
/// </summary>\r
public virtual void ClearBinding(){\r
object ds = this.DataSource;\r
- if (ds == null)\r
- return;\r
- \r
- Type dataSourceType = ds.GetType ();\r
- EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");\r
- if (evtInfo != null) {\r
- FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
- MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
- if (multicastDelegate != null) { \r
- foreach (Delegate d in multicastDelegate.GetInvocationList()) {\r
- string dn = d.Method.Name;\r
- if (!dn.StartsWith ("dynHandle_"))\r
- continue;\r
- int did = int.Parse (dn.Substring (10));\r
- if (this.DynamicMethodIds.Contains (did))\r
- evtInfo.RemoveEventHandler (ds, d);\r
+ if (ds != null) {\r
+ Type dataSourceType = ds.GetType ();\r
+ EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");\r
+ if (evtInfo != null) {\r
+ FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
+ MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
+ if (multicastDelegate != null) { \r
+ foreach (Delegate d in multicastDelegate.GetInvocationList()) {\r
+ string dn = d.Method.Name;\r
+ if (!dn.StartsWith ("dynHandle_"))\r
+ continue;\r
+ int did = int.Parse (dn.Substring (10));\r
+ if (this.DynamicMethodIds.Contains (did))\r
+ evtInfo.RemoveEventHandler (ds, d);\r
+ }\r
}\r
}\r
}\r
- \r
- Interface.References.Remove (this);\r
+ Interface.Unreference (this);\r
+\r
}\r
}\r
}\r
{
if (template == null) {
DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault();
- this.SetChild (Interface.Load (dt.Path, this));
+ this.SetChild (Interface.Load (dt.Path, this,!Interface.DontResoveGOML));
}else
this.SetChild (template);
}
xr.Read ();//go close tag
xr.Read ();//Template close tag
+ break;
} else {
xr.ReadInnerXml ();
}
}
}
} else
- loadTemplate (Interface.Load (template, this));
+ loadTemplate (Interface.Load (template, this, !Interface.DontResoveGOML));
//normal xml read
public static bool ReplaceTabsWithSpace = false;
/// <summary> Allow rendering of interface in development environment </summary>
public static bool DesignerMode = false;
+ public static bool DontResoveGOML = false;
/// <summary> Threshold to catch borders for sizing </summary>
public static int BorderThreshold = 5;
/// Graphic objects References use in dynamic delegates for binding
/// </summary>
public static List<object> References = new List<object>();
+ public static Queue<int> FreeRefIndices = new Queue<int>();
+ public static void Unreference(Object o)
+ {
+ int idxt = Interface.References.IndexOf (o);
+ if (idxt < 0)
+ return;
+ References[idxt] = null;
+ FreeRefIndices.Enqueue (idxt);
+ }
+ /// <summary> register target object reference in an array for binding CIL </summary>
+ public static int Reference(object o)
+ {
+
+ int dstIdx = Interface.References.IndexOf(o);
+ if (dstIdx < 0) {
+ if (FreeRefIndices.Count == 0) {
+ dstIdx = Interface.References.Count;
+ Interface.References.Add (o);
+ } else {
+ dstIdx = FreeRefIndices.Dequeue ();
+ Interface.References [dstIdx] = o;
+ }
+ }
+ return dstIdx;
+ }
public static LayoutingQueue LayoutingQueue = new LayoutingQueue();
#region Load/Save
return t;
}
public static string CurrentGOMLPath;
- public static GraphicObject Load(string path, object hostClass = null)
+ public static GraphicObject Load(string path, object hostClass = null, bool resolveGOML = true)
{
CurrentGOMLPath = path;
using (Stream stream = GetStreamFromPath (path)) {
- return Load(stream, GetTopContainerOfGOMLStream(stream), hostClass);
+ return Load(stream, GetTopContainerOfGOMLStream(stream), hostClass, resolveGOML);
}
CurrentGOMLPath = "";
}
public static GraphicObject Load(Stream stream, Type type, object hostClass = null, bool resolve = true)
{
GraphicObject result;
- GOMLResolutionStack.Push(new List<DynAttribute>());
+
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
xn.Add("", "");
- XmlSerializer xs = new XmlSerializer(type);
+ //prevent unused ref in References created by xmlSerializer
+ Interface.DontResoveGOML = true;
+ XmlSerializer xs = new XmlSerializer(type);
+ Interface.DontResoveGOML = false;
+ GOMLResolutionStack.Push(new List<DynAttribute>());
result = (GraphicObject)xs.Deserialize(stream);
result.DataSource = hostClass;