コード例 #1
0
ファイル: DefaultAlgorithm.cs プロジェクト: yungtau/oea
        protected override void GroupCommandCore(WPFCommand cmd)
        {
            var newGroup  = new GeneratableCommandGroup(cmd.Name);
            var generator = new CompoundGenerator
            {
                CommandMetaGroup = newGroup,
                Context          = this.Context
            };

            newGroup.Generator = generator;

            //是否生成到菜单中
            if (cmd.HasLocation(CommandLocation.Menu))
            {
                //为每一个命令都声明一个单独的组
                //构造并设置控件生成器
                generator.Add(new MenuItemGenerator
                {
                    CommandMetaGroup = newGroup,
                    Context          = this.Context
                });
            }

            if (cmd.HasLocation(CommandLocation.Toolbar))
            {
                if (cmd.Hierarchy.Count != 1)
                {
                    generator.Add(new ButtonItemGenerator
                    {
                        CommandMetaGroup = newGroup,
                        Context          = this.Context
                    });
                }
                else
                {
                    string groupName = cmd.Hierarchy[0];
                    newGroup = this.TryFindGroup(groupName);

                    if (newGroup == null)
                    {
                        newGroup           = this.AddNewGroup(groupName);
                        newGroup.Generator = new SplitButtonGroupGenerator
                        {
                            CommandMetaGroup = newGroup,
                            Context          = this.Context
                        };
                    }
                }
            }

            newGroup.AddCommand(cmd);

            FinalGroups[newGroup.Name] = newGroup;
        }
コード例 #2
0
ファイル: DefaultAlgorithm.cs プロジェクト: 569550384/Rafy
        protected override void GroupCommandCore(WPFCommand cmd)
        {
            var newGroup = new GeneratableCommandGroup(cmd.Name);
            var generator = new CompoundGenerator
            {
                CommandMetaGroup = newGroup,
                Context = this.Context
            };
            newGroup.Generator = generator;

            //是否生成到菜单中
            if (cmd.HasLocation(CommandLocation.Menu))
            {
                //为每一个命令都声明一个单独的组
                //构造并设置控件生成器
                generator.Add(new MenuItemGenerator
                {
                    CommandMetaGroup = newGroup,
                    Context = this.Context
                });
            }

            if (cmd.HasLocation(CommandLocation.Toolbar))
            {
                if (cmd.Hierarchy.Count != 1)
                {
                    generator.Add(new ButtonItemGenerator
                    {
                        CommandMetaGroup = newGroup,
                        Context = this.Context
                    });
                }
                else
                {
                    string groupName = cmd.Hierarchy[0];
                    newGroup = this.TryFindGroup(groupName);

                    if (newGroup == null)
                    {
                        newGroup = this.AddNewGroup(groupName);
                        newGroup.Generator = new SplitButtonGroupGenerator
                        {
                            CommandMetaGroup = newGroup,
                            Context = this.Context
                        };
                    }
                }
            }

            newGroup.AddCommand(cmd);

            FinalGroups[newGroup.Name] = newGroup;
        }