public virtual void Register(IMenuCommandService mcs)
 {
     var menuCommandID = new CommandID(GuidList.GuidEasyCodeCmdSet, CommandID);
     var menuCommand = new OleMenuCommand(ExcuteCommand, menuCommandID);
     menuCommand.BeforeQueryStatus += new EventHandler(menuCommand_BeforeQueryStatus);
     mcs.AddCommand(menuCommand);
 }
        /// <summary>
        /// Hook up the context menu handlers.
        /// </summary>
        public void Initialize(IMenuCommandService menuCommandService)
        {
            if (menuCommandService != null)
            {
                _addMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.AddAnalyzer, AddAnalyzerHandler);
                _projectAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectAddAnalyzer, AddAnalyzerHandler);
                _projectContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectContextAddAnalyzer, AddAnalyzerHandler);
                _referencesContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ReferencesContextAddAnalyzer, AddAnalyzerHandler);

                _removeMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.RemoveAnalyzer, RemoveAnalyzerHandler);

                _openRuleSetMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.OpenRuleSet, OpenRuleSetHandler);

                _setSeverityErrorMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityError, SetSeverityHandler);
                _setSeverityWarningMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityWarning, SetSeverityHandler);
                _setSeverityInfoMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityInfo, SetSeverityHandler);
                _setSeverityHiddenMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityHidden, SetSeverityHandler);
                _setSeverityNoneMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityNone, SetSeverityHandler);

                UpdateMenuItemVisibility();
                UpdateMenuItemsChecked();

                if (_tracker != null)
                {
                    _tracker.SelectedHierarchyChanged += SelectedHierarchyChangedHandler;
                    _tracker.SelectedDiagnosticItemsChanged += SelectedDiagnosticItemsChangedHandler;
                    _tracker.SelectedItemIdChanged += SelectedItemIdChangedHandler;
                }

                var buildManager = (IVsSolutionBuildManager)_serviceProvider.GetService(typeof(SVsSolutionBuildManager));
                uint cookie;
                buildManager.AdviseUpdateSolutionEvents(this, out cookie);
            }
        }
Beispiel #3
0
 public MenuConfigure(ConfigureMenuCallback configureMenuCallback, DisableMenuConfigure disableMenuConfigure, IMenuCommandService menuCommandService, MenuStatusChecker menuStatusChecker)
 {
     this.configureMenuCallback = configureMenuCallback;
     this.disableMenuConfigure = disableMenuConfigure;
     this.menuCommandService = menuCommandService;
     this.menuStatusChecker = menuStatusChecker;
 }
        public static void ShowContextMenu(IMenuCommandService service, Control owner, int x, int y)
        {
            var menu = new ContextMenuStrip();
            menu.Items.AddRange(GetMenuItems(service.Verbs));
            menu.Show(owner, x, y);

        }
 private void AddSuppressionsCommandHandlers(IMenuCommandService menuCommandService)
 {
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressions, delegate { }, OnAddSuppressionsStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressionsInSource, OnAddSuppressionsInSource, OnAddSuppressionsInSourceStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.AddSuppressionsInSuppressionFile, OnAddSuppressionsInSuppressionFile, OnAddSuppressionsInSuppressionFileStatus);
     AddCommand(menuCommandService, ID.RoslynCommands.RemoveSuppressions, OnRemoveSuppressions, OnRemoveSuppressionsStatus);
 }
 public CommandSet(ISite site)
 {
     this.site = site;
     this.eventService = (IEventHandlerService) site.GetService(typeof(IEventHandlerService));
     this.eventService.EventHandlerChanged += new EventHandler(this.OnEventHandlerChanged);
     IDesignerHost host = (IDesignerHost) site.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activated += new EventHandler(this.UpdateClipboardItems);
     }
     this.statusCommandUI = new StatusCommandUI(site);
     IUIService uiService = site.GetService(typeof(IUIService)) as IUIService;
     this.commandSet = new CommandSetItem[] {
         new CommandSetItem(this, new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut, uiService), new ImmediateCommandSetItem(this, new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusSelectAll), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), MenuCommands.DesignerProperties, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusPrimarySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight, true), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeLeft, true, uiService),
         new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeRight, true, uiService)
      };
     this.selectionService = (ISelectionService) site.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.menuService = (IMenuCommandService) site.GetService(typeof(IMenuCommandService));
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.AddCommand(this.commandSet[i]);
         }
     }
     IDictionaryService service = site.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service != null)
     {
         service.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0));
     }
 }
        private void InitializeCommands(XmlRepository repository, IConfiguration configuration, IMenuCommandService commandService)
        {
            var activeDocument = new ActiveDocument();

            var subMenu = CreateSubMenu(activeDocument);
            commandService.AddCommand(subMenu);

            var copyGenericXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyGenericXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyGenericXPathCommand);

            var copyAbsoluteXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyAbsoluteXPath, repository, activeDocument, () => new AbsoluteXPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyAbsoluteXPathCommand);

            var copyDistinctXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyDistinctXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes), new DistinctAttributeFilter(configuration.PreferredAttributeCandidates)}), new CommandTextFormatter());
            commandService.AddCommand(copyDistinctXPathCommand);

            var copySimplifiedXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopySimplifiedXPath, repository, activeDocument, () => new SimplifiedXPathWriter(new[] { new AttributeFilter(configuration.AlwaysDisplayedAttributes) }), new TrimCommandTextFormatter());
            commandService.AddCommand(copySimplifiedXPathCommand);

            var showXPathWorkbenchCommand = new ShowXPathWorkbenchCommand(this, commandService, Symbols.CommandIDs.ShowXPathWorkbench, repository, activeDocument);
            commandService.AddCommand(showXPathWorkbenchCommand.Command);

            var copyXmlStructureCommand = new CopyXmlStructureCommand(Symbols.CommandIDs.CopyXmlStructure, repository, activeDocument, () => new XmlStructureWriter(), new CommandTextFormatter());
            commandService.AddCommand(copyXmlStructureCommand);
        }
Beispiel #8
0
		public void AddTo (IMenuCommandService commands)
		{
			commands.AddCommand (new MenuCommand (Copy, StandardCommands.Copy));
			commands.AddCommand (new MenuCommand (Cut, StandardCommands.Cut));
			commands.AddCommand (new MenuCommand (Paste, StandardCommands.Paste));
			commands.AddCommand (new MenuCommand (Delete, StandardCommands.Delete));
			commands.AddCommand (new MenuCommand (SelectAll, StandardCommands.SelectAll));
		}
 private OleMenuCommand RegisterCommand(Guid guidId, int id, IMenuCommandService menuCommandService)
 {
     var menuCommandID = new CommandID(guidId, id);
     var menuItem = new OleMenuCommand(Exec, menuCommandID);
     menuItem.BeforeQueryStatus += QueryStatus;
     menuCommandService.AddCommand(menuItem);
     return menuItem;
 }
Beispiel #10
0
 public MenuConfigure(CurrentProjectFinder currentProjectFinder, ExceptionDialog exceptionDialog, ConfigureMenuCallback configureMenuCallback, DisableMenuConfigure disableMenuConfigure, IMenuCommandService menuCommandService)
 {
     this.exceptionDialog = exceptionDialog;
     this.configureMenuCallback = configureMenuCallback;
     this.disableMenuConfigure = disableMenuConfigure;
     this.menuCommandService = menuCommandService;
     this.currentProjectFinder = currentProjectFinder;
 }
			public ORMModelBrowserCommandSet(IServiceProvider provider, IMenuCommandService menuService)
			{
				myServiceProvider = provider;
				myMenuService = menuService;
				#region command array
				myCommands = new MenuCommand[]{
					new DynamicStatusMenuCommand(
					new EventHandler(OnStatusDelete),
					new EventHandler(OnMenuDelete),
					StandardCommands.Delete)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusEditLabel),
					new EventHandler(OnMenuEditLabel),
					EditLabelCommandID)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusExclusiveOrDecoupler),
					new EventHandler(OnMenuExclusiveOrDecoupler),
					ORMDesignerDocView.ORMDesignerCommandIds.ExclusiveOrDecoupler)
					,new DynamicDiagramCommand(
					new EventHandler(OnStatusDiagramList),
					new EventHandler(OnMenuDiagramList),
					ORMDesignerDocView.ORMDesignerCommandIds.DiagramList)
					,new DynamicDiagramCommand(
					new EventHandler(OnStatusDiagramList),
					new EventHandler(OnMenuDiagramSpyDiagramList),
					ORMDesignerDocView.ORMDesignerCommandIds.DiagramSpyDiagramList)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusSelectShapeInDocumentWindow),
					new EventHandler(OnMenuSelectShapeInDocumentWindow),
					ORMDesignerDocView.ORMDesignerCommandIds.SelectInDocumentWindow)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusSelectShapeInDiagramSpy),
					new EventHandler(OnMenuSelectShapeInDiagramSpy),
					ORMDesignerDocView.ORMDesignerCommandIds.SelectInDiagramSpy)
					,new DynamicFreeFormCommand(
					new EventHandler(OnStatusFreeFormCommand),
					new EventHandler(OnMenuFreeFormCommand),
					ORMDesignerDocView.ORMDesignerCommandIds.FreeFormCommandList)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusIncludeInGroup),
					new EventHandler(OnMenuIncludeInGroup),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInGroup)
					,new DynamicStatusMenuCommand(
					new EventHandler(OnStatusIncludeInNewGroup),
					new EventHandler(OnMenuIncludeInNewGroup),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInNewGroup)
					,new DynamicIncludeInGroupCommand(
					new EventHandler(OnStatusIncludeInGroupList),
					new EventHandler(OnMenuIncludeInGroupList),
					ORMDesignerDocView.ORMDesignerCommandIds.IncludeInGroupList)
					,new DynamicDeleteFromGroupCommand(
					new EventHandler(OnStatusDeleteFromGroupList),
					new EventHandler(OnMenuDeleteFromGroupList),
					ORMDesignerDocView.ORMDesignerCommandIds.DeleteFromGroupList)
				};
				#endregion //command array
				AddCommands(myCommands);
			}
        protected override void Initialize()
        {
            base.Initialize();

            _menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell;

            AddMenuCommand(CommandIds.TotalCommander, HandleTotalCommanderMenuCommand, options => true);
        }
 public DesignerActionKeyboardBehavior(DesignerActionPanel panel, IServiceProvider serviceProvider, BehaviorService behaviorService) : base(true, behaviorService)
 {
     this.panel = panel;
     if (serviceProvider != null)
     {
         this.menuService = serviceProvider.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
         this.daUISvc = serviceProvider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
     }
 }
 public CompareToBranchCommand(IMenuCommandService menuCommandService, ILogger _logger, ITFSVersionControl _tfs)
 {
     branches = new List<string>();
     logger = _logger;
     tfsVersionControl = _tfs;
     CommandID compareToBranchId = new CommandID(GuidList.guidTFSProductivityPackCmdSet, PkgCmdIDList.cmdIdDynamicCompareToBranchCommand);
     compareToBranchOleCommand = new OleDynamicCommand(compareToBranchId, IsValidDynamicItem, Exec, QueryStatus);
     menuCommandService.AddCommand(compareToBranchOleCommand);
 }
 /// <summary>
 /// Add a command handler and status query handler for a menu item
 /// </summary>
 private static OleMenuCommand AddCommand(
     IMenuCommandService menuCommandService,
     int commandId,
     EventHandler invokeHandler,
     EventHandler beforeQueryStatus)
 {
     var commandIdWithGroupId = new CommandID(Guids.RoslynGroupId, commandId);
     var command = new OleMenuCommand(invokeHandler, delegate { }, beforeQueryStatus, commandIdWithGroupId);
     menuCommandService.AddCommand(command);
     return command;
 }
 public ShowXPathWorkbenchCommand(Package package, IMenuCommandService commandService, int id, XmlRepository repository, ActiveDocument activeDocument)
 {
     _package = package;
     _repository = repository;
     _activeDocument = activeDocument;
     if(commandService == null)
     {
         throw new ArgumentNullException(nameof(commandService));
     }
     var menuCommandID = new CommandID(Guid.Parse(Symbols.PackageID), id);
     Command = new OleMenuCommand(ShowToolWindow, null, OnBeforeQueryStatus, menuCommandID, PackageResources.ShowXPathWorkbenchCommandText);
 }
        public override void AddCommandHandlers(IMenuCommandService menuCommandService)
        {
            //ModelExplorerCut = new CommandID(GuidSymbol, CutIDSymbol);
            ModelExplorerCopy = new CommandID(GuidSymbol, CopyIDSymbol);
            ModelExplorerPaste = new CommandID(GuidSymbol, PasteIDSymbol);

            //menuCommandService.AddCommand(
            //    new DynamicStatusMenuCommand(new EventHandler(OnStatusCut), new EventHandler(OnMenuCut), ModelExplorerCut));
            menuCommandService.AddCommand(
                new DynamicStatusMenuCommand(new EventHandler(OnStatusCopy), new EventHandler(OnMenuCopy), ModelExplorerCopy));
            menuCommandService.AddCommand(
                new DynamicStatusMenuCommand(new EventHandler(OnStatusPaste), new EventHandler(OnMenuPaste), ModelExplorerPaste));

            base.AddCommandHandlers(menuCommandService);
        }
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            if (Control is SettingsTree)
            {
                designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
                menuService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
                selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                settingsTree = Control as SettingsTree;
                settingsTree.TreeView.AfterSelect += OnNodeSelect;
            }


        }
        public PackageCommandManager(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            this.serviceProvider = serviceProvider;

            this.menuService = this.serviceProvider.GetService<IMenuCommandService>();
            if (this.menuService == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.MissingService, nameof(IMenuCommandService)), nameof(serviceProvider));
            }
        }
 public CommandSet(IServiceProvider serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     this.menuCommandService = (IMenuCommandService) this.serviceProvider.GetService(typeof(IMenuCommandService));
     if (this.menuCommandService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IMenuCommandService).FullName }));
     }
     this.workflowView = serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
     if (this.workflowView == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(WorkflowView).FullName }));
     }
     this.selectionService = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService));
     if (this.selectionService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ISelectionService).FullName }));
     }
     this.commandSet = new List<System.Workflow.ComponentModel.Design.CommandSetItem>();
     this.commandSet.AddRange(new System.Workflow.ComponentModel.Design.CommandSetItem[] { 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSaveWorkflowAsImage), WorkflowMenuCommands.SaveAsImage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuCopyToClipboard), WorkflowMenuCommands.CopyToClipboard), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPrint), new EventHandler(this.OnMenuPrint), WorkflowMenuCommands.Print), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPageSetup), new EventHandler(this.OnMenuPageSetup), WorkflowMenuCommands.PageSetup), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), WorkflowMenuCommands.DesignerProperties), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnViewCode), new CommandID(StandardCommands.Cut.Guid, 0x14d)), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft), 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectNext), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectPrevious), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Expand), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Collapse), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Disable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Enable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnCreateTheme), WorkflowMenuCommands.CreateTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnChangeTheme), WorkflowMenuCommands.ChangeTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageDown)
      });
     this.zoomCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom400Mode, DR.GetString("Zoom400Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom300Mode, DR.GetString("Zoom300Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom200Mode, DR.GetString("Zoom200Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom150Mode, DR.GetString("Zoom150Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom100Mode, DR.GetString("Zoom100Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom75Mode, DR.GetString("Zoom75Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom50Mode, DR.GetString("Zoom50Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.ShowAll, DR.GetString("ZoomShowAll", new object[0])) };
     this.commandSet.AddRange(this.zoomCommands);
     this.layoutCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.DefaultPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreviewPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreview) };
     this.commandSet.AddRange(this.layoutCommands);
     this.navigationToolCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[0]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[1]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[2]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[3]) };
     this.commandSet.AddRange(this.navigationToolCommands);
     for (int i = 0; i < this.commandSet.Count; i++)
     {
         if (this.menuCommandService.FindCommand(this.commandSet[i].CommandID) == null)
         {
             this.menuCommandService.AddCommand(this.commandSet[i]);
         }
     }
     IComponentChangeService service = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     if (service != null)
     {
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     IDictionaryService service2 = this.serviceProvider.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service2 != null)
     {
         service2.SetValue(typeof(CommandID), new CommandID(new Guid("5f1c3c8d-60f1-4b98-b85b-8679f97e8eac"), 0));
     }
 }
 public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorner)
 {
     this.serviceProvider = serviceProvider;
     this.designerActionAdorner = containerAdorner;
     this.behaviorService = (BehaviorService) serviceProvider.GetService(typeof(BehaviorService));
     this.menuCommandService = (IMenuCommandService) serviceProvider.GetService(typeof(IMenuCommandService));
     this.selSvc = (ISelectionService) serviceProvider.GetService(typeof(ISelectionService));
     if ((this.behaviorService != null) && (this.selSvc != null))
     {
         this.designerActionService = (DesignerActionService) serviceProvider.GetService(typeof(DesignerActionService));
         if (this.designerActionService == null)
         {
             this.designerActionService = new DesignerActionService(serviceProvider);
             this.disposeActionService = true;
         }
         this.designerActionUIService = (DesignerActionUIService) serviceProvider.GetService(typeof(DesignerActionUIService));
         if (this.designerActionUIService == null)
         {
             this.designerActionUIService = new DesignerActionUIService(serviceProvider);
             this.disposeActionUIService = true;
         }
         this.designerActionUIService.DesignerActionUIStateChange += new DesignerActionUIStateChangeEventHandler(this.OnDesignerActionUIStateChange);
         this.designerActionService.DesignerActionListsChanged += new DesignerActionListsChangedEventHandler(this.OnDesignerActionsChanged);
         this.lastPanelComponent = null;
         IComponentChangeService service = (IComponentChangeService) serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (this.menuCommandService != null)
         {
             this.cmdShowDesignerActions = new MenuCommand(new EventHandler(this.OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag);
             this.menuCommandService.AddCommand(this.cmdShowDesignerActions);
         }
         this.uiService = (IUIService) serviceProvider.GetService(typeof(IUIService));
         if (this.uiService != null)
         {
             this.mainParentWindow = this.uiService.GetDialogOwnerWindow();
         }
         this.componentToGlyph = new Hashtable();
         this.marshalingControl = new Control();
         this.marshalingControl.CreateControl();
     }
 }
        public static void Bind(IMenuCommandService menuCommandService)
        {
            var menuHandlers = IoC.GetInstances<IMenuCommandHandler>();

            foreach (IMenuCommandHandler menuCommandHandler in menuHandlers)
            {
                var handlesCommandAttributes = (HandlesMenuCommandAttribute[])menuCommandHandler.GetType().GetCustomAttributes(typeof(HandlesMenuCommandAttribute), false);

                IEnumerable<int> coomandIdentifiers = handlesCommandAttributes.SelectMany(attr => attr.CommandIdentifiers);

                foreach (int commandId in coomandIdentifiers)
                {
                    var menuCommandId = new CommandID(Identifiers.CommandGroupId, commandId);
                    var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId);
                    menuItem.BeforeQueryStatus += OnBeforeQueryStatus;

                    menuCommandService.AddCommand(menuItem);
                }
            }
        }
        public static void Bind(IMenuCommandService menuCommandService)
        {
            var menuHandlers = IoC.GetInstances<IComboBoxCommandHandler>();

            foreach (IComboBoxCommandHandler handler in menuHandlers)
            {
                var handlesComboBoxdAttributes = (HandlesComboBoxCommandAttribute[])handler.GetType().GetCustomAttributes(typeof(HandlesComboBoxCommandAttribute), false);

                foreach (HandlesComboBoxCommandAttribute attribute in handlesComboBoxdAttributes)
                {
                    var requestItemsCommandId = new CommandID(Identifiers.CommandGroupId, attribute.RequestItemsCommandId);
                    var menuItem = new OleMenuCommand(ProvideItemsCallback, requestItemsCommandId);
                    menuCommandService.AddCommand(menuItem);

                    var itemSelectionCommandId = new CommandID(Identifiers.CommandGroupId, attribute.SelectionCommandId);
                    var itemSelectionMenuItem = new OleMenuCommand(ItemSelectionCallback, itemSelectionCommandId);
                    menuCommandService.AddCommand(itemSelectionMenuItem);
                }
            }
        }
        /// <summary>
        /// Hook up the context menu handlers.
        /// </summary>
        public void Initialize(IMenuCommandService menuCommandService)
        {
            if (menuCommandService != null)
            {
                // Analyzers folder context menu items
                _addMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.AddAnalyzer, AddAnalyzerHandler);
                _openRuleSetMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.OpenRuleSet, OpenRuleSetHandler);

                // Analyzer context menu items
                _removeMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.RemoveAnalyzer, RemoveAnalyzerHandler);

                // Diagnostic context menu items
                _setSeverityDefaultMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityDefault, SetSeverityHandler);
                _setSeverityErrorMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityError, SetSeverityHandler);
                _setSeverityWarningMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityWarning, SetSeverityHandler);
                _setSeverityInfoMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityInfo, SetSeverityHandler);
                _setSeverityHiddenMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityHidden, SetSeverityHandler);
                _setSeverityNoneMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetSeverityNone, SetSeverityHandler);
                _openHelpLinkMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.OpenDiagnosticHelpLink, OpenDiagnosticHelpLinkHandler);

                // Other menu items
                _projectAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectAddAnalyzer, AddAnalyzerHandler);
                _projectContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ProjectContextAddAnalyzer, AddAnalyzerHandler);
                _referencesContextAddMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.ReferencesContextAddAnalyzer, AddAnalyzerHandler);
                _setActiveRuleSetMenuItem = AddCommandHandler(menuCommandService, ID.RoslynCommands.SetActiveRuleSet, SetActiveRuleSetHandler);

                UpdateOtherMenuItemsVisibility();

                if (_tracker != null)
                {
                    _tracker.SelectedHierarchyItemChanged += SelectedHierarchyItemChangedHandler;
                }

                var buildManager = (IVsSolutionBuildManager)_serviceProvider.GetService(typeof(SVsSolutionBuildManager));
                uint cookie;
                buildManager.AdviseUpdateSolutionEvents(this, out cookie);
            }
        }
Beispiel #25
0
        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg != keyPressedMessage /*&& m.Msg != leftMouseButtonDownMessage*/)
            {
                return(false);
            }

            FormsDesignerViewContent formDesigner = VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.Designer;//roman//

            if (formDesigner == null || formDesigner.Host == null)
            {
                return(false);
            }
            if (formDesigner.UserContent != null && !((Control)formDesigner.UserContent).ContainsFocus)
            {
                return(false);
            }

            Control originControl = Control.FromChildHandle(m.HWnd);

            if (originControl != null && formDesigner.UserContent != null && !(formDesigner.UserContent == originControl || formDesigner.UserContent.Contains(originControl)))
            {
                // Ignore if message origin not in forms designer
                // (e.g. navigating the main menu)
                return(false);
            }

            Keys keyPressed = (Keys)m.WParam.ToInt32() | Control.ModifierKeys;

            if (keyPressed == Keys.Escape)
            {
                if (formDesigner.IsTabOrderMode)
                {
                    formDesigner.HideTabOrder();
                    return(true);
                }
            }

            CommandWrapper commandWrapper;

            if (keyTable.TryGetValue(keyPressed, out commandWrapper))
            {
                if (commandWrapper.CommandID == MenuCommands.Delete)
                {
                    // Check Delete menu is enabled.
                    if (!formDesigner.EnableDelete)
                    {
                        return(false);
                    }
                }
                //roman//
                if (commandWrapper.CommandID == MenuCommands.Copy || commandWrapper.CommandID == MenuCommands.Cut)
                {
                    if ((formDesigner.Host.GetService(typeof(ISelectionService)) as ISelectionService).GetComponentSelected(formDesigner.Host.RootComponent))
                    {
                        return(false);
                    }
                }

                //roman//
                LoggingService.Debug("Run menu command: " + commandWrapper.CommandID);

                IMenuCommandService menuCommandService = (IMenuCommandService)formDesigner.Host.GetService(typeof(IMenuCommandService));
                ISelectionService   selectionService   = (ISelectionService)formDesigner.Host.GetService(typeof(ISelectionService));
                ICollection         components         = selectionService.GetSelectedComponents();
                if (components.Count == 1)
                {
                    foreach (IComponent component in components)
                    {
                        if (HandleMenuCommand(formDesigner, component, keyPressed))
                        {
                            return(false);
                        }
                    }
                }

                menuCommandService.GlobalInvoke(commandWrapper.CommandID);

                if (commandWrapper.RestoreSelection)
                {
                    selectionService.SetSelectedComponents(components);
                }
                return(true);
            }

            return(false);
        }
        public TabOrder(IDesignerHost host)
        {
            this.host = host;
            IUIService service = (IUIService)host.GetService(typeof(IUIService));

            if (service != null)
            {
                this.tabFont = (Font)service.Styles["DialogFont"];
            }
            else
            {
                this.tabFont = Control.DefaultFont;
            }
            this.tabFont            = new Font(this.tabFont, FontStyle.Bold);
            this.selSize            = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;
            this.drawString         = new StringBuilder(12);
            this.highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            this.highlightPen       = new Pen(SystemColors.Highlight);
            NumberFormatInfo format = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (format != null)
            {
                this.decimalSep = format.NumberDecimalSeparator;
            }
            else
            {
                this.decimalSep = ".";
            }
            this.tabProperties = new Hashtable();
            base.SetStyle(ControlStyles.Opaque, true);
            IOverlayService service2 = (IOverlayService)host.GetService(typeof(IOverlayService));

            if (service2 != null)
            {
                service2.PushOverlay(this);
            }
            IHelpService service3 = (IHelpService)host.GetService(typeof(IHelpService));

            if (service3 != null)
            {
                service3.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }
            this.commands    = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveUp), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveDown), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveLeft), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveRight), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeySelectNext), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeySelectPrevious) };
            this.newCommands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyTabOrderSelect) };
            IMenuCommandService service4 = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (service4 != null)
            {
                foreach (MenuCommand command in this.newCommands)
                {
                    service4.AddCommand(command);
                }
            }
            IEventHandlerService service5 = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (service5 != null)
            {
                service5.PushHandler(this);
            }
            IComponentChangeService service6 = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (service6 != null)
            {
                service6.ComponentAdded   += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentRemoved += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
        }
Beispiel #27
0
        public static async Task InitializeAsync(AsyncPackage package, IMenuCommandService commandService)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            Instance = new SendMethodCommand(package, commandService);
        }
Beispiel #28
0
        public QuickStartControl(IMenuCommandService service)
        {
            this.service = service;

            this.InitializeComponent();
        }
Beispiel #29
0
 public SetUtf8WithBomCommand(IMenuCommandService menuCommandService)
     : base(menuCommandService, CommandSets.MenuGroupGuid, CommandSets.Ids.SetEncodingToUtf8WithBom)
 {
 }
Beispiel #30
0
        public static void Initialize(AsyncPackage package, IMenuCommandService commandService)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Instance = new MyButton(package, commandService);
        }
        public void Cut()
        {
            IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));

            menuCommandService.GlobalInvoke(StandardCommands.Cut);
        }
 public MenuCommandListWirer(IMenuCommandService menuCommandService, List <MenuCommand> menuCommands, Func <bool> shouldDisplay)
 {
     _menuCommandService = menuCommandService;
     _menuCommands       = menuCommands;
     _shouldDisplay      = shouldDisplay;
 }
 public AnalyzeSolutionCommand(IMenuCommandService menuCommandService)
     : base(menuCommandService, SariferPackageCommandIds.AnalyzeSolution)
 {
 }
Beispiel #34
0
 public PackageCommands(IServiceProvider serviceProvider)
 {
     _dte = serviceProvider.GetService <EnvDTE.DTE>();
     _mcs = serviceProvider.GetService <IMenuCommandService>();
 }
 public static void Initialize(IMenuCommandService commandService) =>
 Instance = new InstructionSetSelector(commandService);
 public ShowPackageListCommand(Package package, IMenuCommandService commandService, IDialogService dialogService)
     : base(commandService, dialogService) => _package = package;
Beispiel #37
0
 public ConanAbout(
     IMenuCommandService commandService,
     Core.IErrorListService errorListService)
     : base(commandService, errorListService)
 {
 }
 public FindInSCEFromCodeWindowCommand(IMenuCommandService menuCommandService, ILogger _logger, DTE2 _dte, ITFSVersionControl _tfs)
     : base(GuidList.guidTFSProductivityPackCmdSet, PkgCmdIDList.cmdIdFindInSCEFromCodeWindow, menuCommandService, _logger, _dte, _tfs)
 {
 }
Beispiel #39
0
        private void PerformAction(string text)
        {
            if (this.GetCurrentHost() == null)
            {
                return;
            }

            IMenuCommandService ims = this.GetCurrentHost().HostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            try
            {
                switch (text)
                {
                case "剪切(&T)":
                    ims.GlobalInvoke(StandardCommands.Cut);
                    break;

                case "复制(&C)":
                    ims.GlobalInvoke(StandardCommands.Copy);
                    break;

                case "粘贴(&P)":
                    ims.GlobalInvoke(StandardCommands.Paste);
                    break;

                case "撤消(&U)":
                    ims.GlobalInvoke(StandardCommands.Undo);
                    break;

                case "重复(&R)":
                    ims.GlobalInvoke(StandardCommands.Redo);
                    break;

                case "删除(&D)":
                    ims.GlobalInvoke(StandardCommands.Delete);
                    break;

                case "删除":
                    ims.GlobalInvoke(StandardCommands.Delete);
                    break;

                case "全选(&S)":
                    ims.GlobalInvoke(StandardCommands.SelectAll);
                    break;

                case "左对齐":
                    ims.GlobalInvoke(StandardCommands.AlignLeft);
                    break;

                case "居中对齐":
                    ims.GlobalInvoke(StandardCommands.AlignHorizontalCenters);
                    break;

                case "右对齐":
                    ims.GlobalInvoke(StandardCommands.AlignRight);
                    break;

                case "顶端对齐":
                    ims.GlobalInvoke(StandardCommands.AlignTop);
                    break;

                case "中间对齐":
                    ims.GlobalInvoke(StandardCommands.AlignVerticalCenters);
                    break;

                case "底端对齐":
                    ims.GlobalInvoke(StandardCommands.AlignBottom);
                    break;

                case "垂直间距相等":
                    ims.GlobalInvoke(StandardCommands.VertSpaceMakeEqual);
                    break;

                case "水平间距相等":
                    ims.GlobalInvoke(StandardCommands.HorizSpaceMakeEqual);
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "错误");
            }
        }
        public bool PreFilterMessage(ref Message m)
        {
            if (host == null)
            {
                return(false);
            }

            if (m.Msg == 256 /*0x0100 WM_KEYDOWN*/)
            {
                IMenuCommandService mcs = host.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

                switch (((int)m.WParam) | ((int)Control.ModifierKeys))
                {
                case (int)Keys.Up: mcs.GlobalInvoke(MenuCommands.KeyMoveUp);
                    return(true);

                case (int)Keys.Down: mcs.GlobalInvoke(MenuCommands.KeyMoveDown);
                    return(true);

                case (int)Keys.Right: mcs.GlobalInvoke(MenuCommands.KeyMoveRight);
                    return(true);

                case (int)Keys.Left: mcs.GlobalInvoke(MenuCommands.KeyMoveLeft);
                    return(true);

                case (int)Keys.Enter:
                    ITU.enterKeyPressed = true;
                    return(false);

                case (int)(Keys.Control | Keys.Up): mcs.GlobalInvoke(MenuCommands.KeyNudgeUp);
                    return(true);

                case (int)(Keys.Control | Keys.Down): mcs.GlobalInvoke(MenuCommands.KeyNudgeDown);
                    return(true);

                case (int)(Keys.Control | Keys.Right): mcs.GlobalInvoke(MenuCommands.KeyNudgeRight);
                    return(true);

                case (int)(Keys.Control | Keys.Left): mcs.GlobalInvoke(MenuCommands.KeyNudgeLeft);
                    return(true);

                case (int)(Keys.Shift | Keys.Up): mcs.GlobalInvoke(MenuCommands.KeySizeHeightDecrease);
                    return(true);

                case (int)(Keys.Shift | Keys.Down): mcs.GlobalInvoke(MenuCommands.KeySizeHeightIncrease);
                    return(true);

                case (int)(Keys.Shift | Keys.Right): mcs.GlobalInvoke(MenuCommands.KeySizeWidthIncrease);
                    return(true);

                case (int)(Keys.Shift | Keys.Left): mcs.GlobalInvoke(MenuCommands.KeySizeWidthDecrease);
                    return(true);

                case (int)(Keys.Control | Keys.Shift | Keys.Up): mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightDecrease);
                    return(true);

                case (int)(Keys.Control | Keys.Shift | Keys.Down): mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightIncrease);
                    return(true);

                case (int)(Keys.Control | Keys.Shift | Keys.Right): mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthIncrease);
                    return(true);

                case (int)(Keys.ControlKey | Keys.Shift | Keys.Left): mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthDecrease);
                    return(true);
                }
            }
            else if (m.Msg == 257 /*0x0101 WM_KEYUP*/)
            {
                switch (((int)m.WParam) | ((int)Control.ModifierKeys))
                {
                case (int)Keys.Enter:
                    ITU.enterKeyPressed = false;
                    return(false);
                }
            }
            return(false);
        }
 public CommandRegistrator(IMenuCommandService menuCommandService, IAppServices appServices)
 {
     _menuCommandService = menuCommandService;
     _appServices        = appServices;
 }
Beispiel #42
0
        //
        //
        //
        private void menuItem_Click(object sender, System.EventArgs e)
        {
            // The IMenuCommandService makes doing common commands easy.
            // It keeps track of what commands and verbs the designer supports
            // and can invoke them given members of the MenuCommands enum (CommandID's).
            IServiceContainer   sc  = host as IServiceContainer;
            IMenuCommandService mcs = sc.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            switch ((sender as MenuItem).Text)
            {
            case "Cu&t":
                mcs.GlobalInvoke(StandardCommands.Cut);
                break;

            case "&Copy":
                mcs.GlobalInvoke(StandardCommands.Copy);
                break;

            case "&Paste":
                mcs.GlobalInvoke(StandardCommands.Paste);
                break;

            case "&Delete":
                mcs.GlobalInvoke(StandardCommands.Delete);
                break;

            case "Select &All":
                mcs.GlobalInvoke(StandardCommands.SelectAll);
                break;

            case "&Service Requests":
                if (serviceRequests == null)
                {
                    serviceRequests         = new ServiceRequests();
                    serviceRequests.Closed += new EventHandler(OnServiceRequestsClosed);

                    // Our designer host looks for this service to announce the success / failure
                    // of service requests.
                    hostingServiceContainer.AddService(typeof(ServiceRequests), serviceRequests);
                    serviceRequests.Show();
                }
                serviceRequests.Activate();
                break;

            case "&Design":
                tabControl.SelectedTab = tabDesign;
                break;

            case "&C# Source":
                tabControl.SelectedTab = tabCS;
                break;

            case "&VB Source":
                tabControl.SelectedTab = tabVB;
                break;

            case "&XML":
                tabControl.SelectedTab = tabXML;
                break;

            case "&Properties":
                mcs.GlobalInvoke(MenuCommands.Properties);
                break;

            case "Show &Grid":
                mcs.GlobalInvoke(StandardCommands.ShowGrid);
                menuItemShowGrid.Checked = !menuItemShowGrid.Checked;
                break;

            case "S&nap to Grid":
                mcs.GlobalInvoke(StandardCommands.SnapToGrid);
                menuItemSnapToGrid.Checked = !menuItemSnapToGrid.Checked;
                break;

            case "&Lefts":
                mcs.GlobalInvoke(StandardCommands.AlignLeft);
                break;

            case "&Rights":
                mcs.GlobalInvoke(StandardCommands.AlignRight);
                break;

            case "&Tops":
                mcs.GlobalInvoke(StandardCommands.AlignTop);
                break;

            case "&Bottoms":
                mcs.GlobalInvoke(StandardCommands.AlignBottom);
                break;

            case "&Middles":
                mcs.GlobalInvoke(StandardCommands.AlignHorizontalCenters);
                break;

            case "&Centers":
                mcs.GlobalInvoke(StandardCommands.AlignVerticalCenters);
                break;

            case "to &Grid":
                mcs.GlobalInvoke(StandardCommands.AlignToGrid);
                break;

            case "&Horizontally":
                mcs.GlobalInvoke(StandardCommands.CenterHorizontally);
                break;

            case "&Vertically":
                mcs.GlobalInvoke(StandardCommands.CenterVertically);
                break;

            case "&Control":
                mcs.GlobalInvoke(StandardCommands.SizeToControl);
                break;

            case "Control &Width":
                mcs.GlobalInvoke(StandardCommands.SizeToControlWidth);
                break;

            case "Control &Height":
                mcs.GlobalInvoke(StandardCommands.SizeToControlHeight);
                break;

            case "&Grid":
                mcs.GlobalInvoke(StandardCommands.SizeToGrid);
                break;

            case "&Bring to Front":
                mcs.GlobalInvoke(StandardCommands.BringToFront);
                break;

            case "&Send to Back":
                mcs.GlobalInvoke(StandardCommands.SendToBack);
                break;

            case "&Tab Order":
                mcs.GlobalInvoke(StandardCommands.TabOrder);
                break;
            }
        }
        public bool PreFilterMessage(ref Message m)
        {
            // Catch WM_KEYCHAR if the designerView has focus
            if ((m.Msg == 0x0100) && (((EtoDesignerHost)host).View.Focused))
            {
                IMenuCommandService mcs = host.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

                // WM_KEYCHAR only tells us the last key pressed. Thus we check
                // Control for modifier keys (Control, Shift, etc.)
                //
                switch (((int)m.WParam) | ((int)Control.ModifierKeys))
                {
                case (int)Keys.Up:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveUp);
                    break;

                case (int)Keys.Down:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveDown);
                    break;

                case (int)Keys.Right:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveRight);
                    break;

                case (int)Keys.Left:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveLeft);
                    break;

                case (int)(Keys.Control | Keys.Up):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeUp);
                    break;

                case (int)(Keys.Control | Keys.Down):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeDown);
                    break;

                case (int)(Keys.Control | Keys.Right):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeRight);
                    break;

                case (int)(Keys.Control | Keys.Left):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeLeft);
                    break;

                case (int)(Keys.Shift | Keys.Up):
                    mcs.GlobalInvoke(MenuCommands.KeySizeHeightIncrease);
                    break;

                case (int)(Keys.Shift | Keys.Down):
                    mcs.GlobalInvoke(MenuCommands.KeySizeHeightDecrease);
                    break;

                case (int)(Keys.Shift | Keys.Right):
                    mcs.GlobalInvoke(MenuCommands.KeySizeWidthIncrease);
                    break;

                case (int)(Keys.Shift | Keys.Left):
                    mcs.GlobalInvoke(MenuCommands.KeySizeWidthDecrease);
                    break;

                case (int)(Keys.Control | Keys.Shift | Keys.Up):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightIncrease);
                    break;

                case (int)(Keys.Control | Keys.Shift | Keys.Down):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightDecrease);
                    break;

                case (int)(Keys.Control | Keys.Shift | Keys.Right):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthIncrease);
                    break;

                case (int)(Keys.ControlKey | Keys.Shift | Keys.Left):
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthDecrease);
                    break;

                case (int)(Keys.Escape):
                    mcs.GlobalInvoke(MenuCommands.KeyCancel);
                    break;

                case (int)(Keys.Shift | Keys.Escape):
                    mcs.GlobalInvoke(MenuCommands.KeyReverseCancel);
                    break;

                case (int)(Keys.Enter):
                    mcs.GlobalInvoke(MenuCommands.KeyDefaultAction);
                    break;
                }
            }
            // Never filter the message
            return(false);
        }
Beispiel #44
0
        void AddCommandWithEnableFlag(IMenuCommandService mcs, OleMenuCommand command, UDNDocRunningTableMonitor rdtm)
        {
            command.BeforeQueryStatus += new EventHandler((sender, args) =>
            {
                var cmd = sender as OleMenuCommand;
                cmd.Enabled = (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownRebuildDoxygenDatabase)
                                  ? (!_doxygenIsRebuilding && rdtm.CommandsEnabled)
                                  : rdtm.CommandsEnabled;
                cmd.Visible = rdtm.CommandsEnabled;
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownDisableParsing)
                {
                    cmd.Checked = Settings.Default.DisableAllParsing;
                }
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownDisableHighlighting)
                {
                    cmd.Enabled = !Settings.Default.DisableAllParsing;  //Turn off the highlighting button when full parsing is disabled
                    cmd.Checked = Settings.Default.DisableHighlighting;
                }
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownPreviewWindow)
                {
                    cmd.Enabled = !Settings.Default.DisableAllParsing;
                }
                
            });

            mcs.AddCommand(command);
        }
        public bool PreFilterMessage(ref Message m)
        {
            if ((m.Msg == 0x100) && ((SampleDesignerHost)this.host).View.Focused)
            {
                IMenuCommandService mcs = this.host.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
                switch ((((int)m.WParam) | (int)Control.ModifierKeys))
                {
                case 0x25:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveLeft);
                    break;

                case 0x26:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveUp);
                    break;

                case 0x27:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveRight);
                    break;

                case 40:
                    mcs.GlobalInvoke(MenuCommands.KeyMoveDown);
                    break;

                case 0x1001b:
                    mcs.GlobalInvoke(MenuCommands.KeyReverseCancel);
                    break;

                case 13:
                    mcs.GlobalInvoke(MenuCommands.KeyDefaultAction);
                    break;

                case 0x1b:
                    mcs.GlobalInvoke(MenuCommands.KeyCancel);
                    break;

                case 0x10025:
                    mcs.GlobalInvoke(MenuCommands.KeySizeWidthDecrease);
                    break;

                case 0x10026:
                    mcs.GlobalInvoke(MenuCommands.KeySizeHeightIncrease);
                    break;

                case 0x10027:
                    mcs.GlobalInvoke(MenuCommands.KeySizeWidthIncrease);
                    break;

                case 0x10028:
                    mcs.GlobalInvoke(MenuCommands.KeySizeHeightDecrease);
                    break;

                case 0x10035:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthDecrease);
                    break;

                case 0x20025:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeLeft);
                    break;

                case 0x20026:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeUp);
                    break;

                case 0x20027:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeRight);
                    break;

                case 0x20028:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeDown);
                    break;

                case 0x30026:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightIncrease);
                    break;

                case 0x30027:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeWidthIncrease);
                    break;

                case 0x30028:
                    mcs.GlobalInvoke(MenuCommands.KeyNudgeHeightDecrease);
                    break;
                }
            }
            return(false);
        }
Beispiel #46
0
        void InitializePublishFlagButtons(IMenuCommandService mcs, UDNDocRunningTableMonitor rdtm)
        {
            //InitializePublishFlagButton(mcs, rdtm, GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPublishList, .Trim());

            var availabilityStrings = Settings.Default.SupportedAvailabilitiesString.Split(',').ToList();
            availabilityStrings.Insert(0, Settings.Default.PublicAvailabilitiesString);

            int i = 0;
            foreach (var availabilityString in availabilityStrings)
            {
                InitializePublishFlagButton(mcs, rdtm, GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPublishList + i + 1, availabilityStrings[i].Trim());
                ++i;
            }
        }
Beispiel #47
0
 public CommandRegistrant(IMenuCommandService menuCommandService, IContainer container)
 {
     _menuCommandService = menuCommandService;
     _container          = container;
 }
Beispiel #48
0
 public FindInSolExpFromSCECommand(IMenuCommandService menuCommandService, ILogger _logger, DTE2 _dte, ITFSVersionControl _tfs)
     : base(GuidList.guidTFSProductivityPackCmdSet, PkgCmdIDList.cmdIdFindInSolExpFromSCE, menuCommandService, _logger, _dte)
 {
     tfsVersionControl = _tfs;
 }
 public MenuCommandListHider(IMenuCommandService menuCommandService, List<MenuCommand> menuCommands)
 {
     _menuCommandService = menuCommandService;
     _menuCommands = menuCommands;
 }
Beispiel #50
0
        /// <summary>
        /// Called after the WindowPane has been sited with an IServiceProvider from the environment
        ///
        protected override void Initialize()
        {
            base.Initialize();

            // Create and initialize the editor
            #region Register with IOleComponentManager
            IOleComponentManager componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager));
            if (this._componentId == 0 && componentManager != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 100;
                int hr = componentManager.FRegisterComponent(this, crinfo, out this._componentId);
                ErrorHandler.Succeeded(hr);
            }
            #endregion

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane));

            #region Hook Undo Manager
            // Attach an IOleUndoManager to our WindowFrame. Merely calling QueryService
            // for the IOleUndoManager on the site of our IVsWindowPane causes an IOleUndoManager
            // to be created and attached to the IVsWindowFrame. The WindowFrame automaticall
            // manages to route the undo related commands to the IOleUndoManager object.
            // Thus, our only responsibilty after this point is to add IOleUndoUnits to the
            // IOleUndoManager (aka undo stack).
            _undoManager = (IOleUndoManager)GetService(typeof(SOleUndoManager));

            // In order to use the IVsLinkedUndoTransactionManager, it is required that you
            // advise for IVsLinkedUndoClient notifications. This gives you a callback at
            // a point when there are intervening undos that are blocking a linked undo.
            // You are expected to activate your document window that has the intervening undos.
            if (_undoManager != null)
            {
                IVsLinkCapableUndoManager linkCapableUndoMgr = (IVsLinkCapableUndoManager)_undoManager;
                if (linkCapableUndoMgr != null)
                {
                    linkCapableUndoMgr.AdviseLinkedUndoClient(this);
                }
            }
            #endregion

            // hook up our
            XmlEditorService es = GetService(typeof(XmlEditorService)) as XmlEditorService;
            _store             = es.CreateXmlStore();
            _store.UndoManager = _undoManager;

            _model = _store.OpenXmlModel(new Uri(_fileName));

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            _vsDesignerControl = new VsDesignerControl(_service, new ViewModel(_thisPackage, _store, _model, this, _textBuffer));
            base.Content       = _vsDesignerControl;

            RegisterIndependentView(true);

            IMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
            if (null != mcs)
            {
                // Now create one object derived from MenuCommnad for each command defined in
                // the CTC file and add it to the command service.

                // For each command we have to define its id that is a unique Guid/integer pair, then
                // create the OleMenuCommand object for this command. The EventHandler object is the
                // function that will be called when the user will select the command. Then we add the
                // OleMenuCommand to the menu service.  The addCommand helper function does all this for us.
                AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.NewWindow,
                           new EventHandler(OnNewWindow), new EventHandler(OnQueryNewWindow));
                AddCommand(mcs, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.ViewCode,
                           new EventHandler(OnViewCode), new EventHandler(OnQueryViewCode));
            }
        }
Beispiel #51
0
 protected MenuCommandBase(IMenuCommandService menuCommandService, Guid menuGroup, int commandId)
 {
     MenuCommand = new OleMenuCommand(OnExec, OnChange, OnQueryStatus, new CommandID(menuGroup, commandId));
     menuCommandService.AddCommand(MenuCommand);
 }
Beispiel #52
0
        /// <summary>
        /// Perform all the Edit menu options using the MenuCommandService
        /// </summary>
        private void PerformAction(string text)
        {
            if (this.CurrentDocumentView == Strings.Code)
            {
                MessageBox.Show("This is not in supported code view");
                return;
            }

            if (this.CurrentDocumentsHostControl == null)
            {
                return;
            }

            IMenuCommandService ims = this.CurrentDocumentsHostControl.HostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            try
            {
                switch (text)
                {
                case "&Cut":
                    ims.GlobalInvoke(StandardCommands.Cut);
                    break;

                case "C&opy":
                    ims.GlobalInvoke(StandardCommands.Copy);
                    break;

                case "&Paste":
                    ims.GlobalInvoke(StandardCommands.Paste);
                    break;

                case "&Undo":
                    ims.GlobalInvoke(StandardCommands.Undo);
                    break;

                case "&Redo":
                    ims.GlobalInvoke(StandardCommands.Redo);
                    break;

                case "&Delete":
                    ims.GlobalInvoke(StandardCommands.Delete);
                    break;

                case "&Select All":
                    ims.GlobalInvoke(StandardCommands.SelectAll);
                    break;

                case "&Lefts":
                    ims.GlobalInvoke(StandardCommands.AlignLeft);
                    break;

                case "&Centers":
                    ims.GlobalInvoke(StandardCommands.AlignHorizontalCenters);
                    break;

                case "&Rights":
                    ims.GlobalInvoke(StandardCommands.AlignRight);
                    break;

                case "&Tops":
                    ims.GlobalInvoke(StandardCommands.AlignTop);
                    break;

                case "&Middles":
                    ims.GlobalInvoke(StandardCommands.AlignVerticalCenters);
                    break;

                case "&Bottoms":
                    ims.GlobalInvoke(StandardCommands.AlignBottom);
                    break;

                default:
                    break;
                }
            }
            catch
            {
                this.OutputWindow.RichTextBox.Text += "Error in performing the action: " + text.Replace("&", "");
            }
        }
Beispiel #53
0
        /// <summary>
        /// Helper function used to add commands using IMenuCommandService
        /// </summary>
        /// <param name="mcs"> The IMenuCommandService interface.</param>
        /// <param name="menuGroup"> This guid represents the menu group of the command.</param>
        /// <param name="cmdID"> The command ID of the command.</param>
        /// <param name="commandEvent"> An EventHandler which will be called whenever the command is invoked.</param>
        /// <param name="queryEvent"> An EventHandler which will be called whenever we want to query the status of
        /// the command.  If null is passed in here then no EventHandler will be added.</param>
        private static void AddCommand(IMenuCommandService mcs, Guid menuGroup, int cmdID,
            EventHandler commandEvent, EventHandler queryEvent)
        {
            // Create the OleMenuCommand from the menu group, command ID, and command event
            CommandID menuCommandID = new CommandID(menuGroup, cmdID);
            OleMenuCommand command = new OleMenuCommand(commandEvent, menuCommandID);

            // Add an event handler to BeforeQueryStatus if one was passed in
            if (null != queryEvent)
            {
                command.BeforeQueryStatus += queryEvent;
            }

            // Add the command using our IMenuCommandService instance
            mcs.AddCommand(command);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="_dte"></param>
        /// <param name="_logger"></param>
        public AbstractCommand(Guid guidId, int id, IMenuCommandService menuCommandService, ILogger _logger)
        {
            logger = _logger;

            menuCommand = RegisterCommand(guidId, id, menuCommandService);
        }
Beispiel #55
0
 void AddSolutionExplorerCommand(IMenuCommandService mcs, OleMenuCommand command, UDNDocRunningTableMonitor rdtm)
 {
     command.BeforeQueryStatus += (sender, args) =>
     {
         var cmd = sender as OleMenuCommand;
         if (cmd != null)
         {
             var selectedItems = (Array)uih.SelectedItems;
             if (null != selectedItems)
             {
                 foreach (UIHierarchyItem selectedItem in selectedItems)
                 {
                     var projectItem = selectedItem.Object as ProjectItem;
                     var pathString = projectItem.Properties.Item("FullPath").Value.ToString();
                     if (!pathString.EndsWith(".udn"))
                     {
                         cmd.Visible = false;
                         break;
                     }
                     cmd.Visible = true;
                 }
             }
         }
     };
     mcs.AddCommand(command);
 }
Beispiel #56
0
        // Loads the new ITypeDescriptorFilterService and reloads the
        // designers for each button.
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            base.Initialize(component);

            // Loads the custom service if it has not been loaded already
            LoadService();

            // Build list of buttons from Container.Components.
            ArrayList buttons = new ArrayList();

            foreach (IComponent c in this.Component.Site.Container.Components)
            {
                if (c.GetType() == typeof(System.Windows.Forms.Button))
                {
                    buttons.Add((System.Windows.Forms.Button)c);
                }
            }
            if (buttons.Count > 0)
            {
                // Tests each Button for an existing
                // ColorCycleButtonDesigner;
                // if it has no designer of type
                // ColorCycleButtonDesigner, adds a designer.
                foreach (System.Windows.Forms.Button b in buttons)
                {
                    bool loaddesigner = true;
                    // Gets the attributes for each button.
                    AttributeCollection ac = TypeDescriptor.GetAttributes(b);
                    for (int i = 0; i < ac.Count; i++)
                    {
                        // If designer attribute is not for a
                        // ColorCycleButtonDesigner, adds a new
                        // ColorCycleButtonDesigner.
                        if (ac[i] is DesignerAttribute)
                        {
                            DesignerAttribute da = (DesignerAttribute)ac[i];
                            if (da.DesignerTypeName.Substring(da.DesignerTypeName.LastIndexOf(".") + 1) == "ColorCycleButtonDesigner")
                            {
                                loaddesigner = false;
                            }
                        }
                    }
                    if (loaddesigner)
                    {
                        // Saves the button location so that it
                        // can be repositioned.
                        Point p = b.Location;

                        // Gets an IMenuCommandService to cut and
                        // paste control in order to register with
                        // selection and movement interface after
                        // designer is changed without reloading.
                        IMenuCommandService imcs = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));
                        if (imcs == null)
                        {
                            throw new Exception("Could not obtain IMenuCommandService interface.");
                        }
                        // Gets an ISelectionService to select the
                        // button so that it can be cut and pasted.
                        ISelectionService iss = (ISelectionService)this.GetService(typeof(ISelectionService));
                        if (iss == null)
                        {
                            throw new Exception("Could not obtain ISelectionService interface.");
                        }
                        iss.SetSelectedComponents(new IComponent[] { b }, SelectionTypes.Auto);
                        // Invoke Cut and Paste.
                        imcs.GlobalInvoke(StandardCommands.Cut);
                        imcs.GlobalInvoke(StandardCommands.Paste);
                        // Regains reference to button from
                        // selection service.
                        System.Windows.Forms.Button b2 = (System.Windows.Forms.Button)iss.PrimarySelection;
                        iss.SetSelectedComponents(null);
                        // Refreshes TypeDescriptor properties of
                        // button to load new attributes from
                        // ButtonDesignerFilterService.
                        TypeDescriptor.Refresh(b2);
                        b2.Location = p;
                        b2.Focus();
                    }
                }
            }
        }
Beispiel #57
0
        void InitializePublishFlagButton(IMenuCommandService mcs, UDNDocRunningTableMonitor rdtm, Guid pkgGuid, int cmdId, string PublishFlag)
        {
            CommandID PublishFlagCommandID = new CommandID(pkgGuid, cmdId);

            // public is necessary so we don't want to attach changing event
            OleMenuCommand PublishFlagCommand;

            if (PublishFlag == Settings.Default.PublicAvailabilitiesString.Trim())
            {
                PublishFlagCommand = new OleMenuCommand((sender, args) => { }, PublishFlagCommandID);
                PublishFlagCommand.BeforeQueryStatus += (sender, args) =>
                {
                    PublishFlagCommand.Checked = true;
                    PublishFlagCommand.Text = PublishFlag;
                };
            }
            else
            {
                PublishFlagCommand = new OleMenuCommand((sender, args) => PublishCommand(sender, args, PublishFlag), PublishFlagCommandID);
                PublishFlagCommand.BeforeQueryStatus += (sender, args) => PublishCommandBeforeQueryStatus(sender, args, PublishFlagCommand, PublishFlag);
            }

            AddCommandWithEnableFlag(mcs, PublishFlagCommand, rdtm);
        }
 public AnalyzeProjectCommand(IMenuCommandService menuCommandService)
     : base(menuCommandService, SariferPackageCommandIds.AnalyzeProject)
 {
 }
 public MenuCommandBase(IMenuCommandService commandService, IDialogService dialogService)
 {
     _dialogService = dialogService;
     InitializeMenuItem(commandService);
 }
Beispiel #60
0
 public MenuCommandService(IServiceProvider serviceProvider, IMenuCommandService parent) : base(serviceProvider, (IOleCommandTarget)parent)
 {
 }