protected override void addSelectionEventsAndChoices() { SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property>(), 2, true, this.CardInfo.JurySelectionInfos[0].Description), revealAllAspects)); SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property>() { Property.Religion }, 1, false, this.CardInfo.JurySelectionInfos[1].Description), peekAllAspects)); }
protected override void addSelectionEventsAndChoices() { SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property> { Property.Language }, 3, true, this.CardInfo.JurySelectionInfos[0].Description), revealAllAspects)); SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property> { Property.Occupation }, 2, true, this.CardInfo.JurySelectionInfos[1].Description), revealAllAspects)); }
public DTEEventSource(Events2 events) { _buildEvents = events.BuildEvents; _dteEvents = events.DTEEvents; _debuggerEvents = events.DebuggerEvents; _debuggerProcessEvents = events.DebuggerProcessEvents; _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents; _findEvents = events.FindEvents; _miscFileEvents = events.MiscFilesEvents; _projectItemsEvents = events.ProjectItemsEvents; _projectEvents = events.ProjectsEvents; _publishEvents = events.PublishEvents; _selectionEvents = events.SelectionEvents; _solutionEvents = events.SolutionEvents; _solutionItemEvents = events.SolutionItemsEvents; }
public DTEEventSource( Events2 events) { _buildEvents = events.BuildEvents; _dteEvents = events.DTEEvents; _debuggerEvents = events.DebuggerEvents; _debuggerProcessEvents = events.DebuggerProcessEvents; _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents; _findEvents = events.FindEvents; _miscFileEvents = events.MiscFilesEvents; _projectItemsEvents = events.ProjectItemsEvents; _projectEvents = events.ProjectsEvents; _publishEvents = events.PublishEvents; _selectionEvents = events.SelectionEvents; _solutionEvents = events.SolutionEvents; _solutionItemEvents = events.SolutionItemsEvents; }
protected override void addSelectionEventsAndChoices() { SelectionEvents.Add( new CardEffectPair( (Game game, Player choosingPlayer, ChoiceHandler choiceHandler) => { BoardChoices boardChoices; choiceHandler.ChooseCards( game.Discards.Cards, (Dictionary <Card, int> selected) => { return(true); }, (List <Card> remainingChoices, Dictionary <Card, int> selected) => { return(remainingChoices); }, (Dictionary <Card, int> selected, bool isDone) => { return(selected.Count == 1); }, false, game, choosingPlayer, CardInfo.JurySelectionInfos[0].Description, out boardChoices); if (boardChoices.NotCancelled) { Card card = boardChoices.SelectedCards.Keys.First(); choiceHandler.ChooseCardEffect(card, game, choosingPlayer, "Select Jury Selection event to play", out boardChoices.PlayInfo); if (boardChoices.NotCancelled) { int idx = boardChoices.PlayInfo.eventIdx; boardChoices.PlayInfo.resultBoardChoice = card.Template.SelectionEvents[idx].CardChoice(game, choosingPlayer, choiceHandler); boardChoices.NotCancelled = boardChoices.PlayInfo.resultBoardChoice.NotCancelled; } } return(boardChoices); }, (Game game, Player choosingPlayer, BoardChoices boardChoices) => { Card card = boardChoices.SelectedCards.Keys.First(); int idx = boardChoices.PlayInfo.eventIdx; card.Template.SelectionEvents[idx].CardEffect(game, choosingPlayer, boardChoices.PlayInfo.resultBoardChoice); }, (Game game, Player choosingPlayer) => { return(choosingPlayer.Hand.Cards.Count == 3); })); }
public MenuBuilder(VisualStudio visualStudio) { this.visualStudio = visualStudio; try { CommandBars commandBars = (CommandBars)visualStudio.ApplicationObject.CommandBars; CommandBar itemCommandBar = commandBars["Item"]; CommandBar webItemCommandBar = commandBars["Web Item"]; CommandBar projectCommandBar = commandBars["Project"]; CommandBar webProjectCommandBar = commandBars["Web Project Folder"]; CommandBar toolsCommandBar = commandBars["Tools"]; subMenuPopup = (CommandBarPopup)itemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); subMenuPopup.Caption = "WSCF.blue"; subMenuCommandBar = subMenuPopup.CommandBar; webSubMenuPopup = (CommandBarPopup)webItemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webSubMenuPopup.Caption = "WSCF.blue"; webSubMenuCommandBar = webSubMenuPopup.CommandBar; projectSubMenuPopup = (CommandBarPopup)projectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); projectSubMenuPopup.Caption = "WSCF.blue"; projectSubMenuCommandBar = projectSubMenuPopup.CommandBar; webProjectSubMenuPopup = (CommandBarPopup)webProjectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webProjectSubMenuPopup.Caption = "WSCF.blue"; webProjectSubMenuCommandBar = webProjectSubMenuPopup.CommandBar; toolsSubMenuPopup = (CommandBarPopup)toolsCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); toolsSubMenuPopup.Caption = "WSCF.blue"; toolsSubMenuCommandBar = toolsSubMenuPopup.CommandBar; selectionEvents = visualStudio.ApplicationObject.Events.SelectionEvents; selectionEvents.OnChange += OnSelectionChanged; } catch (Exception ex) { AppLog.LogMessage(ex.ToString()); } }
protected override void addSelectionEventsAndChoices() { SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property>() { Property.Occupation, Property.Language }, 2, true, this.CardInfo.JurySelectionInfos[0].Description, null, (List <BoardObject> remainingChoices, Dictionary <BoardObject, int> selected) => { List <BoardObject> newChoices = new List <BoardObject>(remainingChoices); foreach (BoardObject obj in selected.Keys) { if (obj.Properties.Contains(Property.Occupation)) { newChoices = newChoices.Where(c => !c.Properties.Contains(Property.Occupation)).ToList(); } if (obj.Properties.Contains(Property.Language)) { newChoices = newChoices.Where(c => !c.Properties.Contains(Property.Language)).ToList(); } } return(newChoices); }), revealAllAspects)); SelectionEvents.Add( new CardEffectPair( genRevealOrPeakCardChoice(new HashSet <Property>() { Property.Religion }, 2, false, this.CardInfo.JurySelectionInfos[1].Description), peekAllAspects)); }
public DTE2EventListener(AWPackage package) { this._package = package; var dte2Events = this._package.DTE2Service.Events; _buildEv = dte2Events.BuildEvents; _documentEv = dte2Events.DocumentEvents; _selectionEv = dte2Events.SelectionEvents; _solutionEv = dte2Events.SolutionEvents; _windowEv = dte2Events.WindowEvents; _buildEv.OnBuildBegin += buildEvents_OnBuildBegin; _buildEv.OnBuildDone += buildEvents_OnBuildDone; _documentEv.DocumentOpened += documentEv_DocumentOpened; _documentEv.DocumentSaved += documentEv_DocumentSaved; _documentEv.DocumentClosing += documentEv_DocumentClosing; _selectionEv.OnChange += selectionEv_OnChange; _solutionEv.Opened += solutionEvents_Opened; _solutionEv.BeforeClosing += solutionEv_BeforeClosing; _windowEv.WindowActivated += windowEv_WindowActivated; _windowEv.WindowClosing += windowEv_WindowClosing; _windowEv.WindowCreated += windowEv_WindowCreated; _windowEv.WindowMoved += windowEv_WindowMoved; }
// ReSharper restore PrivateFieldCanBeConvertedToLocalVariable public SolutionEventGenerator(IRSEnv env, IMessageBus messageBus, IDateUtils dateUtils, IThreading threading) : base(env, messageBus, dateUtils, threading) { _solutionEvents = DTE.Events.SolutionEvents; _solutionEvents.Opened += _solutionEvents_Opened; _solutionEvents.ProjectAdded += _solutionEvents_ProjectAdded; _solutionEvents.ProjectRenamed += _solutionEvents_ProjectRenamed; _solutionEvents.ProjectRemoved += _solutionEvents_ProjectRemoved; _solutionEvents.Renamed += _solutionEvents_Renamed; _solutionEvents.BeforeClosing += _solutionEvents_BeforeClosing; _solutionItemsEvents = DTE.Events.SolutionItemsEvents; _solutionItemsEvents.ItemAdded += _solutionItemsEvents_ItemAdded; _solutionItemsEvents.ItemRenamed += _solutionItemsEvents_ItemRenamed; _solutionItemsEvents.ItemRemoved += _solutionItemsEvents_ItemRemoved; _projectItemsEvents = DTE.Events.MiscFilesEvents; _projectItemsEvents.ItemAdded += _projectItemsEvents_ItemAdded; _projectItemsEvents.ItemRenamed += _projectItemsEvents_ItemRenamed; _projectItemsEvents.ItemRemoved += _projectItemsEvents_ItemRemoved; _selectionEvents = DTE.Events.SelectionEvents; _selectionEvents.OnChange += _selectionEvents_OnChange; }
public EventHandlerBase(IServiceProvider serviceProvider, IOsbideEventGenerator osbideEvents) { if (serviceProvider == null) { throw new Exception("Service provider is null"); } ServiceProvider = serviceProvider; //save references to dte events buildEvents = dte.Events.BuildEvents; genericCommandEvents = dte.Events.CommandEvents; menuCommandEvents = dte.Events.get_CommandEvents(MenuEventGuid); debuggerEvents = dte.Events.DebuggerEvents; documentEvents = dte.Events.DocumentEvents; findEvents = dte.Events.FindEvents; miscFileEvents = dte.Events.MiscFilesEvents; outputWindowEvents = dte.Events.OutputWindowEvents; selectionEvents = dte.Events.SelectionEvents; solutionEvents = dte.Events.SolutionEvents; solutionItemsEvents = dte.Events.SolutionItemsEvents; textEditorEvents = dte.Events.TextEditorEvents; //attach osbide requests _osbideEvents = osbideEvents; _osbideEvents.SolutionSubmitRequest += new EventHandler <SubmitAssignmentArgs>(OsbideSolutionSubmitted); _osbideEvents.SolutionDownloaded += new EventHandler <SolutionDownloadedEventArgs>(OsbideSolutionDownloaded); _osbideEvents.SubmitEventRequested += new EventHandler <SubmitEventArgs>(SubmitEventRequested); //attach listeners for dte events //build events buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin); buildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(OnBuildDone); //generic command events genericCommandEvents.AfterExecute += new _dispCommandEvents_AfterExecuteEventHandler(GenericCommand_AfterCommandExecute); genericCommandEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(GenericCommand_BeforeCommandExecute); //menu-related command command menuCommandEvents.AfterExecute += new _dispCommandEvents_AfterExecuteEventHandler(MenuCommand_AfterExecute); menuCommandEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(MenuCommand_BeforeExecute); //debugger events debuggerEvents.OnContextChanged += new _dispDebuggerEvents_OnContextChangedEventHandler(OnContextChanged); debuggerEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(OnEnterBreakMode); debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(OnEnterDesignMode); debuggerEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(OnEnterRunMode); debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled); debuggerEvents.OnExceptionThrown += new _dispDebuggerEvents_OnExceptionThrownEventHandler(OnExceptionThrown); //document events documentEvents.DocumentClosing += new _dispDocumentEvents_DocumentClosingEventHandler(DocumentClosing); documentEvents.DocumentOpened += new _dispDocumentEvents_DocumentOpenedEventHandler(DocumentOpened); documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(DocumentSaved); //find events findEvents.FindDone += new _dispFindEvents_FindDoneEventHandler(FindDone); //misc file events miscFileEvents.ItemAdded += new _dispProjectItemsEvents_ItemAddedEventHandler(ProjectItemAdded); miscFileEvents.ItemRemoved += new _dispProjectItemsEvents_ItemRemovedEventHandler(ProjectItemRemoved); miscFileEvents.ItemRenamed += new _dispProjectItemsEvents_ItemRenamedEventHandler(ProjectItemRenamed); //output window events outputWindowEvents.PaneUpdated += new _dispOutputWindowEvents_PaneUpdatedEventHandler(OutputPaneUpdated); //selection events selectionEvents.OnChange += new _dispSelectionEvents_OnChangeEventHandler(SelectionChange); //solution events solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(SolutionBeforeClosing); solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionOpened); solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(ProjectAdded); solutionEvents.Renamed += new _dispSolutionEvents_RenamedEventHandler(SolutionRenamed); //solution item events solutionItemsEvents.ItemAdded += new _dispProjectItemsEvents_ItemAddedEventHandler(SolutionItemAdded); solutionItemsEvents.ItemRemoved += new _dispProjectItemsEvents_ItemRemovedEventHandler(SolutionItemRemoved); solutionItemsEvents.ItemRenamed += new _dispProjectItemsEvents_ItemRenamedEventHandler(SolutionItemRenamed); //text editor events textEditorEvents.LineChanged += new _dispTextEditorEvents_LineChangedEventHandler(EditorLineChanged); }
protected override void addSelectionEventsAndChoices() { SelectionEvents.Add(genAttorneyJurySelectPeekEffectPair(4, 2, 0)); }
void VsShellPropertyEvents_AfterShellPropertyChanged(object sender, VsShellPropertyEventsHandler.ShellPropertyChangeEventArgs e) { SafeExecute(() => { // when zombie state changes to false, finish package initialization //! DO NOT USE CODE WHICH MAY EXECUTE FOR LONG TIME HERE if ((int)__VSSPROPID.VSSPROPID_Zombie == e.PropId) { if ((bool)e.Var == false) { var dte2 = ServiceProvider.GetDte2(); Events = dte2.Events as Events2; DTEEvents = Events.DTEEvents; SolutionEvents = Events.SolutionEvents; DocumentEvents = Events.DocumentEvents; WindowEvents = Events.WindowEvents; DebuggerEvents = Events.DebuggerEvents; CommandEvents = Events.CommandEvents; SelectionEvents = Events.SelectionEvents; DelayedInitialise(); } } }); }
public EventHandlerBase(IServiceProvider serviceProvider, IEventGenerator osbideEvents) { if (serviceProvider == null) { throw new Exception("Service provider is null"); } ServiceProvider = serviceProvider; //attach osbide requests _osbideEvents = osbideEvents; _osbideEvents.SolutionSubmitRequest += SolutionSubmitted; _osbideEvents.SubmitEventRequested += SubmitEventRequested; //save references to dte events buildEvents = Dte.Events.BuildEvents; genericCommandEvents = Dte.Events.CommandEvents; menuCommandEvents = Dte.Events.CommandEvents[MenuEventGuid]; debuggerEvents = Dte.Events.DebuggerEvents; documentEvents = Dte.Events.DocumentEvents; findEvents = Dte.Events.FindEvents; miscFileEvents = Dte.Events.MiscFilesEvents; outputWindowEvents = Dte.Events.OutputWindowEvents; selectionEvents = Dte.Events.SelectionEvents; solutionEvents = Dte.Events.SolutionEvents; solutionItemsEvents = Dte.Events.SolutionItemsEvents; textEditorEvents = Dte.Events.TextEditorEvents; //attach osbide requests //var osbideEventGenerator = osbideEvents; //osbideEventGenerator.SolutionSubmitRequest += SolutionSubmitted; //osbideEventGenerator.SubmitEventRequested += SubmitEventRequested; //attach listeners for dte events //build events buildEvents.OnBuildBegin += OnBuildBegin; buildEvents.OnBuildDone += OnBuildDone; //generic command events genericCommandEvents.AfterExecute += GenericCommand_AfterCommandExecute; genericCommandEvents.BeforeExecute += GenericCommand_BeforeCommandExecute; //menu-related command command menuCommandEvents.AfterExecute += MenuCommand_AfterExecute; menuCommandEvents.BeforeExecute += MenuCommand_BeforeExecute; //debugger events debuggerEvents.OnContextChanged += OnContextChanged; debuggerEvents.OnEnterBreakMode += OnEnterBreakMode; debuggerEvents.OnEnterDesignMode += OnEnterDesignMode; debuggerEvents.OnEnterRunMode += OnEnterRunMode; debuggerEvents.OnExceptionNotHandled += OnExceptionNotHandled; debuggerEvents.OnExceptionThrown += OnExceptionThrown; //document events documentEvents.DocumentClosing += DocumentClosing; documentEvents.DocumentOpened += DocumentOpened; documentEvents.DocumentSaved += DocumentSaved; //find events findEvents.FindDone += FindDone; //misc file events miscFileEvents.ItemAdded += ProjectItemAdded; miscFileEvents.ItemRemoved += ProjectItemRemoved; miscFileEvents.ItemRenamed += ProjectItemRenamed; //output window events outputWindowEvents.PaneUpdated += OutputPaneUpdated; //selection events selectionEvents.OnChange += SelectionChange; //solution events solutionEvents.BeforeClosing += SolutionBeforeClosing; solutionEvents.Opened += SolutionOpened; solutionEvents.ProjectAdded += ProjectAdded; solutionEvents.Renamed += SolutionRenamed; //solution item events solutionItemsEvents.ItemAdded += SolutionItemAdded; solutionItemsEvents.ItemRemoved += SolutionItemRemoved; solutionItemsEvents.ItemRenamed += SolutionItemRenamed; //text editor events textEditorEvents.LineChanged += EditorLineChanged; // Create an event log watcher that will notify us if any windows event logs // of type Error are created in the "Application" log file. This is so we can // tell if a user experiences a runtime exception while running their code // outside debug mode. string queryStr = "*[System/Level=2]"; EventLogQuery query = new EventLogQuery("Application", PathType.LogName, queryStr); eventLogWatcher = new EventLogWatcher(query); // subscribe to it's event (Note: it is not enabled yet, it will be enabled if the // user runs without debuging) eventLogWatcher.EventRecordWritten += NETErrorEventRecordWritten; }
private void CreateAddInMenus(VsAddIn addin, ext_ConnectMode connectMode) { object[] contextGUIDS = new object[] { }; //CommandBar cmdBar; Command cmdObj; if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup || connectMode == ext_ConnectMode.ext_cm_UISetup) { AppLog.LogMessage("Creating commands."); Commands2 commands = (Commands2)Connect.ApplicationObject.Commands; CommandBars commandBars = (CommandBars)Connect.ApplicationObject.CommandBars; CommandBar subMenuCommandBar = null; CommandBar webSubMenuCommandBar = null; CommandBar projectSubMenuCommandBar = null; CommandBar webProjectSubMenuCommandBar = null; CommandBar toolsSubMenuCommandBar = null; try { CommandBar itemCommandBar = FindCommandBarByName(commandBars, "Item"); CommandBar webItemCommandBar = FindCommandBarByName(commandBars, "Web Item"); CommandBar projectCommandBar = FindCommandBarByName(commandBars, "Project"); CommandBar webProjectCommandBar = FindCommandBarByName(commandBars, "Web Project Folder"); CommandBar toolsCommandBar = GetToolsCommandBar(commandBars); if (itemCommandBar != null) { subMenuPopup = (CommandBarPopup)itemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); subMenuPopup.Caption = "WSCF.blue"; subMenuCommandBar = subMenuPopup.CommandBar; } else { AppLog.LogMessage("The 'Item' CommandBar could not be found."); } if (webItemCommandBar != null) { webSubMenuPopup = (CommandBarPopup)webItemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webSubMenuPopup.Caption = "WSCF.blue"; webSubMenuCommandBar = webSubMenuPopup.CommandBar; } else { AppLog.LogMessage("The 'Web Item' CommandBar could not be found."); } if (projectCommandBar != null) { projectSubMenuPopup = (CommandBarPopup)projectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); projectSubMenuPopup.Caption = "WSCF.blue"; projectSubMenuCommandBar = projectSubMenuPopup.CommandBar; } else { AppLog.LogMessage("The 'Project' CommandBar could not be found."); } if (webProjectCommandBar != null) { webProjectSubMenuPopup = (CommandBarPopup)webProjectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webProjectSubMenuPopup.Caption = "WSCF.blue"; webProjectSubMenuCommandBar = webProjectSubMenuPopup.CommandBar; } else { AppLog.LogMessage("The 'Web Project Folder' CommandBar could not be found."); } if (toolsCommandBar != null) { toolsSubMenuPopup = (CommandBarPopup)toolsCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); toolsSubMenuPopup.Caption = "WSCF.blue"; toolsSubMenuCommandBar = toolsSubMenuPopup.CommandBar; } else { AppLog.LogMessage("The 'Tools' CommandBar could not be found."); } selectionEvents = Connect.ApplicationObject.Events.SelectionEvents; selectionEvents.OnChange += OnSelectionChanged; } catch (Exception ex) { AppLog.LogMessage(ex.ToString()); } // Create the 'Web Services Contract-First...' Tools entry try { if (toolsSubMenuCommandBar != null) { Command command = commands.AddNamedCommand2( AddInInstance, "WsContractFirst", "Web Services Contract-First...", "Executes the command for WsContractFirstAddin", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); command.AddControl(toolsSubMenuCommandBar, 1); AppLog.LogMessage("Command bar is added to the Tools menu."); } } catch (ArgumentException) { } catch (Exception e) { AppLog.LogMessage(e.Message); } // Create the 'Generate Web Service Code...' context-menu entry try { if (subMenuCommandBar != null || webSubMenuCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "WsContractFirstContextMenu", "Generate Web Service Code...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if (subMenuCommandBar != null) { cmdObj.AddControl(subMenuCommandBar, 1); } if (webSubMenuCommandBar != null) { // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 1); } AppLog.LogMessage("Generate Web Serive Code menu item is added."); } } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Edit WSDL Interface Description...' context-menu entry try { if (subMenuCommandBar != null || webSubMenuCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "EditWsdlContextMenu", "Edit WSDL Interface Description...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if (subMenuCommandBar != null) { cmdObj.AddControl(subMenuCommandBar, 2); } if (webSubMenuCommandBar != null) { // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 2); } AppLog.LogMessage("Edit WSDL menu item is added"); } } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Create WSDL Interface Description...' context-menu entry try { if (subMenuCommandBar != null || webSubMenuCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "CreateWsdlContextMenu", "Create WSDL Interface Description...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if (subMenuCommandBar != null) { cmdObj.AddControl(subMenuCommandBar, 1); } if (webSubMenuCommandBar != null) { // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 1); } AppLog.LogMessage("Create WSDL interface desc menu item is added"); } } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Choose WSDL to implement...' context-menu entry try { if (projectSubMenuCommandBar != null || webProjectSubMenuCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "WsContractFirstContextMenu2", "Choose WSDL to Implement...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if (projectSubMenuCommandBar != null) { cmdObj.AddControl(projectSubMenuCommandBar, 1); } if (webProjectSubMenuCommandBar != null) { // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webProjectSubMenuCommandBar, 1); } AppLog.LogMessage("Choose WSDL menu item is added"); } } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Generate code...' context-menu entry try { if (subMenuCommandBar != null || webSubMenuCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "GenerateCodeMenu", "Generate Data Contract Code...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if (subMenuCommandBar != null) { cmdObj.AddControl(subMenuCommandBar, 2); } if (webSubMenuCommandBar != null) { // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 2); } AppLog.LogMessage("Generate code menu item is added"); } } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } // Create the 'Paste XML as Schema' Edit menu entry. try { CommandBar menuBarCommandBar = FindCommandBarByName(commandBars, "MenuBar"); if (menuBarCommandBar != null) { // Create the add-in command cmdObj = commands.AddNamedCommand2( AddInInstance, "PasteSchemaMenu", "Paste XML as Schema", "Pastes the XML on the clipboard as XSD schema.", true, 239, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); CommandBarControl editControl = menuBarCommandBar.Controls["Edit"]; CommandBarPopup editPopup = (CommandBarPopup)editControl; CommandBarControl pasteControl = editPopup.CommandBar.Controls["Paste"]; cmdObj.AddControl(editPopup.CommandBar, pasteControl != null ? pasteControl.Index + 1 : 1); AppLog.LogMessage("Paste Schema code menu item is added"); } else { AppLog.LogMessage("The 'MenuBar' CommandBar could not be found."); } } catch (Exception ex) { AppLog.LogMessage(ex.Message); } } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { AppLog.LogMessage("Entering OnConnection method."); applicationObject = (DTE2)application; // Initialize VsHelper. visualStudio = new VisualStudio(applicationObject); outputWindowWriter = new OutputWindowWriter(applicationObject); addInInstance = (AddIn)addInInst; object[] contextGUIDS = new object[] { }; CommandBar cmdBar; Command cmdObj; if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup || connectMode == ext_ConnectMode.ext_cm_UISetup) { AppLog.LogMessage("Creating commands."); Commands2 commands = (Commands2)applicationObject.Commands; CommandBars commandBars = (CommandBars)applicationObject.CommandBars; CommandBar subMenuCommandBar = null; CommandBar webSubMenuCommandBar = null; CommandBar projectSubMenuCommandBar = null; CommandBar webProjectSubMenuCommandBar = null; CommandBar toolsSubMenuCommandBar = null; try { CommandBar itemCommandBar = commandBars["Item"]; CommandBar webItemCommandBar = commandBars["Web Item"]; CommandBar projectCommandBar = commandBars["Project"]; CommandBar webProjectCommandBar = commandBars["Web Project Folder"]; CommandBar toolsCommandBar = commandBars["Tools"]; subMenuPopup = (CommandBarPopup)itemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); subMenuPopup.Caption = "WSCF.blue"; subMenuCommandBar = subMenuPopup.CommandBar; webSubMenuPopup = (CommandBarPopup)webItemCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webSubMenuPopup.Caption = "WSCF.blue"; webSubMenuCommandBar = webSubMenuPopup.CommandBar; projectSubMenuPopup = (CommandBarPopup)projectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); projectSubMenuPopup.Caption = "WSCF.blue"; projectSubMenuCommandBar = projectSubMenuPopup.CommandBar; webProjectSubMenuPopup = (CommandBarPopup)webProjectCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); webProjectSubMenuPopup.Caption = "WSCF.blue"; webProjectSubMenuCommandBar = webProjectSubMenuPopup.CommandBar; toolsSubMenuPopup = (CommandBarPopup)toolsCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true); toolsSubMenuPopup.Caption = "WSCF.blue"; toolsSubMenuCommandBar = toolsSubMenuPopup.CommandBar; selectionEvents = applicationObject.Events.SelectionEvents; selectionEvents.OnChange += OnSelectionChanged; } catch (Exception ex) { AppLog.LogMessage(ex.ToString()); } // Create the 'Web Services Contract-First...' Tools entry try { Command command = commands.AddNamedCommand2( addInInstance, "WsContractFirst", "Web Services Contract-First...", "Executes the command for WsContractFirstAddin", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); command.AddControl(toolsSubMenuCommandBar, 1); AppLog.LogMessage("Command bar is added to the Tools menu."); } catch (ArgumentException) { } catch (Exception e) { AppLog.LogMessage(e.Message); } // Create the 'Generate Web Service Code...' context-menu entry try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "WsContractFirstContextMenu", "Generate Web Service Code...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); cmdObj.AddControl(subMenuCommandBar, 1); // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 1); AppLog.LogMessage("Generate Web Serive Code menu item is added."); } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Edit WSDL Interface Description...' context-menu entry try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "EditWsdlContextMenu", "Edit WSDL Interface Description...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); cmdObj.AddControl(subMenuCommandBar, 2); // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 2); AppLog.LogMessage("Edit WSDL menu item is added"); } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Create WSDL Interface Description...' context-menu entry try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "CreateWsdlContextMenu", "Create WSDL Interface Description...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); cmdObj.AddControl(subMenuCommandBar, 1); // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 1); AppLog.LogMessage("Create WSDL interface desc menu item is added"); } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Choose WSDL to implement...' context-menu entry try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "WsContractFirstContextMenu2", "Choose WSDL to Implement...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); cmdObj.AddControl(projectSubMenuCommandBar, 1); // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webProjectSubMenuCommandBar, 1); AppLog.LogMessage("Choose WSDL menu item is added"); } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } // Create the 'Generate code...' context-menu entry try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "GenerateCodeMenu", "Generate Data Contract Code...", "Executes the command for WsContractFirstAddin ContextMenu", true, 190, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusUnsupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); cmdObj.AddControl(subMenuCommandBar, 2); // BDS 11/21/2005: Add this menu item to the web project // template. cmdObj.AddControl(webSubMenuCommandBar, 2); AppLog.LogMessage("Generate code menu item is added"); } catch (ArgumentException e) { AppLog.LogMessage(e.Message); } // Create the 'Paste XML as Schema' Edit menu entry. try { // Create the add-in command cmdObj = commands.AddNamedCommand2( addInInstance, "PasteSchemaMenu", "Paste XML as Schema", "Pastes the XML on the clipboard as XSD schema.", true, 239, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); CommandBar menuBarCommandBar = commandBars["MenuBar"]; CommandBarControl editControl = menuBarCommandBar.Controls["Edit"]; CommandBarPopup editPopup = (CommandBarPopup)editControl; CommandBarControl pasteControl = editPopup.CommandBar.Controls["Paste"]; cmdObj.AddControl(editPopup.CommandBar, pasteControl != null ? pasteControl.Index + 1 : 1); AppLog.LogMessage("Paste Schema code menu item is added"); } catch (Exception ex) { AppLog.LogMessage(ex.Message); } } AppLog.LogMessage("Leaving OnConnection method."); }