Пример #1
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            IContentMenuService cmbService = context.Services.Get <IContentMenuService>();

            if (cmbService == null)
            {
                throw new UniframeworkException(String.Format("未注册IContentMenuBarService无法创建上下文菜单 \"{0}\"。", element.Name));
            }

            BarSubItem item = new BarSubItem();

            item.Name    = element.Name;
            item.Tag     = element.Path;
            item.Manager = BuilderUtility.GetBarManager(context); // 设置工具栏管理器
            string exPath = BuilderUtility.CombinPath(element.Path, element.Id);

            cmbService.RegisterContentMenu(exPath, item);

            // 添加插件单元到系统中
            if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
            {
                context.UIExtensionSites[element.Path].Add(item);
            }
            if (!String.IsNullOrEmpty(element.Command))
            {
                Command cmd = BuilderUtility.GetCommand(context, element.Command);
                if (cmd != null)
                {
                    cmd.AddInvoker(item, "Popup");
                }
            }

            context.UIExtensionSites.RegisterSite(exPath, item);
            return(item);
        }
Пример #2
0
        public NavBarItem AddNaviBarItem(string extPath, string id, string text, string command, string imagefile, string largeimage)
        {
            Guard.ArgumentNotNull(extPath, "extPath");

            NavBarItem item = new NavBarItem(text);

            item.Name = id;
            if (!String.IsNullOrEmpty(imagefile))
            {
                item.SmallImage = BuilderUtility.GetBitmap(WorkItem, imagefile, 16, 16);
            }
            if (!String.IsNullOrEmpty(largeimage))
            {
                item.LargeImage = BuilderUtility.GetBitmap(WorkItem, largeimage, 32, 32);
            }
            Command cmd = BuilderUtility.GetCommand(WorkItem, command);

            if (cmd != null)
            {
                cmd.AddInvoker(item, "LinkClicked");
            }
            if (!String.IsNullOrEmpty(extPath) && WorkItem.UIExtensionSites.Contains(extPath))
            {
                WorkItem.UIExtensionSites[extPath].Add(item);
            }

            return(item);
        }
Пример #3
0
        private BarItem CreateButton(string extPath, string id, string text, string command, bool regisger)
        {
            BarItem item = null;

            if (regisger)
            {
                item = new BarSubItem();
                WorkItem.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(extPath, id), item);
            }
            else
            {
                item = new BarButtonItem();
            }
            item.Name    = id;
            item.Caption = text;
            item.Hint    = text;
            Command cmd = BuilderUtility.GetCommand(WorkItem, command);

            if (cmd != null)
            {
                cmd.AddInvoker(item, "ItemClick");
            }

            return(item);
        }
Пример #4
0
        /// <summary>
        /// 增加一个导航分组
        /// </summary>
        /// <param name="naviPane"></param>
        /// <param name="extPath">路径</param>
        /// <param name="name">名称</param>
        /// <param name="text"></param>
        /// <param name="groupStyle">样式</param>
        /// <param name="imagefile">显示的小图标文件名,以"${...}"括起来</param>
        /// <param name="largeimage">显示的大图标文件名</param>
        /// <returns></returns>
        public NavBarGroup AddNaviBar(string naviPane, string extPath, string id, string text, NavBarGroupStyle groupStyle, string imagefile, string largeimage)
        {
            NavBarGroup group = null;

            NavBarControl naviBar = WorkItem.Items.Get <NavBarControl>(naviPane);

            if (naviBar == null)
            {
                throw new UniframeworkException(String.Format("未定义导航栏 \"{0}\"", naviPane));
            }

            group            = new NavBarGroup(text);
            group.Name       = id;
            group.GroupStyle = groupStyle;
            naviBar.Groups.Add(group);
            if (!String.IsNullOrEmpty(imagefile))
            {
                group.SmallImage = BuilderUtility.GetBitmap(WorkItem, imagefile, 16, 16);
            }
            if (!String.IsNullOrEmpty(largeimage))
            {
                group.LargeImage = BuilderUtility.GetBitmap(WorkItem, largeimage, 32, 32);
            }
            WorkItem.UIExtensionSites.RegisterSite(extPath, group);
            return(group);
        }
Пример #5
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            Guard.ArgumentNotNull(context, "插件构建上下文对象");

            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }

            string  label = element.Configuration.Attributes["label"];
            BarItem item;
            bool    register = false;

            if (element.Configuration.Attributes["register"] != null)
            {
                register = bool.Parse(element.Configuration.Attributes["register"]);
            }
            Bar bar = context.Items.Get <Bar>(UIExtensionSiteNames.Shell_Bar_Mainmenu);

            if (bar == null)
            {
                throw new UniframeworkException("没有定义系统主菜单条无法创建系统皮肤菜单项。");
            }

            item         = new XtraBarListMenu(bar);
            item.Caption = label;
            item.Name    = element.Name;
            BarManager barManager = BuilderUtility.GetBarManager(context);

            if (barManager != null)
            {
                item.Id = barManager.GetNewItemId(); // 为BarItem设置Id方便正确的保存和恢复其状态
            }
            BarItemExtend extend = new BarItemExtend();

            if (element.Configuration.Attributes["begingroup"] != null)
            {
                bool beginGroup = bool.Parse(element.Configuration.Attributes["begingroup"]);
                extend.BeginGroup = beginGroup;
            }
            if (element.Configuration.Attributes["insertbefore"] != null)
            {
                extend.InsertBefore = element.Configuration.Attributes["insertbefore"];
            }
            item.Tag = extend;

            // 添加插件单元到系统中
            if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
            {
                context.UIExtensionSites[element.Path].Add(item);
            }

            // 注册此路径的插件
            if (register)
            {
                context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item);
            }
            return(item);
        }
Пример #6
0
        /// <summary>
        /// 注册文档工厂
        /// </summary>
        /// <param name="documentFactory">文档工厂.</param>
        public void Register(IDocumentFactory documentFactory)
        {
            documentFactories.Add(documentFactory.Extension, documentFactory);
            openFileDialog.Filter = AppendFilter(openFileDialog.Filter, documentFactory);

            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_OPEN, documentFactories.Count > 0);
        }
Пример #7
0
        private void SetCommandStatus(string command, bool enabled)
        {
            Command cmd = BuilderUtility.GetCommand(WorkItem, command);

            if (cmd != null)
            {
                cmd.Status = (enabled) ? CommandStatus.Enabled : CommandStatus.Disabled;
            }
        }
Пример #8
0
        private void UpdateCommandStatus()
        {
            bool enabled = Browser != null;

            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_VIEW_BACK, enabled && Browser.CanBack);
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_VIEW_FORWARD, enabled && Browser.CanForward);
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_VIEW_STOP, enabled && Browser.CanStop);
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_VIEW_HOME, !String.IsNullOrEmpty(HomeUri));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_VIEW_REFRESH, enabled && Browser.CanRefresh);
        }
Пример #9
0
        /// <summary>
        /// Updates the command status.
        /// </summary>
        private void UpdateCommandStatus()
        {
            bool enabled = (activeDocument != null);

            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_OPEN, documentFactories.Count > 0 &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_OPEN));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_SAVE, enabled && ActiveDocument.CanSave &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_SAVE));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_SAVEAS, enabled && ActiveDocument.CanSave &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_SAVEAS));
        }
Пример #10
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }
            if (element.Configuration.Attributes["navipane"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供navipane属性。",
                                                       element.ClassName, element.Id));
            }

            string      label    = element.Configuration.Attributes["label"];
            string      navipane = element.Configuration.Attributes["navipane"];
            NavBarGroup item     = new NavBarGroup(BuilderUtility.GetStringRES(context, label));

            item.GroupStyle = NavBarGroupStyle.LargeIconsText;
            NavBarControl naviPane = context.Items.Get <NavBarControl>(navipane);

            if (naviPane == null)
            {
                throw new UniframeworkException("未定义框架外壳的导航栏管理器。");
            }
            naviPane.Groups.Add(item); // 添加分组条到导航栏

            if (element.Configuration.Attributes["tooltip"] != null)
            {
                item.Hint = element.Configuration.Attributes["tooltip"];
            }

            // 设置分组栏显示的图像
            if (element.Configuration.Attributes["imagefile"] != null)
            {
                string image = element.Configuration.Attributes["imagefile"];
                item.SmallImage = BuilderUtility.GetBitmap(context, image, 16, 16);
            }
            if (element.Configuration.Attributes["largeimage"] != null)
            {
                string largeImage = element.Configuration.Attributes["largeimage"];
                item.LargeImage = BuilderUtility.GetBitmap(context, largeImage, 32, 32);
            }

            if (element.Configuration.Attributes["register"] != null)
            {
                bool register = bool.Parse(element.Configuration.Attributes["register"]);
                if (register)
                {
                    context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item);
                }
            }
            return(item);
        }
Пример #11
0
        /// <summary>
        /// 增加一个菜单项、按钮
        /// </summary>
        /// <param name="extPath">路径</param>
        /// <param name="id">标识</param>
        /// <param name="text">标题</param>
        /// <param name="command">命令</param>
        /// <param name="register">是否注册此菜单项以便可以在其下增加子菜单项</param>
        /// <param name="beginGroup">是否添加分隔条</param>
        /// <param name="insertBefore">插入位置</param>
        /// <param name="imagefile">小图标文件名称</param>
        /// <param name="largeimage">大图标文件名称</param>
        /// <param name="shortcut">快捷键</param>
        /// <returns>返回创建好的菜单项/按钮</returns>
        public BarItem AddButton(string extPath, string id, string text, string command, bool register, bool beginGroup, string insertBefore, string imagefile, string largeimage, string shortcut)
        {
            BarItem item = AddButton(extPath, id, text, command, register, beginGroup, insertBefore);

            if (!String.IsNullOrEmpty(imagefile))
            {
                item.Glyph = BuilderUtility.GetBitmap(WorkItem, imagefile, 16, 16);
            }
            if (!String.IsNullOrEmpty(largeimage))
            {
                item.LargeGlyph = BuilderUtility.GetBitmap(WorkItem, largeimage, 32, 32);
            }
            return(item);
        }
Пример #12
0
        /// <summary>
        /// 更新命令处理器的状态
        /// </summary>
        private void UpdateCommandStatus()
        {
            bool enabled = (activeHandler != null);

            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_PRINT, enabled && activeHandler.CanPrint &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_PRINT));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_QUICKPRINT, enabled && activeHandler.CanQuickPrint &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_QUICKPRINT));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_PREVIEW, enabled && activeHandler.CanPreview &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_PREVIEW));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_PAGESETUP, enabled && activeHandler.CanPageSetup &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_PAGESETUP));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_FILE_DESIGN, enabled && activeHandler.CanDesign &&
                                            CanExecute(CommandHandlerNames.CMD_FILE_DESIGN));
        }
Пример #13
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }

            string     label      = element.Configuration.Attributes["label"];
            BarManager barManager = context.Items.Get <BarManager>(UIExtensionSiteNames.Shell_Bar_Manager);

            if (barManager == null)
            {
                throw new UniframeworkException("未定义框架外壳的工具条管理器。");
            }

            Bar item = new Bar(barManager, label);

            item.BarName   = element.Name;
            item.DockStyle = BarDockStyle.Top; // 默认停靠在顶部
            if (element.Configuration.Attributes["dockstyle"] != null)
            {
                string dockStyle = element.Configuration.Attributes["dockstyle"];
                item.DockStyle = (BarDockStyle)Enum.Parse(typeof(BarDockStyle), dockStyle);
            }

            // 是否让工具栏显示整行
            if (element.Configuration.Attributes["wholerow"] != null)
            {
                item.OptionsBar.UseWholeRow = bool.Parse(element.Configuration.Attributes["wholerow"]);
            }
            if (element.Configuration.Attributes["allowcustomization"] != null)
            {
                item.OptionsBar.AllowQuickCustomization = bool.Parse(element.Configuration.Attributes["allowcustomization"]);
            }
            if (element.Configuration.Attributes["register"] != null)
            {
                bool register = bool.Parse(element.Configuration.Attributes["register"]);
                if (register)
                {
                    context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item); // 此处可能抛出异常
                }
            }

            return(item);
        }
Пример #14
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            Guard.ArgumentNotNull(context, "插件构建上下文对象");

            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }

            string label = element.Configuration.Attributes["label"];
            Form   shell = context.Items.Get <Form>(UIExtensionSiteNames.Shell);
            Bar    bar   = context.Items.Get <Bar>(UIExtensionSiteNames.Shell_Bar_Mainmenu);
            XtraTabbedMdiManager mdiManager = context.Items.Get <XtraTabbedMdiManager>(UIExtensionSiteNames.Shell_Manager_TabbedMdiManager);

            Guard.ArgumentNotNull(bar, "Main menu bar.");
            Guard.ArgumentNotNull(shell, "Shell");
            Guard.ArgumentNotNull(mdiManager, "Tabbed mdi manager.");

            XtraWindowMenu item = new XtraWindowMenu(bar, mdiManager, shell);

            item.Caption = label;
            item.Name    = element.Name;
            BarManager barManager = BuilderUtility.GetBarManager(context);

            if (barManager != null)
            {
                item.Id = barManager.GetNewItemId(); // 为BarItem设置Id方便正确的保存和恢复其状态
            }
            if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
            {
                context.UIExtensionSites[element.Path].Add(item);
            }
            // 注册插件单元
            if (element.Configuration.Attributes["register"] != null)
            {
                bool register = bool.Parse(element.Configuration.Attributes["register"]);
                if (register)
                {
                    context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item);
                }
            }
            return(item);
        }
Пример #15
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }

            string     label = element.Configuration.Attributes["label"];
            NavBarItem item  = new NavBarItem(BuilderUtility.GetStringRES(context, label));

            item.Name = element.Name;
            if (element.Configuration.Attributes["tooltip"] != null)
            {
                item.Hint = element.Configuration.Attributes["tooltip"];
            }

            if (element.Configuration.Attributes["largeimage"] != null)
            {
                string largeImage = element.Configuration.Attributes["largeimage"];
                item.LargeImage = BuilderUtility.GetBitmap(context, largeImage, 32, 32);
            }
            if (element.Configuration.Attributes["imagefile"] != null)
            {
                string image = element.Configuration.Attributes["imagefile"];
                item.SmallImage = BuilderUtility.GetBitmap(context, image, 16, 16);
            }

            if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
            {
                context.UIExtensionSites[element.Path].Add(item);
            }
            Command cmd = BuilderUtility.GetCommand(context, element.Command);

            if (cmd != null)
            {
                cmd.AddInvoker(item, "LinkClicked");
            }
            return(item);
        }
Пример #16
0
        private void UpdateCommandStatus()
        {
            bool enabled = (activeHandler != null);

            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_UNDO, enabled && activeHandler.CanUndo &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_UNDO));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_REDO, enabled && activeHandler.CanRedo &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_REDO));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_CUT, enabled && activeHandler.CanCut &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_CUT));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_COPY, enabled && activeHandler.CanCopy &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_COPY));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_PASTE, enabled && activeHandler.CanPaste &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_PASTE));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_DELETE, enabled && activeHandler.CanDelete &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_DELETE));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_SELECTALL, enabled && activeHandler.CanSelectAll &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_SELECTALL));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_SEARCH, enabled && activeHandler.CanSearch &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_SEARCH));
            BuilderUtility.SetCommandStatus(WorkItem, CommandHandlerNames.CMD_EDIT_REPLACE, enabled && activeHandler.CanReplace &&
                                            CanExecute(CommandHandlerNames.CMD_EDIT_REPLACE));
        }
Пример #17
0
        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            if (element.Configuration.Attributes["label"] == null)
            {
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                                                       element.ClassName, element.Id));
            }

            string  label = element.Configuration.Attributes["label"];
            BarItem item;
            bool    register = false;

            if (element.Configuration.Attributes["register"] != null)
            {
                register = bool.Parse(element.Configuration.Attributes["register"]);
            }
            if (register)
            {
                item = new BarSubItem();
            }
            else
            {
                item = new BarButtonItem();
            }
            item.Caption = BuilderUtility.GetStringRES(context, label);
            item.Name    = element.Name;
            BarManager barManager = BuilderUtility.GetBarManager(context);

            if (barManager != null)
            {
                item.Id = barManager.GetNewItemId(); // 为BarItem设置Id方便正确的保存和恢复其状态
            }
            if (element.Configuration.Attributes["alignment"] != null)
            {
                item.Alignment = (BarItemLinkAlignment)Enum.Parse(typeof(BarItemLinkAlignment), element.Configuration.Attributes["alignment"]);
            }
            if (element.Configuration.Attributes["paintstyle"] != null)
            {
                item.PaintStyle = (BarItemPaintStyle)Enum.Parse(typeof(BarItemPaintStyle), element.Configuration.Attributes["paintstyle"]);
            }
            if (element.Configuration.Attributes["tooltip"] != null)
            {
                item.Hint = element.Configuration.Attributes["tooltip"];
            }
            else
            {
                item.Hint = BuilderUtility.GetStringRES(context, label);
            }
            if (element.Configuration.Attributes["largeimage"] != null)
            {
                string largeImage = element.Configuration.Attributes["largeimage"];
                item.LargeGlyph = BuilderUtility.GetBitmap(context, largeImage, 32, 32);
            }
            if (element.Configuration.Attributes["imagefile"] != null)
            {
                string image = element.Configuration.Attributes["imagefile"];
                item.Glyph = BuilderUtility.GetBitmap(context, image, 16, 16);
            }
            if (element.Configuration.Attributes["shortcut"] != null)
            {
                string key = element.Configuration.Attributes["shortcut"];
                try {
                    item.ItemShortcut = new BarShortcut((Shortcut)Enum.Parse(typeof(Shortcut), key));
                }
                catch {
                }
            }

            BarItemExtend extend = new BarItemExtend();

            if (element.Configuration.Attributes["begingroup"] != null)
            {
                bool beginGroup = bool.Parse(element.Configuration.Attributes["begingroup"]);
                extend.BeginGroup = beginGroup;
            }
            if (element.Configuration.Attributes["insertbefore"] != null)
            {
                extend.InsertBefore = element.Configuration.Attributes["insertbefore"];
            }
            item.Tag = extend;

            // 设置菜单项/按钮为选择项
            if ((element.Configuration.Attributes["checked"] != null) && (item is BarButtonItem))
            {
                ((BarButtonItem)item).ButtonStyle = BarButtonStyle.Check;
                bool check = bool.Parse(element.Configuration.Attributes["checked"]);
                ((BarButtonItem)item).Down = check;
                if (element.Configuration.Attributes["optiongroup"] != null)
                {
                    ((BarButtonItem)item).GroupIndex = int.Parse(element.Configuration.Attributes["optiongroup"]);
                }
            }

            // 添加插件单元到系统中
            if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
            {
                context.UIExtensionSites[element.Path].Add(item);
            }
            Command cmd = BuilderUtility.GetCommand(context, element.Command);

            if (cmd != null) // 如果操作命令不为空则绑定命令
            {
                cmd.AddInvoker(item, "ItemClick");
            }

            // 注册此路径的插件
            if (register)
            {
                context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item);
            }
            return(item);
        }