private void Button_Add_Click(object sender, RoutedEventArgs e)
        {
            var methodInfo = BindInstance as CodeDomNode.CustomMethodInfo;

            if (BindProperty.Name == "OutParams" && methodInfo.IsAsync && methodInfo.OutParams.Count > 0)
            {
                EditorCommon.MessageBox.Show("异步函数只能包含最多一个输出参数,不能添加多个输出参数!");
                return;
            }

            var  paramName  = BindProperty.Name + "_";
            bool repetition = false;
            int  i          = 0;

            do
            {
                repetition = false;
                foreach (var param in Params)
                {
                    if (param.ParamName == paramName + i)
                    {
                        repetition = true;
                        i++;
                        break;
                    }
                }
            } while (repetition);

            var funcParam = new CodeDomNode.CustomMethodInfo.FunctionParam()
            {
                ParamType      = new CodeDomNode.VariableType(methodInfo.CSType),
                HostMethodInfo = methodInfo,
            };

            if (BindProperty.Name == "InParams")
            {
                funcParam.ParamName = paramName + i;
                Params.Add(funcParam);
                methodInfo._OnAddedInParam(funcParam);
            }
            else if (BindProperty.Name == "OutParams")
            {
                funcParam.ParamName = paramName + i;
                Params.Add(funcParam);
                methodInfo._OnAddedOutParam(funcParam);
            }
            var be = GetBindingExpression(ParamsProperty);

            be.UpdateSource();
        }
Esempio n. 2
0
        //void ReturnCustom_RemoveParam(int index, CustomMethodInfo.FunctionParam funcParam)
        public async Task OnRemovedOutParam(int index, CodeDomNode.CustomMethodInfo.FunctionParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var node = mChildNodes[index] as MethodInvokeParameterControl;

            if (node != null)
            {
                if (node.ParamPin.HasLink)
                {
                    var pinInfo = node.ParamPin;
                    pinInfo.Clear();
                }

                param.OnParamTypeChanged -= node.UpdateParamType;
                RemoveChildNodeByIndex(index);
            }
        }
        private void Button_Remove_Click(object sender, RoutedEventArgs e)
        {
            if (ListBox_Params.SelectedItems.Count == 0)
            {
                return;
            }
            var items      = new CodeDomNode.CustomMethodInfo.FunctionParam[ListBox_Params.SelectedItems.Count];
            var methodInfo = BindInstance as CodeDomNode.CustomMethodInfo;

            ListBox_Params.SelectedItems.CopyTo(items, 0);
            List <int> indexList = new List <int>(items.Length);

            foreach (var item in items)
            {
                var param = item as CodeDomNode.CustomMethodInfo.FunctionParam;
                if (param == null)
                {
                    continue;
                }
                var index = Params.IndexOf(param);
                indexList.Add(index);
                Params.Remove(param);
            }
            for (int i = 0; i < indexList.Count; i++)
            {
                var item  = items[i];
                var param = item as CodeDomNode.CustomMethodInfo.FunctionParam;
                if (param == null)
                {
                    continue;
                }
                if (BindProperty.Name == "InParams")
                {
                    methodInfo._OnRemovedInParam(indexList[i], param);
                }
                else if (BindProperty.Name == "OutParams")
                {
                    methodInfo._OnRemovedOutParam(indexList[i], param);
                }
            }
            var be = GetBindingExpression(ParamsProperty);

            be.UpdateSource();
        }
Esempio n. 4
0
        //void ReturnCustom_AddParam(CustomMethodInfo.FunctionParam funcParam)
        public async Task OnAddedOutParam(CodeDomNode.CustomMethodInfo.FunctionParam funcParam)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var csParam = CSParam as ReturnCustomConstructParam;
            MethodParamInfoAssist retValue;

            if (funcParam.ParamType.Type.IsByRef)
            {
                var typefullname = funcParam.ParamType.Type.FullName.Substring(0, funcParam.ParamType.Type.FullName.Length - 1);
                var type         = funcParam.ParamType.Type.Assembly.GetType(typefullname);
                //funcParam.ParamType = new VariableType(type, funcParam.ParamType.CSType);
                retValue = new MethodParamInfoAssist();
                retValue.FieldDirection = System.CodeDom.FieldDirection.Out;
                retValue.IsParamsArray  = false;
                retValue.ParameterType  = type;
                retValue.ParamName      = funcParam.ParamName;
                BindingOperations.SetBinding(this, CodeDomNode.CustomMethodInfo.FunctionParam.ParamNameProperty, new Binding("ParamName")
                {
                    Source = retValue, Mode = BindingMode.TwoWay
                });
            }
            else
            {
                retValue = funcParam.CreateParamInfoAssist(System.CodeDom.FieldDirection.Out);
            }

            var pm = new MethodInvokeParameterControl.MethodInvokeParameterConstructionParams()
            {
                CSType             = CSParam.CSType,
                HostNodesContainer = CSParam.HostNodesContainer,
                ConstructParam     = "",
                ConstructType      = MethodInvokeNode.enParamConstructType.ReturnCustom,
                ParamInfo          = retValue,
            };
            var pc = new MethodInvokeParameterControl(pm);

            funcParam.OnParamTypeChanged -= pc.UpdateParamType;
            funcParam.OnParamTypeChanged += pc.UpdateParamType;
            pc.OnUpdateParamTypeAction    = OnUpdateChildParamType;
            AddChildNode(pc, mParamsPanel);
        }
Esempio n. 5
0
        public async Task OnInsertOutParam(int index, CodeDomNode.CustomMethodInfo.FunctionParam funcParam)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var csParam = CSParam as ReturnCustomConstructParam;
            var pm      = new MethodInvokeParameterControl.MethodInvokeParameterConstructionParams()
            {
                CSType             = CSParam.CSType,
                HostNodesContainer = CSParam.HostNodesContainer,
                ConstructParam     = "",
                ConstructType      = MethodInvokeNode.enParamConstructType.ReturnCustom,
                ParamInfo          = funcParam.CreateParamInfoAssist(System.CodeDom.FieldDirection.Out),
            };
            var pc = new MethodInvokeParameterControl(pm);

            funcParam.OnParamTypeChanged -= pc.UpdateParamType;
            funcParam.OnParamTypeChanged += pc.UpdateParamType;
            pc.OnUpdateParamTypeAction    = OnUpdateChildParamType;
            InsertChildNode(index, pc, mParamsPanel);
        }
        public UIMacrossEditorControl()
        {
            InitializeComponent();
            Macross_Client.HostControl = this;

            Macross.CategoryItem.RegistInitAction("UI_UIElement_Variable", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new UIElementVariableCategoryItemPropertys();
                }

                var varItemPro = item.PropertyShowItem as UIElementVariableCategoryItemPropertys;
                BindingOperations.SetBinding(varItemPro, UIElementVariableCategoryItemPropertys.VariableNameProperty, new Binding("Name")
                {
                    Source = item
                });
                BindingOperations.SetBinding(varItemPro, UIElementVariableCategoryItemPropertys.TooltipProperty, new Binding("ToolTips")
                {
                    Source = item, Mode = BindingMode.TwoWay
                });

                var initData = data as UIEditor.UIMacross.UIElementVariableCategoryItemInitData;

                BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("Name")
                {
                    Source = initData.UIElement.Initializer
                });

                varItemPro.VariableType = initData.ElementType;
                varItemPro.ElementId    = initData.UIElementId;
                var atts = initData.ElementType.GetCustomAttributes(typeof(EngineNS.UISystem.Editor_UIControlAttribute), false);
                if (atts.Length > 0)
                {
                    var att   = atts[0] as EngineNS.UISystem.Editor_UIControlAttribute;
                    item.Icon = new BitmapImage(new Uri($"/UIEditor;component/Icons/{att.Icon}", UriKind.Relative));
                }

                var menuItem = new MenuItem()
                {
                    Name   = "VariableFocus",
                    Header = "查找引用",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                };
                item.CategoryItemContextMenu.Items.Add(menuItem);

                item.OnDropToNodesControlAction = (dropData) =>
                {
                    var nodesControlAssist           = dropData.NodesContainerHost as Macross.NodesControlAssist;
                    nodesControlAssist.ShowGetButton = true;
                    nodesControlAssist.ShowSetButton = false;
                    nodesControlAssist.InitVariableDropShow(dropData.DropPos);
                };
                item.OnDropVariableGetNodeControlAction = (actionData) =>
                {
                    var nodeType               = typeof(CodeDomNode.PropertyNode);
                    var csParam                = new CodeDomNode.PropertyNode.PropertyNodeConstructionParams();
                    csParam.CSType             = ctrl.CSType;
                    csParam.HostNodesContainer = actionData.NodesContainer;
                    csParam.ConstructParam     = "";
                    csParam.PropertyInfo       = new CodeDomNode.PropertyInfoAssist()
                    {
                        PropertyName     = item.Name,
                        PropertyType     = varItemPro.VariableType,
                        HostType         = CodeDomNode.MethodInfoAssist.enHostType.This,
                        MacrossClassType = HostControl.CurrentResInfo.ResourceName.PureName(),
                        Direction        = CodeDomNode.PropertyInfoAssist.enDirection.Get,
                    };

                    var pos  = actionData.NodesContainer._RectCanvas.TranslatePoint(actionData.Pos, actionData.NodesContainer._MainDrawCanvas);
                    var node = actionData.NodesContainer.AddNodeControl(nodeType, csParam, pos.X, pos.Y);
                    item.AddInstanceNode(actionData.NodesContainer.GUID, node);
                    //nc.VariablePopupGetProcess(pos);
                };
            }));
            Macross.CategoryItem.RegistInitAction("UI_UIElement_Event", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                var initData  = data as UIElementEventCategoryItemInitData;
                item.Icon     = TryFindResource("Icon_Function") as ImageSource;
                item.Name     = initData.FunctionName + "___" + item.Id.ToString().Replace("-", "_");
                item.ShowName = $"{initData.FunctionName}({initData.UIElement.Initializer.Name})";
                Macross.CategoryItem.Delegate_OnDoubleClick action = async(categoryItem) =>
                {
                    var noUse = await ctrl.ShowNodesContainer(categoryItem);
                };
                item.OnDoubleClick += action;
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new UIElementEventCategoryItemPorpertys();
                }
                var varItemPro = item.PropertyShowItem as UIElementEventCategoryItemPorpertys;

                varItemPro.MethodInfo.MethodName  = item.Name;     // initData.FunctionName + "_" + item.Id.ToString().Replace("-", "_");
                varItemPro.MethodInfo.DisplayName = item.ShowName; // $"{initData.FunctionName}({initData.UIElement.Initializer.Name})";

                var invokeMethod = initData.EventType.GetMethod("Invoke");
                var methodParams = invokeMethod.GetParameters();
                foreach (var methodParam in methodParams)
                {
                    var funcParam            = new CodeDomNode.CustomMethodInfo.FunctionParam();
                    funcParam.HostMethodInfo = varItemPro.MethodInfo;
                    funcParam.ParamName      = methodParam.Name;
                    funcParam.ParamType      = new CodeDomNode.VariableType(methodParam.ParameterType, ctrl.CSType);
                    if (methodParam.IsOut)
                    {
                        varItemPro.MethodInfo.OutParams.Add(funcParam);
                    }
                    else
                    {
                        varItemPro.MethodInfo.InParams.Add(funcParam);
                    }
                }
                if (invokeMethod.ReturnType != typeof(void) && invokeMethod.ReturnType != typeof(System.Threading.Tasks.Task))
                {
                    var funcParam            = new CodeDomNode.CustomMethodInfo.FunctionParam();
                    funcParam.HostMethodInfo = varItemPro.MethodInfo;
                    funcParam.ParamName      = "Return";
                    if (invokeMethod.ReturnType.BaseType == typeof(System.Threading.Tasks.Task))
                    {
                        var genericType               = invokeMethod.ReturnType.GetGenericArguments()[0];
                        funcParam.ParamType           = new CodeDomNode.VariableType(genericType, ctrl.CSType);
                        varItemPro.MethodInfo.IsAsync = true;
                    }
                    else
                    {
                        funcParam.ParamType = new CodeDomNode.VariableType(invokeMethod.ReturnType, ctrl.CSType);
                    }
                    varItemPro.MethodInfo.OutParams.Add(funcParam);
                }
                else if (invokeMethod.ReturnType == typeof(System.Threading.Tasks.Task))
                {
                    varItemPro.MethodInfo.IsAsync = true;
                }

                initData.UIElement.Initializer.PropertyChanged += (sender, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case "Name":
                        item.ShowName = $"{initData.FunctionName}({initData.UIElement.Initializer.Name})";
                        varItemPro.MethodInfo.DisplayName = item.ShowName;
                        break;
                    }
                };

                BindingOperations.SetBinding(varItemPro.MethodInfo, CodeDomNode.CustomMethodInfo.TooltipProperty, new Binding("ToolTips")
                {
                    Source = item, Mode = BindingMode.TwoWay
                });

                var menuItem = new MenuItem()
                {
                    Name   = "UIElementEventOpenGraph",
                    Header = "打开",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    action.Invoke(item);
                };
                if (data.Deleteable)
                {
                    menuItem = new MenuItem()
                    {
                        Name   = "UIElementEventDelete",
                        Header = "删除",
                        Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                    };
                    ResourceLibrary.Controls.Menu.MenuAssist.SetIcon(menuItem, new BitmapImage(new Uri("/ResourceLibrary;component/Icons/Icons/icon_Edit_Delete_40x.png", UriKind.Relative)));
                    menuItem.Click += (object sender, RoutedEventArgs e) =>
                    {
                        if (EditorCommon.MessageBox.Show($"即将删除{item.Name},删除后无法恢复,是否继续?", EditorCommon.MessageBox.enMessageBoxButton.YesNo) == EditorCommon.MessageBox.enMessageBoxResult.Yes)
                        {
                            item.ParentCategory.Items.Remove(item);
                            ctrl.RemoveNodesContainer(item);
                            var fileName = ctrl.GetGraphFileName(item.Name);
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName);

                            // 从UIResourceInfo中删除Event标记
                            var key = new UIResourceInfo.UIEventDicKey(initData.UIElementId, initData.FunctionName);
                            HostControl.CurrentResInfo.UIEventsDic.Remove(key);
                        }
                    };
                    item.CategoryItemContextMenu.Items.Add(menuItem);
                }
            }));
            Macross.CategoryItem.RegistInitAction("UI_UIElement_PropertyCustomBind", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                var initData  = data as UIElementPropertyCustomBindCategoryitemInitData;
                item.Icon     = TryFindResource("Icon_Function") as ImageSource;
                item.Name     = initData.FunctionName;
                item.ShowName = $"UIBindFunc_{initData.PropertyName}({initData.UIElement.Initializer.Name})";
                Macross.CategoryItem.Delegate_OnDoubleClick action = async(categoryItem) =>
                {
                    var noUse = await ctrl.ShowNodesContainer(categoryItem);
                };
                item.OnDoubleClick += action;
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new UIElementPropertyCustomBindCategoryItemPropertys();
                }
                BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("FunctionName")
                {
                    Source = initData
                });

                var varItemPro = item.PropertyShowItem as UIElementPropertyCustomBindCategoryItemPropertys;
                varItemPro.MethodInfo.MethodName  = item.Name;
                varItemPro.MethodInfo.DisplayName = item.ShowName;
                BindingOperations.SetBinding(varItemPro.MethodInfo, CodeDomNode.CustomMethodInfo.MethodNameProperty, new Binding("Name")
                {
                    Source = item
                });
                initData.UIElement.Initializer.PropertyChanged += (sender, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case "Name":
                        item.ShowName = $"UIBindFuc_{initData.PropertyName}({initData.UIElement.Initializer.Name})";
                        varItemPro.MethodInfo.DisplayName = item.ShowName;
                        break;
                    }
                };

                var funcParam            = new CodeDomNode.CustomMethodInfo.FunctionParam();
                funcParam.HostMethodInfo = varItemPro.MethodInfo;
                funcParam.ParamName      = "uiElement";
                funcParam.ParamType      = new CodeDomNode.VariableType(initData.UIElement.GetType(), ctrl.CSType);
                varItemPro.MethodInfo.InParams.Add(funcParam);
                funcParam = new CodeDomNode.CustomMethodInfo.FunctionParam();
                funcParam.HostMethodInfo = varItemPro.MethodInfo;
                funcParam.ParamName      = "value";
                funcParam.ParamType      = new CodeDomNode.VariableType(initData.PropertyType, ctrl.CSType);
                varItemPro.MethodInfo.InParams.Add(funcParam);

                var menuItem = new MenuItem()
                {
                    Name   = "UIElementPropertyCustomBindFuncOpenGraph",
                    Header = "打开",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    action.Invoke(item);
                };
            }));
            Macross.CategoryItem.RegistInitAction("UI_UIElement_VariableBind", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                var initData  = data as UIElementVariableBindCategoryItemInitData;
                item.Icon     = TryFindResource("Icon_Function") as ImageSource;
                item.Name     = initData.FunctionName;
                item.ShowName = $"UIVarBind_({initData.TargetUIElement.Initializer.Name}.{initData.TargetPropertyName})";
                Macross.CategoryItem.Delegate_OnDoubleClick action = async(categoryItem) =>
                {
                    var noUse = await ctrl.ShowNodesContainer(categoryItem);
                };
                item.OnDoubleClick += action;
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new UIElementVariableBindCategoryItemPropertys();
                }
                BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("FunctionName")
                {
                    Source = initData
                });

                var varItemPro = item.PropertyShowItem as UIElementVariableBindCategoryItemPropertys;
                varItemPro.MethodInfo.MethodName  = item.Name;
                varItemPro.MethodInfo.DisplayName = item.ShowName;
                BindingOperations.SetBinding(varItemPro.MethodInfo, CodeDomNode.CustomMethodInfo.MethodNameProperty, new Binding("Name")
                {
                    Source = item
                });
                initData.TargetUIElement.Initializer.PropertyChanged += (sender, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case "Name":
                        item.ShowName = $"UIVarBind_({initData.TargetUIElement.Initializer.Name}.{initData.TargetPropertyName})";
                        varItemPro.MethodInfo.DisplayName = item.ShowName;
                        break;
                    }
                };

                var funcParam            = new CodeDomNode.CustomMethodInfo.FunctionParam();
                funcParam.HostMethodInfo = varItemPro.MethodInfo;
                funcParam.ParamName      = "uiElement";
                funcParam.ParamType      = new CodeDomNode.VariableType(initData.UIElement.GetType(), ctrl.CSType);
                varItemPro.MethodInfo.InParams.Add(funcParam);
                funcParam = new CodeDomNode.CustomMethodInfo.FunctionParam();
                funcParam.HostMethodInfo = varItemPro.MethodInfo;
                funcParam.ParamName      = "inValue";
                funcParam.ParamType      = new CodeDomNode.VariableType(initData.PropertyType, ctrl.CSType);
                varItemPro.MethodInfo.InParams.Add(funcParam);

                var retParam            = new CodeDomNode.CustomMethodInfo.FunctionParam();
                retParam.HostMethodInfo = varItemPro.MethodInfo;
                retParam.ParamName      = "outValue";
                retParam.ParamType      = new CodeDomNode.VariableType(initData.TargetPropertyType, ctrl.CSType);
                varItemPro.MethodInfo.OutParams.Add(retParam);

                var menuItem = new MenuItem()
                {
                    Name   = "UIElementVariableBindFuncOpenGraph",
                    Header = "打开",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                ResourceLibrary.Controls.Menu.MenuAssist.SetIcon(menuItem, new BitmapImage(new Uri("/ResourceLibrary;component/Icons/Icons/icon_Edit_Delete_40x.png", UriKind.Relative)));
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    action.Invoke(item);
                };
            }));
            Macross.CategoryItem.RegistInitAction("UI_UIElement_CustomEvent", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                var initData = data as UIElementCustomEventCategoryItemInitData;
                item.Icon    = TryFindResource("Icon_Function") as ImageSource;
                item.Name    = initData.DisplayName;

                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new UIElementCustomEventCategoryItemPropertys();
                }
                var itemPro  = item.PropertyShowItem as UIElementCustomEventCategoryItemPropertys;
                itemPro.Name = initData.DisplayName;
                itemPro.MethodInfo.MethodName      = initData.EventName;
                itemPro.MethodInfo.DisplayName     = initData.DisplayName;
                itemPro.MethodInfo.CSType          = ctrl.CSType;
                itemPro.MethodInfo.IsDelegateEvent = true;
                BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("DisplayName")
                {
                    Source = itemPro.MethodInfo, Mode = BindingMode.TwoWay
                });
                BindingOperations.SetBinding(itemPro, UIElementCustomEventCategoryItemPropertys.NameProperty, new Binding("Name")
                {
                    Source = item, Mode = BindingMode.TwoWay
                });
                BindingOperations.SetBinding(itemPro.MethodInfo, CodeDomNode.CustomMethodInfo.TooltipProperty, new Binding("ToolTips")
                {
                    Source = item, Mode = BindingMode.TwoWay
                });

                item.OnNameChangedEvent += async(categoryItem, newValue, oldValue) =>
                {
                    foreach (var insData in categoryItem.InstanceNodes)
                    {
                        var container = await categoryItem.ParentCategory.HostControl.HostControl.GetNodesContainer(insData.ContainerKeyId, true);
                        var node      = container.FindControl(insData.NodeId);
                        var param     = node.CSParam as CodeDomNode.MethodCustomInvoke.MethodCustomInvokeConstructParam;
                        param.MethodInfo.DisplayName = newValue;
                    }
                };
                item.OnDropToNodesControlAction = (dropData) =>
                {
                    var nodeCtrl               = EditorCommon.Program.GetParent(dropData.DropCanvas, typeof(CodeGenerateSystem.Controls.NodesContainerControl)) as CodeGenerateSystem.Controls.NodesContainerControl;
                    var nodeType               = typeof(CodeDomNode.MethodCustomInvoke);
                    var csParam                = new CodeDomNode.MethodCustomInvoke.MethodCustomInvokeConstructParam();
                    csParam.CSType             = ctrl.CSType;
                    csParam.HostNodesContainer = nodeCtrl;
                    csParam.ConstructParam     = "";
                    csParam.MethodInfo         = itemPro.MethodInfo;
                    var pos  = nodeCtrl._RectCanvas.TranslatePoint(dropData.DropPos, nodeCtrl._MainDrawCanvas);
                    var node = nodeCtrl.AddNodeControl(nodeType, csParam, pos.X, pos.Y);
                    node.NodeNameAddShowNodeName = false;
                    item.AddInstanceNode(nodeCtrl.GUID, node);
                };

                var menuItem = new MenuItem()
                {
                    Name   = "UI_CustomEvent_Delete",
                    Header = "删除",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                ResourceLibrary.Controls.Menu.MenuAssist.SetIcon(menuItem, new BitmapImage(new Uri("/ResourceLibrary;component/Icons/Icons/icon_Edit_Delete_40x.png", UriKind.Relative)));
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    if (EditorCommon.MessageBox.Show($"即将删除{this.Name},删除后无法恢复,是否继续?", EditorCommon.MessageBox.enMessageBoxButton.YesNo) == EditorCommon.MessageBox.enMessageBoxResult.Yes)
                    {
                        item.RemoveFromParent();
                        ctrl.RemoveNodesContainer(item);
                        var fileName = ctrl.GetGraphFileName(this.Name);
                        EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName);

                        item.ParentCategory?.HostControl.HostControl.ShowItemPropertys(null);
                    }
                };
                item.CategoryItemContextMenu.Items.Add(menuItem);
            }));
        }