public void RemoveItem(EditorControl ctrl) { ctrl.OnSizeChange.Remove(SubObjectSizeChange); SubCtrls.Remove(ctrl); ctrl.SetParent(null); SubObjectSizeChange(ctrl, LocalRect); }
public void AddItem(EditorControl ctrl, int index) { SubCtrls.Insert(index, ctrl); ctrl.OnSizeChange.Add(SubObjectSizeChange); ctrl.SetParent(this); SubObjectSizeChange(ctrl, LocalRect); }
public static void TreeDeserialize(IEditorControl parent, XmlNode parentNode, IEditorControl root) { foreach (XmlNode node in parentNode) { try { EditorControl subCtrl = Activator.CreateInstance(typeof(IEditorControl).Assembly.GetType(node.Name)) as EditorControl; subCtrl.SetParent(parent); InitControl(subCtrl); AttributeDeserialize(node, subCtrl, root); Type type = root.GetType(); if (!string.IsNullOrEmpty(subCtrl.Name)) { MemberInfo[] infos = type.GetMember(subCtrl.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (infos.Length > 0) { MemberInfo info = infos[0]; switch (info.MemberType) { case MemberTypes.Field: (info as FieldInfo).SetValue(root, subCtrl); break; case MemberTypes.Property: (info as PropertyInfo).SetValue(root, subCtrl); break; } } TreeDeserialize(subCtrl, node, root); } } catch (Exception err) { throw new Exception($"{node.Name}", err); } } }