예제 #1
0
        /// <summary>
        /// Handles the changes in the <see cref="Microsoft.Practices.CompositeUI.Commands.Command"/> by refreshing
        /// the <see cref="ToolStripItem.Enabled"/> property.
        /// </summary>
        protected override void OnCommandChanged(Microsoft.Practices.CompositeUI.Commands.Command command)
        {
            base.OnCommandChanged(command);

            foreach (KeyValuePair <ToolStripItem, List <string> > pair in Invokers)
            {
                pair.Key.Enabled = (command.Status == CommandStatus.Enabled);
                pair.Key.Visible = (command.Status != CommandStatus.Unavailable);
            }
        }
예제 #2
0
        /// <summary>
        /// 注册系统默认的UI组件
        /// </summary>
        private void RegisterUIElements()
        {
            IImageService imageService = RootWorkItem.Services.Get <IImageService>();

            if (imageService != null)
            {
                NavBarItem item = new NavBarItem("系统外观");
                item.LargeImage = imageService.GetBitmap("cubes", new System.Drawing.Size(32, 32));
                item.SmallImage = imageService.GetBitmap("cubes", new System.Drawing.Size(16, 16));
                RootWorkItem.UIExtensionSites[UIExtensionSiteNames.Shell_UI_NaviPane_DefaultSetting].Add(item);
                Microsoft.Practices.CompositeUI.Commands.Command cmd = RootWorkItem.Commands[CommandHandlerNames.CMD_SHOW_LAYOUTSETTING];
                if (cmd != null)
                {
                    cmd.AddInvoker(item, "LinkClicked");
                }
                cmd.Execute();
            }
        }
예제 #3
0
 /// <summary>
 /// Handles the <see cref="Command.Changed"/> event.
 /// </summary>
 /// <param name="command">The <see cref="Command"/> that fired the Changed event.</param>
 protected virtual void OnCommandChanged(Command command)
 {
 }
예제 #4
0
 public void AddElements(WorkItem workItem, IEnumerable <UICommandDefinition> menuEntryEnumerable, Control host)
 {
     foreach (UICommandDefinition definition in menuEntryEnumerable)
     {
         if (definition.IsCategoryOrFolder)
         {
             if (!workItem.UIExtensionSites.Contains(definition.Site + "." + definition.Name))
             {
                 if (definition.Parent != null)
                 {
                     Microsoft.Practices.CompositeUI.Commands.Command command = (workItem is LocalCommandWorkItem) ? AddShortcutCommand((LocalCommandWorkItem)workItem, definition, host) : AddCommand(workItem, definition, host);
                     UltraTreeNode uiElement = this.CreateTreeNode(workItem, definition);
                     workItem.UIExtensionSites[definition.Site].Add <UltraTreeNode>(uiElement);
                     command.AddInvoker(uiElement, "Click");
                     workItem.UIExtensionSites.RegisterSite(definition.Site + "." + definition.Name, uiElement.Nodes);
                 }
                 else if (!definition.HasFolderChild)
                 {
                     UltraExplorerBarGroup group = new UltraExplorerBarGroup
                     {
                         Tag  = definition,
                         Text = definition.Text
                     };
                     workItem.UIExtensionSites[definition.Site].Add <UltraExplorerBarGroup>(group);
                     workItem.UIExtensionSites.RegisterSite(definition.Site + "." + definition.Name, group.Items);
                     ((workItem is LocalCommandWorkItem) ? AddShortcutCommand((LocalCommandWorkItem)workItem, definition, host) : AddCommand(workItem, definition, host)).AddInvoker(group, "GroupClick");
                 }
                 else
                 {
                     this.CreateGroupTree(workItem, definition);
                 }
             }
         }
         else
         {
             Microsoft.Practices.CompositeUI.Commands.Command command3 = (workItem is LocalCommandWorkItem) ? AddShortcutCommand((LocalCommandWorkItem)workItem, definition, host) : AddCommand(workItem, definition, host);
             if (!definition.Parent.HasFolderChild)
             {
                 UltraExplorerBarItem item = new UltraExplorerBarItem
                 {
                     Text = definition.Text,
                     Tag  = definition
                 };
                 workItem.UIExtensionSites[definition.Site].Add <UltraExplorerBarItem>(item);
                 item.Settings.AppearancesSmall.Appearance.Image = this.GetImage(definition);
                 command3.AddInvoker(item, "ItemClick");
             }
             else
             {
                 UltraTreeNode node2 = this.CreateTreeNode(workItem, definition);
                 workItem.UIExtensionSites[definition.Site].Add <UltraTreeNode>(node2);
                 command3.AddInvoker(node2, "Click");
             }
         }
     }
     foreach (UICommandDefinition definition2 in menuEntryEnumerable)
     {
         Microsoft.Practices.CompositeUI.Commands.Command command4 = workItem.Commands[definition2.Name];
         if (!string.IsNullOrEmpty(definition2.PermissionName))
         {
             if (workItem.Services.Get <IAuthorizationService>().Authorize(Thread.CurrentPrincipal, definition2.PermissionName))
             {
                 command4.Status = CommandStatus.Enabled;
             }
             else
             {
                 command4.Status = CommandStatus.Unavailable;
             }
         }
         else
         {
             command4.Status = CommandStatus.Enabled;
         }
     }
 }