private void CreateParticleMethodCategory(string methodname, float x, float y)
        {
            Macross.NodesControlAssist NodesControlAssist = mLinkedNodesContainer.HostControl as Macross.NodesControlAssist;

            //加入列表信息
            Macross.Category category;
            var csparam = CSParam as ParticleShapeConeControlConstructionParams;

            if (!csparam.CategoryDic.TryGetValue(Macross.MacrossPanelBase.GraphCategoryName, out category))
            {
                return;
            }

            var HostControl = this.HostNodesContainer.HostControl;

            var item = new Macross.CategoryItem(null, category);

            item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.OverrideFunction;
            var data = new Macross.CategoryItem.InitializeData();

            data.Reset();

            var MacrossOpPanel = NodesControlAssist.HostControl.MacrossOpPanel;

            item.Initialize(MacrossOpPanel.HostControl, data);
            //HostControl.CreateNodesContainer(item);

            //MainGridItem.Children.Add(item);
            item.Name = methodname;
            category.Items.Add(item);

            //加入结点信息
            Type type = typeof(EngineNS.Bricks.Particle.ParticleEmitShapeNode);

            System.Reflection.MethodInfo      methodInfo = type.GetMethod(methodname);
            System.Reflection.ParameterInfo[] paramstype = methodInfo.GetParameters();

            //拷貝方法的attribute.
            var    attrts      = methodInfo.GetCustomAttributes(true);
            string displayname = "";

            for (int i = 0; i < attrts.Length; i++)
            {
                var displayattr = attrts[i] as System.ComponentModel.DisplayNameAttribute;
                if (displayattr != null)
                {
                    displayname = displayattr.DisplayName;
                    break;
                }
            }

            //var CustomFunctionData = new Macross.ResourceInfos.MacrossResourceInfo.CustomFunctionData();
            var methodinfo = CodeDomNode.Program.GetMethodInfoAssistFromMethodInfo(methodInfo, type, CodeDomNode.MethodInfoAssist.enHostType.Base, "");
            var nodeType   = typeof(CodeDomNode.MethodOverride);
            var csParam    = new CodeDomNode.MethodOverride.MethodOverrideConstructParam()
            {
                CSType             = mLinkedNodesContainer.CSType,
                HostNodesContainer = mLinkedNodesContainer,
                ConstructParam     = "",
                MethodInfo         = methodinfo,
                DisplayName        = displayname,
            };

            //var center = nodesContainer.NodesControl.GetViewCenter();
            var node = mLinkedNodesContainer.AddOrigionNode(nodeType, csParam, x, y);

            node.IsDeleteable = true;

            //重写双击事件 不需要进入二级编辑
            //item.OnDoubleClick -= item.OnDoubleClick;
            Type      ItemType = item.GetType();
            FieldInfo _Field   = item.GetType().GetField("OnDoubleClick", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static);

            if (_Field != null)
            {
                object _FieldValue = _Field.GetValue(item);
                if (_FieldValue != null && _FieldValue is Delegate)
                {
                    Delegate   _ObjectDelegate = (Delegate)_FieldValue;
                    Delegate[] invokeList      = _ObjectDelegate.GetInvocationList();

                    foreach (Delegate del in invokeList)
                    {
                        ItemType.GetEvent("OnDoubleClick").RemoveEventHandler(item, del);
                    }
                }
            }
            item.OnDoubleClick += (categoryItem) =>
            {
                mLinkedNodesContainer.FocusNode(node);
            };

            //NodesControlAssist.Save();
        }
示例#2
0
        public override async Task <bool> LoadData(string absFile)
        {
            var xndHolder = await EngineNS.IO.XndHolder.LoadXND(absFile, EngineNS.Thread.Async.EAsyncTarget.AsyncEditor);

            if (xndHolder != null)
            {
                mNodesContainerDic.Clear();
                Macross.CategoryItem mainGraphItem = null;
                foreach (var category in MacrossOpPanel.CategoryDic)
                {
                    category.Value.Items.Clear();
                    var graphCategoryNode = xndHolder.Node.FindNode("Category_" + category.Key);
                    if (graphCategoryNode == null)
                    {
                        continue;
                    }

                    var itemNodes = graphCategoryNode.GetNodes();
                    foreach (var itemNode in itemNodes)
                    {
                        var item = new Macross.CategoryItem(null, category.Value);
                        item.Load(itemNode, this);
                        switch (item.InitTypeStr)
                        {
                        case "UI_UIElement_Variable":
                        {
                            var initData = item.InitData as UIElementVariableCategoryItemInitData;
                            initData.UIElement = ((UIMacrossEditorControl)HostControl).HostControl.mCurrentUIHost.FindChildElement(initData.UIElementId);
                        }
                        break;

                        case "UI_UIElement_Event":
                        {
                            var initData = item.InitData as UIElementEventCategoryItemInitData;
                            initData.UIElement = ((UIMacrossEditorControl)HostControl).HostControl.mCurrentUIHost.FindChildElement(initData.UIElementId);
                        }
                        break;

                        case "UI_UIElement_PropertyCustomBind":
                        {
                            var initData = item.InitData as UIElementPropertyCustomBindCategoryitemInitData;
                            initData.UIElement = ((UIMacrossEditorControl)HostControl).HostControl.mCurrentUIHost.FindChildElement(initData.UIElementId);
                        }
                        break;

                        case "UI_UIElement_VariableBind":
                        {
                            var initdata = item.InitData as UIElementVariableBindCategoryItemInitData;
                            initdata.UIElement       = ((UIMacrossEditorControl)HostControl).HostControl.mCurrentUIHost.FindChildElement(initdata.UIElementId);
                            initdata.TargetUIElement = ((UIMacrossEditorControl)HostControl).HostControl.mCurrentUIHost.FindChildElement(initdata.TargetUIElementId);
                        }
                        break;

                        case "UI_UIElement_CustomEvent":
                        {
                        }
                        break;
                        }
                        item.Initialize(this, item.InitData);
                        category.Value.Items.Add(item);

                        switch (item.CategoryItemType)
                        {
                        case Macross.CategoryItem.enCategoryItemType.MainGraph:
                        {
                            mainGraphItem = item;
                        }
                        break;
                        }
                    }
                }

                MacrossOpPanel.SetMainGridItem(mainGraphItem);
                return(true);
            }
            return(false);
        }