예제 #1
0
        /// <summary>
        /// 添加一个新的组到ExistingGroups中,组名为groupName
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        protected GeneratableCommandGroup AddNewGroup(string groupName)
        {
            var group = new GeneratableCommandGroup(groupName);

            FinalGroups[group.Name] = group;
            return(group);
        }
예제 #2
0
        /// <summary>
        /// 在ExistingGroups中查找指定的组
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        protected GeneratableCommandGroup TryFindGroup(string groupName)
        {
            GeneratableCommandGroup group = null;

            FinalGroups.TryGetValue(groupName, out group);
            return(group);
        }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }
예제 #5
0
 /// <summary>
 /// 添加一个新的组到ExistingGroups中,组名为groupName
 /// </summary>
 /// <param name="groupName"></param>
 /// <returns></returns>
 protected GeneratableCommandGroup AddNewGroup(string groupName)
 {
     var group = new GeneratableCommandGroup(groupName);
     FinalGroups[group.Name] = group;
     return group;
 }