예제 #1
0
        public override void ShowOptionDialog(Pat.Project proj)
        {
            Environment            = new EditableEnvironment(proj);
            Animations.Environment = Environment;

            var dialog = new PlayerExporterOptionsForm(proj, this);

            dialog.ShowDialog();
        }
예제 #2
0
        protected EditableTreeNode(EditableEnvironment env, MultiEditable <T> dest, string title)
        {
            Env   = env;
            Dest  = null;
            Tag   = CreateSelectObject(dest);
            Title = title;

            SetupCommon();
        }
예제 #3
0
        protected EditableTreeNode(EditableEnvironment env, T data, object tag, Editable <T> dest, string title)
        {
            Env   = env;
            Data  = data;
            Dest  = dest;
            Tag   = tag;
            Title = title;

            SetupCommon();
        }
예제 #4
0
 public GenericEditableTreeNode(EditableEnvironment env, object data, Editable <T> dest, string title)
     : base(env, data as T, data, dest, title)
 {
     if (data is IEditableEnvironment)
     {
         var cv = (IEditableEnvironment)data;
         if (cv.Environment == null)
         {
             cv.Environment = env;
         }
     }
 }
예제 #5
0
        public static void AddEditableList <T>(this TreeNodeCollection coll,
                                               EditableEnvironment env, List <T> list)
            where T : class
        {
            var me = new ListMultiEditable <T>(list);

            foreach (var item in list)
            {
                coll.Add(EditableNodeGenerator.Create <T>(env, item, me));
            }
            coll.Add(EditableNodeGenerator.Create <T>(env, me));
        }
예제 #6
0
        public PlayerExporterOptionsForm(Pat.Project proj, PlayerExporter exporter)
        {
            InitializeComponent();

            treeView1.LinkedPropertyGrid   = propertyGrid1;
            treeView1.LinkedDeleteButton   = button1;
            treeView1.LinkedResetButton    = button2;
            treeView1.LinkedMoveDownButton = button3;
            treeView1.LinkedMoveUpButton   = button4;

            var env = new EditableEnvironment(proj);

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "Export Options",
                Tag  = exporter,
            });

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "System Animations",
                Tag  = exporter.Animations,
            });

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "Player Information",
                Tag  = exporter.PlayerInformation,
            });

            var skills = new TreeNode
            {
                Text = "Skills",
            };

            treeView1.Nodes.Add(skills);
            skills.Nodes.AddEditableList(env, exporter.Skills);
        }
예제 #7
0
 public GenericEditableTreeNode(EditableEnvironment env, MultiEditable <T> dest, string title)
     : base(env, dest, title)
 {
 }
예제 #8
0
        private static void SetupChildren <T>(TreeNode node, EditableEnvironment env, T obj)
        {
            if (obj == null)
            {
                return;
            }

            var fields = obj.GetType().GetFields();

            foreach (var f in fields)
            {
                var attr = f.GetCustomAttributes(typeof(EditorChildNodeAttribute), false)
                           .Select(x => (EditorChildNodeAttribute)x)
                           .FirstOrDefault();
                if (attr == null)
                {
                    continue;
                }

                TreeNodeCollection coll;
                if (attr.Name == null || attr.Merged)
                {
                    coll = node.Nodes;
                }
                else
                {
                    var newNode = new TreeNode {
                        Text = attr.Name
                    };
                    newNode.Expand();
                    node.Nodes.Add(newNode);
                    coll = newNode.Nodes;
                }

                var valueF        = f.GetValue(obj);
                var typeV         = f.FieldType;
                var listInterface = typeV.GetInterfaces()
                                    .Where(i => i.IsGenericType &&
                                           (i.GetGenericTypeDefinition() == typeof(IEditableList <>) ||
                                            i.GetGenericTypeDefinition() == typeof(IList <>)))
                                    .Select(i => new { Arg = i.GetGenericArguments()[0], Temp = i.GetGenericTypeDefinition() })
                                    .FirstOrDefault();

                var typeString = typeof(string);
                var title      = attr.Merged ? attr.Name : null;

                if (listInterface != null)
                {
                    //we've got a list
                    //first create our MultiEditable object
                    var editableT = typeof(Editable <>).MakeGenericType(listInterface.Arg);
                    var treeNodeT = typeof(GenericEditableTreeNode <>).MakeGenericType(listInterface.Arg);

                    object me;
                    if (listInterface.Temp == typeof(IEditableList <>))
                    {
                        var editableListT = typeof(IEditableList <>).MakeGenericType(listInterface.Arg);
                        me = typeof(EditableListMultiEditable <>).MakeGenericType(listInterface.Arg)
                             .GetConstructor(new Type[] { editableListT })
                             .Invoke(new object[] { valueF });
                    }
                    else
                    {
                        var editableListT = typeof(IList <>).MakeGenericType(listInterface.Arg);
                        me = typeof(ListMultiEditable <>).MakeGenericType(listInterface.Arg)
                             .GetConstructor(new Type[] { editableListT })
                             .Invoke(new object[] { valueF });
                    }
                    var creator1 = treeNodeT.GetConstructor(new Type[] {
                        typeof(EditableEnvironment), listInterface.Arg, editableT, typeString
                    });
                    var creator2 = treeNodeT.GetConstructor(new Type[] {
                        typeof(EditableEnvironment),
                        typeof(MultiEditable <>).MakeGenericType(listInterface.Arg), typeString
                    });

                    var list = (System.Collections.IEnumerable)valueF;
                    foreach (var item in list)
                    {
                        var newNode = (TreeNode)creator1.Invoke(new object[] { env, item, me, title });
                        coll.Add(newNode);
                    }
                    coll.Add((TreeNode)creator2.Invoke(new object[] { env, me, title }));
                }
                else
                {
                    var editableT = typeof(Editable <>).MakeGenericType(typeV);
                    var se        = typeof(FieldSingleEditable <>).MakeGenericType(typeV)
                                    .GetConstructor(new Type[] { typeof(object), typeof(FieldInfo) })
                                    .Invoke(new object[] { obj, f });
                    var creator = typeof(GenericEditableTreeNode <>).MakeGenericType(typeV)
                                  .GetConstructor(new Type[] { typeof(EditableEnvironment), typeV, editableT, typeString });
                    var newNode = (IEditableTreeNode)creator.Invoke(new object[] { env, valueF, se, title });
                    coll.Add((TreeNode)newNode);
                    if (valueF == null)
                    {
                        newNode.Reset();
                    }
                }
            }
        }
예제 #9
0
 public static EditableTreeNode <T> Create <T>(EditableEnvironment env, MultiEditable <T> dest, string title = null)
     where T : class
 {
     return(new GenericEditableTreeNode <T>(env, dest, title));
 }
예제 #10
0
 public SelectObject(Action <object> cb, EditableEnvironment env)
 {
     base.Callback    = cb;
     base.Env         = env;
     base.GenericType = typeof(T);
 }