コード例 #1
0
 public void RemoveItem(EditorControl ctrl)
 {
     ctrl.OnSizeChange.Remove(SubObjectSizeChange);
     SubCtrls.Remove(ctrl);
     ctrl.SetParent(null);
     SubObjectSizeChange(ctrl, LocalRect);
 }
コード例 #2
0
 public void AddItem(EditorControl ctrl, int index)
 {
     SubCtrls.Insert(index, ctrl);
     ctrl.OnSizeChange.Add(SubObjectSizeChange);
     ctrl.SetParent(this);
     SubObjectSizeChange(ctrl, LocalRect);
 }
コード例 #3
0
        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);
                }
            }
        }