Пример #1
0
        private void MenuItem_PostProcess_Click(object sender, RoutedEventArgs e)
        {
            Category category;

            if (!mCategoryDic.TryGetValue(LogicAnimationPostProcessCategoryName, out category))
            {
                return;
            }

            var validName = GetValidName("LogicAnimPostProcess", category);
            var item      = new CategoryItem(null, category);

            item.CategoryItemType = CategoryItem.enCategoryItemType.LogicAnimPostProcess;
            item.Name             = validName;
            item.InitTypeStr      = "LA_PostProcess";
            var data = new LAAnimPostProcessCategoryItemInitData();

            data.Name     = validName;
            data.ToolTips = item.ToolTips;
            data.Reset();
            item.Initialize(HostControl, data);
            category.Items.Add(item);
            Action create = async() =>
            {
                var nodeContainer = await HostControl.GetNodesContainer(item, true);

                {
                    var csParam = new LAStartPoseControlConstructionParams()
                    {
                        CSType             = HostControl.CSType,
                        NodeName           = "InPose",
                        HostNodesContainer = nodeContainer.NodesControl,
                        ConstructParam     = "",
                    };
                    var ins = nodeContainer.NodesControl.AddNodeControl(typeof(LAStartPoseControl), csParam, 50, 250);
                    ins.HostNodesContainer = nodeContainer.NodesControl;
                    ins.IsDeleteable       = false;
                }
                {
                    var csParam = new LAFinalPoseControlConstructionParams()
                    {
                        CSType             = HostControl.CSType,
                        NodeName           = "OutPose",
                        HostNodesContainer = nodeContainer.NodesControl,
                        ConstructParam     = "",
                    };
                    var ins = nodeContainer.NodesControl.AddNodeControl(typeof(LAFinalPoseControl), csParam, 550, 250);
                    ins.HostNodesContainer = nodeContainer.NodesControl;
                    ins.IsDeleteable       = false;
                }
            };

            create.Invoke();
        }
Пример #2
0
        private void InitializeMenuItems()
        {
            Macross.CategoryItem.RegistInitAction("LA_AnimLayer", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new LAAnimLayerCategoryItemPropertys();

                    var varItemPro          = item.PropertyShowItem as LAAnimLayerCategoryItemPropertys;
                    var varData             = data as LAAnimLayerCategoryItemInitData;
                    varItemPro.Name         = varData.Name;
                    varItemPro.ToolTips     = varData.ToolTips;
                    varItemPro.LayerType    = varData.LayerType;
                    varItemPro.CategoryItem = item;
                    BindingOperations.SetBinding(item, CategoryItem.NameProperty, new Binding("Name")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                    BindingOperations.SetBinding(item, CategoryItem.ToolTipsProperty, new Binding("ToolTips")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                    BindingOperations.SetBinding(varItemPro, LAAnimLayerCategoryItemPropertys.LayerTypeProperty, new Binding("LayerType")
                    {
                        Source = varData, Mode = BindingMode.TwoWay
                    });
                }
                //BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("Name") { Source = initData.UIElement.Initializer });
                var menuItem = new MenuItem()
                {
                    Name   = "LA_AnimLayerItem",
                    Header = "添加LinkNode",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    var animGrapItem = new CategoryItem(item, item.ParentCategory);
                    animGrapItem.CategoryItemType = CategoryItem.enCategoryItemType.LogicAnimGraph;
                    animGrapItem.Name             = GetValidName("LinkNode", item.ParentCategory);
                    animGrapItem.InitTypeStr      = "LA_AnimGraph";
                    var tempData      = new LAAnimGraphCategoryItemInitData();
                    tempData.Name     = animGrapItem.Name;
                    tempData.ToolTips = animGrapItem.ToolTips;
                    tempData.Reset();
                    animGrapItem.Initialize(ctrl, tempData);
                    item.Children.Add(animGrapItem); Action create = async() =>
                    {
                        var nodeContainer            = await ctrl.GetNodesContainer(animGrapItem, true);
                        var csParam                  = new LAGraphNodeControlConstructionParams();
                        csParam.CSType               = ctrl.CSType;
                        csParam.LAGNodeName          = animGrapItem.Name;
                        csParam.LinkedCategoryItemID = animGrapItem.Id;
                        csParam.IsSelfGraphNode      = true;
                        var ins = nodeContainer.NodesControl.AddNodeControl(typeof(LAGraphNodeControl), csParam, 0, 200);
                        ins.HostNodesContainer = nodeContainer.NodesControl;
                    };
                    create.Invoke();
                };
                item.CategoryItemContextMenu.Items.Add(menuItem);
                {
                    menuItem = new MenuItem()
                    {
                        Name   = "LA_AnimLayerItem_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.ParentCategory.Items.Remove(item);
                            ctrl.RemoveNodesContainer(item);
                            var fileName = ctrl.GetGraphFileName(item.Name);
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName);
                            if (item.Parent != null)
                            {
                                item.Parent.Children.Remove(item);
                            }
                        }
                    };
                    item.CategoryItemContextMenu.Items.Add(menuItem);
                }
            }));

            Macross.CategoryItem.RegistInitAction("LA_AnimGraph", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem = new LAAnimGraphCategoryItemPropertys();
                    var varItemPro        = item.PropertyShowItem as LAAnimGraphCategoryItemPropertys;
                    var varData           = data as LAAnimGraphCategoryItemInitData;
                    if (varData == null)
                    {
                        varItemPro.Name     = item.Name;
                        varItemPro.ToolTips = item.ToolTips;
                    }
                    else
                    {
                        varItemPro.Name     = varData.Name;
                        varItemPro.ToolTips = varData.ToolTips;
                    }
                    varItemPro.LinkControl  = ctrl as MCLAMacrossLinkControl;
                    varItemPro.CategoryItem = item;
                    BindingOperations.SetBinding(item, CategoryItem.NameProperty, new Binding("Name")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                    BindingOperations.SetBinding(item, CategoryItem.ToolTipsProperty, new Binding("ToolTips")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                }
                var initData = data as LAAnimGraphCategoryItemInitData;

                //BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("Name") { Source = initData.UIElement.Initializer });
                item.Icon           = TryFindResource("Icon_Graph") as ImageSource;
                item.OnDoubleClick += (categoryItem) =>
                {
                    var noUse = ctrl.ShowNodesContainer(categoryItem);
                };

                var menuItem = new MenuItem()
                {
                    Name   = "LA_AnimGraphItem",
                    Header = "添加LinkNode",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };

                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    var animGrapItem = new CategoryItem(item, item.ParentCategory);
                    animGrapItem.CategoryItemType = CategoryItem.enCategoryItemType.LogicAnimGraph;
                    animGrapItem.Name             = GetValidName("LinkNode", item.ParentCategory);
                    animGrapItem.InitTypeStr      = "LA_AnimGraph";
                    var tempData      = new LAAnimGraphCategoryItemInitData();
                    tempData.Name     = animGrapItem.Name;
                    tempData.ToolTips = animGrapItem.ToolTips;
                    tempData.Reset();
                    animGrapItem.Initialize(ctrl, tempData);
                    item.Children.Add(animGrapItem);
                    Action create = async() =>
                    {
                        var nodeContainer            = await ctrl.GetNodesContainer(animGrapItem, true);
                        var csParam                  = new LAGraphNodeControlConstructionParams();
                        csParam.CSType               = ctrl.CSType;
                        csParam.LAGNodeName          = animGrapItem.Name;
                        csParam.LinkedCategoryItemID = animGrapItem.Id;
                        csParam.IsSelfGraphNode      = true;
                        var ins = nodeContainer.NodesControl.AddNodeControl(typeof(LAGraphNodeControl), csParam, 0, 200);
                        ins.HostNodesContainer = nodeContainer.NodesControl;
                    };
                    create.Invoke();
                };
                item.CategoryItemContextMenu.Items.Add(menuItem);
                {
                    menuItem = new MenuItem()
                    {
                        Name   = "LA_AnimGraphItem_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.ParentCategory.Items.Remove(item);
                            ctrl.RemoveNodesContainer(item);
                            var fileName = ctrl.GetGraphFileName(item.Name);
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName);
                            if (item.Parent != null)
                            {
                                item.Parent.Children.Remove(item);
                            }
                        }
                    };
                    item.CategoryItemContextMenu.Items.Add(menuItem);
                }
            }));

            Macross.CategoryItem.RegistInitAction("LA_PostProcess", new Action <Macross.CategoryItem, Macross.IMacrossOperationContainer, Macross.CategoryItem.InitializeData>((item, ctrl, data) =>
            {
                if (item.PropertyShowItem == null)
                {
                    item.PropertyShowItem   = new LAAnimPostProcessCategoryItemPropertys();
                    var varItemPro          = item.PropertyShowItem as LAAnimPostProcessCategoryItemPropertys;
                    var varData             = new LAAnimPostProcessCategoryItemInitData();
                    varItemPro.Name         = varData.Name;
                    varItemPro.ToolTips     = varData.ToolTips;
                    varItemPro.CategoryItem = item;
                    BindingOperations.SetBinding(item, CategoryItem.NameProperty, new Binding("Name")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                    BindingOperations.SetBinding(item, CategoryItem.ToolTipsProperty, new Binding("ToolTips")
                    {
                        Source = varItemPro, Mode = BindingMode.TwoWay
                    });
                    var initData = data as LAAnimPostProcessCategoryItemInitData;
                }

                //BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("Name") { Source = initData.UIElement.Initializer });
                item.Icon = TryFindResource("Icon_Graph") as ImageSource;
                Macross.CategoryItem.Delegate_OnDoubleClick openAction = async(categoryItem) =>
                {
                    var noUse = await ctrl.ShowNodesContainer(categoryItem);
                };
                item.OnDoubleClick += openAction;
                var menuItem        = new MenuItem()
                {
                    Name   = "AnimPostProcessOpenGraph",
                    Header = "打开",
                    Style  = TryFindResource(new ComponentResourceKey(typeof(ResourceLibrary.CustomResources), "MenuItem_Default")) as Style,
                };
                menuItem.Click += (object sender, RoutedEventArgs e) =>
                {
                    openAction.Invoke(item);
                };
                item.CategoryItemContextMenu.Items.Add(menuItem);
                {
                    menuItem = new MenuItem()
                    {
                        Name   = "LA_AnimGraphItem_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.ParentCategory.Items.Remove(item);
                            ctrl.RemoveNodesContainer(item);
                            var fileName = ctrl.GetGraphFileName(item.Name);
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName);
                            if (item.Parent != null)
                            {
                                item.Parent.Children.Remove(item);
                            }
                        }
                    };
                    item.CategoryItemContextMenu.Items.Add(menuItem);
                }
            }));
        }