/// <summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary> //public Connect() //{ //} /// <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) { applicationObject = (DTE2) application; addInInstance = (AddIn) addInInst; // Only execute the startup code if the connection mode is a startup mode //if( connectMode == ext_ConnectMode.ext_cm_UISetup ) { if (connectMode == ext_ConnectMode.ext_cm_AfterStartup) { //Initializing Context Context.ApplicationObject = applicationObject; Context.AddInInstance = addInInstance; //Initializing EventSinks SolutionEventSink solutionEventSink = new SolutionEventSink(); addinEventSink = new AddinEventSink(); //Initializing Controller controller = new UIController(); controller.Sinks.Add(solutionEventSink); controller.Sinks.Add(addinEventSink); controller.Init(solutionEventSink, addinEventSink); addinEventSink.OnStartup(applicationObject); if (Context.ApplicationObject.Solution.IsOpen){ solutionEventSink.OnOpenSolution(); } } }
/// <summary> /// Returns a newly build <code>ICondition</code> object. /// </summary> public ICondition BuildCondition(AddIn addIn) { //一个AddIn并没有和一个ICondition关联,所以创建一个ICondition时可以不必提供AddIn对象 ICondition condition = (ICondition)assembly.CreateInstance(className, true); return condition; }
public fmReportTypeSelect(String r, DTE2 ao, AddIn aii) { Result = r; applicationObject = ao; addInInstance = aii; InitializeComponent(); }
public ExpressionHighlighterPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { workerToDos.WorkerReportsProgress = false; workerToDos.WorkerSupportsCancellation = true; workerToDos.DoWork += new System.ComponentModel.DoWorkEventHandler(workerToDos_DoWork); }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// </summary> /// <remarks> /// <para> /// Receives notification that the Add-in is being loaded. /// </para> /// </remarks> /// <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' /> void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { dte = (DTE2)application; addIn = (AddIn)addInInst; ShellProxy.Instance.AddInConnected(this); }
protected DockablePresenterBase(VBE vbe, AddIn addin, IDockableUserControl control) { _vbe = vbe; _addin = addin; UserControl = control as UserControl; _window = CreateToolWindow(control); }
public RubberduckMenu(VBE vbe, AddIn addIn, IGeneralConfigService configService, IRubberduckParser parser, IActiveCodePaneEditor editor, IInspector inspector) : base(vbe, addIn) { _addIn = addIn; _parser = parser; _configService = configService; var testExplorer = new TestExplorerWindow(); var testEngine = new TestEngine(); var testGridViewSort = new GridViewSort<TestExplorerItem>(RubberduckUI.Result, false); var testPresenter = new TestExplorerDockablePresenter(vbe, addIn, testExplorer, testEngine, testGridViewSort); _testMenu = new TestMenu(vbe, addIn, testExplorer, testPresenter); var codeExplorer = new CodeExplorerWindow(); var codePresenter = new CodeExplorerDockablePresenter(parser, vbe, addIn, codeExplorer); codePresenter.RunAllTests += CodePresenterRunAllAllTests; codePresenter.RunInspections += codePresenter_RunInspections; codePresenter.Rename += codePresenter_Rename; codePresenter.FindAllReferences += codePresenter_FindAllReferences; codePresenter.FindAllImplementations += codePresenter_FindAllImplementations; _codeExplorerMenu = new CodeExplorerMenu(vbe, addIn, codeExplorer, codePresenter); var todoSettings = configService.LoadConfiguration().UserSettings.ToDoListSettings; var todoExplorer = new ToDoExplorerWindow(); var todoGridViewSort = new GridViewSort<ToDoItem>(RubberduckUI.Priority, false); var todoPresenter = new ToDoExplorerDockablePresenter(parser, todoSettings.ToDoMarkers, vbe, addIn, todoExplorer, todoGridViewSort); _todoItemsMenu = new ToDoItemsMenu(vbe, addIn, todoExplorer, todoPresenter); var inspectionExplorer = new CodeInspectionsWindow(); var inspectionGridViewSort = new GridViewSort<CodeInspectionResultGridViewItem>(RubberduckUI.Component, false); var inspectionPresenter = new CodeInspectionsDockablePresenter(inspector, vbe, addIn, inspectionExplorer, inspectionGridViewSort); _codeInspectionsMenu = new CodeInspectionsMenu(vbe, addIn, inspectionExplorer, inspectionPresenter); _refactorMenu = new RefactorMenu(IDE, AddIn, parser, editor); }
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { try { _vbe = Application as VBE; _addin = AddInInst as AddIn; switch (ConnectMode) { case ext_ConnectMode.ext_cm_AfterStartup: InitializeAddIn(); break; case ext_ConnectMode.ext_cm_Startup: break; case ext_ConnectMode.ext_cm_External: break; case ext_ConnectMode.ext_cm_CommandLine: break; default: throw new ArgumentOutOfRangeException("ConnectMode"); } } catch (Exception e) { MessageBox.Show(e.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { try { this._applicationObject = (DTE2)application; this._addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_Startup && AddinSetupState.State == SetupState.FirstRun) { LogHelper.LogDebug("Add-in SetupState is FirstRun"); LogHelper.LogDebug("Removing add-in commands"); this.RemoveAddinCommands(); LogHelper.LogDebug("Creating add-in commands"); this.CreateAddinCommands(); LogHelper.LogDebug("Opening FirstRunStep1 form"); FirstRunStep1 firstRunStep = new FirstRunStep1(); firstRunStep.ShowDialog(); LogHelper.LogDebug("Setting add-in SetupState to complete"); AddinSetupState.State = SetupState.SetupComplete; } if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup) { LogHelper.LogDebug("Creating add-in menus"); this.CreateAddinMenus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "CodeKeep"); } }
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { pb = new PBHelper(); application = (DTE2)Application; addInInstance = (AddIn)AddInInst; if (ConnectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)application.Commands; // get item bar Microsoft.VisualStudio.CommandBars.CommandBar itemCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)application.CommandBars)["Item"]; try { // add me commands Command command = commands.AddNamedCommand2(addInInstance, "Dw2Struct", "Generate Structure", "Generates a structure of the columns in the datawindow", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); Command command2 = commands.AddNamedCommand2(addInInstance, "Dw2Nv", "Generate NonVisualObject", "Generates an NonVisualObject of the columns in the datawindow", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if ((command != null)) { command.AddControl(itemCommandBar, itemCommandBar.Controls.Count); } if ((command2 != null)) { command2.AddControl(itemCommandBar, itemCommandBar.Controls.Count); } } catch (System.ArgumentException) { } } }
/// <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) { _application = (DTE2)application; _addInInstance = (AddIn)addInInst; // Core var name = _addInInstance.Name; var outputPane = _application.ToolWindows.OutputWindow.OutputWindowPanes.GetPane(name); var feedback = new FeedbackManager(name, outputPane); _core = new Core(feedback); // Events _events = (Events2)_application.Events; _projectsEvents = _events.ProjectsEvents; _projectItemsEvents = _events.ProjectItemsEvents; _documentEvents = _events.DocumentEvents; _buildEvents = _events.BuildEvents; AttachEvents(); // If being connected when Solution is already loaded - try to load all projects if (_application.Solution != null) { _core.Load(_application.Solution); } }
public frmEEPReport(DTE2 dte2, AddIn addIn, bool isWebReport) { InitializeComponent(); _dte2 = dte2; _addIn = addIn; _isWebReport = isWebReport; }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; _dbgWatchConfig = new QuickWatchConfig(); try { CommandBar commandBar = ((CommandBars)_applicationObject.CommandBars)["Code Window"]; // Create Quick watch menu _controlQuickWatch = commandBar.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true); _controlQuickWatch.Caption = "QuickWatchEx..."; _controlQuickWatch.Enabled = IsInDebugMode(_applicationObject); _menuItemHandlerQuickWatch = (CommandBarEvents)_applicationObject.Events.CommandBarEvents[_controlQuickWatch]; _menuItemHandlerQuickWatch.Click += MenuItemHandlerQuickWatch_Click; _debuggerEvents = _applicationObject.Events.DebuggerEvents; _debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode; _debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode; _debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode; } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded. /// </summary> /// <param name='application'> /// Root object of the host application. /// </param> /// <param name='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param name='addIn'> /// Object representing this Add-in. /// </param> /// /// <param name='custom'> /// Array of parameters that are host application specific. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addIn, ref Array custom) { _application = (DTE2)application; _addIn = (AddIn)addIn; try { if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup) { _listener = CreateTraceListener(); _env = new ControllerEnvironment(new WindowHandle(_application.MainWindow.HWnd), _listener); _controller = CreateController(); _controller.OnConnectionStateChange += OnConnectionStateChange; CreateCommands(); CreateToolWindow(); _listener.WriteLine("Addin initialized"); if (connectMode == ext_ConnectMode.ext_cm_AfterStartup) { OnStartupComplete(ref custom); } } } catch (Exception ex) { if (_listener != null) { _listener.WriteLine(ex); } } }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; CommandBars cBars = (CommandBars)_applicationObject.CommandBars; try { Command commandProjectSettings = commands.AddNamedCommand2(_addInInstance, "DavecProjectSchemaSettings", "Davec Project Settings", "Manages Database Project Settings", false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); Command commandAddSchemaUpdate = commands.AddNamedCommand2(_addInInstance, "DavecProjectUpdate", "Davec Update", "Updates Database Schema", false, 2, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); CommandBar vsBarProject = cBars["Project"]; CommandBar vsBarFolder = cBars["Folder"]; commandProjectSettings.AddControl(vsBarProject, 1); commandAddSchemaUpdate.AddControl(vsBarFolder, 1); } catch (System.ArgumentException) { //ignore } var _solutionEvents = _applicationObject.Events.SolutionEvents; _solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened); var _documentEvents = _applicationObject.Events.DocumentEvents; _documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(_documentEvents_DocumentSaved); } }
/// <summary> /// Gets a known WPF command. /// </summary> /// <param name="addIn">The addIn definition that defines the command class.</param> /// <param name="commandName">The name of the command, e.g. "Copy".</param> /// <returns>The WPF ICommand with the given name, or null if thecommand was not found.</returns> public static System.Windows.Input.ICommand GetRegisteredCommand(AddIn addIn, string commandName) { if (addIn == null) throw new ArgumentNullException("addIn"); if (commandName == null) throw new ArgumentNullException("commandName"); System.Windows.Input.ICommand command; lock (knownCommands) { if (knownCommands.TryGetValue(commandName, out command)) return command; } int pos = commandName.LastIndexOf('.'); if (pos > 0) { string className = commandName.Substring(0, pos); string propertyName = commandName.Substring(pos + 1); Type classType = addIn.FindType(className); if (classType != null) { PropertyInfo p = classType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Static); if (p != null) return (System.Windows.Input.ICommand)p.GetValue(null, null); FieldInfo f = classType.GetField(propertyName, BindingFlags.Public | BindingFlags.Static); if (f != null) return (System.Windows.Input.ICommand)f.GetValue(null); } } return null; }
public CommandBarBuilder(DTE2 dte, AddIn addin) { this.dte = dte; this.addIn = addin; createdControls = new List<CommandBarControl>(); }
/// <summary> /// Constructor /// </summary> public CommandManager(DTE2 dte, AddIn addin) { this.dte = dte; this.addIn = addin; commands = new Dictionary<string, CommandBase>(); }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded. /// </summary> /// <param name="application">Root object of the host application.</param> /// <param name="connectMode">Describes how the Add-in is being loaded.</param> /// <param name="addInInst">Object representing this Add-in.</param> /// <param name="custom"></param> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; var bootstrap = new Bootstrap(_applicationObject, _addInInstance); bootstrap.Run(); }
public RefactorMenu(VBE vbe, AddIn addin, IRubberduckParser parser, IActiveCodePaneEditor editor) : base(vbe, addin) { _parser = parser; _editor = editor; _iconCache = new SearchResultIconCache(); }
public CodeExplorerDockablePresenter(IRubberduckParser parser, VBE vbe, AddIn addIn, CodeExplorerWindow view) : base(vbe, addIn, view) { _parser = parser; _parser.ParseStarted += _parser_ParseStarted; _parser.ParseCompleted += _parser_ParseCompleted; RegisterControlEvents(); }
public PluginManager(DTE2 _applicationObject, AddIn _addInInstance) { this._applicationObject =_applicationObject; this._addInInstance = _addInInstance; menuManager = new MenuManager(_applicationObject); windowManager = new WindowManager(_applicationObject, _addInInstance); }
/// <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) { _addInInstance = (AddIn)addInInst; IObjectExplorerService objectExplorer = ServiceCache.GetObjectExplorer(); IObjectExplorerEventProvider provider = (IObjectExplorerEventProvider)objectExplorer.GetService(typeof(IObjectExplorerEventProvider)); provider.SelectionChanged += new NodesChangedEventHandler(Provider_SelectionChanged); }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; buildBegin = _applicationObject.Events.BuildEvents; buildDone = _applicationObject.Events.BuildEvents; System.Diagnostics.Debug.WriteLine("Connected!"); }
public BIDSHelperPluginReference(Type t, DTE2 applicationObject, AddIn addInInstance, Connect addinCore) { pluginType = t; _applicationObject = applicationObject; _addInInstance = addInInstance; _core = addinCore; }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if(connectMode == ext_ConnectMode.ext_cm_UISetup) { object []contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; string toolsMenuName; try { //If you would like to move the command to a different menu, change the word "Tools" to the // English version of the menu. This code will take the culture, append on the name of the menu // then add the command to that menu. You can find a list of all the top-level menus in the file // CommandBar.resx. ResourceManager resourceManager = new ResourceManager("Tab.Right.Click.CommandBar", Assembly.GetExecutingAssembly()); CultureInfo cultureInfo = new System.Globalization.CultureInfo(_applicationObject.LocaleID); string resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools"); toolsMenuName = resourceManager.GetString(resourceName); } catch { //We tried to find a localized version of the word Tools, but one was not found. // Default to the en-US word, which may work for the current culture. toolsMenuName = "Tools"; } //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"]; //Find the Tools command bar on the MenuBar command bar: CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName]; CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl; //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in, // just make sure you also update the QueryStatus/Exec method to include the new command names. try { //Add a command to the Commands collection: Command command = commands.AddNamedCommand2(_addInInstance, "Tab.Right.Click", "Tab.Right.Click", "Executes the command for Tab.Right.Click", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); //Add a control for the command to the tools menu: if((command != null) && (toolsPopup != null)) { command.AddControl(toolsPopup.CommandBar, 1); } } catch(System.ArgumentException) { //If we are here, then the exception is probably because a command with that name // already exists. If so there is no need to recreate the command and we can // safely ignore the exception. } } }
protected DockableToolwindowPresenter(VBE vbe, AddIn addin, IDockableUserControl view) { _vbe = vbe; _addin = addin; _logger = LogManager.GetCurrentClassLogger(); _logger.Trace(string.Format("Initializing Dockable Panel ({0})", GetType().Name)); UserControl = view as UserControl; _window = CreateToolWindow(view); }
public Plugin(DTE2 application, AddIn addIn, string panelName, string connectPath) { // TODO: This can be figured out from traversing the assembly and locating the Connect class... m_connectPath = connectPath; m_application = application; m_addIn = addIn; m_outputPane = AquireOutputPane(application, panelName); }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; _debug = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add("Solution Settings Loader"); Output("loaded..."); _applicationObject.Events.SolutionEvents.Opened += SolutionEvents_Opened; Output("listening for solution load..."); }
public AddInAdapter(object addInInst) { _addInInstance = (AddIn)addInInst; _applicationObject = (DTE2)_addInInstance.DTE; _CommandEvents = _applicationObject.Events.get_CommandEvents("{52692960-56BC-4989-B5D3-94C47A513E8D}", 1); _CommandEvents.AfterExecute += new _dispCommandEvents_AfterExecuteEventHandler(_CommandEvents_AfterExecute); _CommandEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(_CommandEvents_BeforeExecute); }
protected override void GenerateDrawings() { if (Subassemblies == null) { return; } var selectedSubassemblies = Subassemblies.Where(x => x.IsSelected == true).ToList(); if (selectedSubassemblies.Count == 0) { ShowWarningMessageBox("No subassemblies are selected."); return; } foreach (var assembly in selectedSubassemblies) { var drawingDocument = CreateDrawingDocument(); var sheet = drawingDocument.ActiveSheet; var topRightCorner = sheet.TopRightCorner(); try { // 1. Alter formatting of custom properties. SetCustomPropertyFormat(assembly.Parts); // 2. Add base view. var baseView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.CenterPoint(), Scale: Scale, ViewOrientation: ViewOrientationTypeEnum.kFrontViewOrientation, ViewStyle: DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); baseView.AddTopAndLeftProjectedViews( addDimensions: true, drawingDistance: 0.5 ); baseView.AddPartName( partName: baseView.ReferencedDocumentDescriptor.DisplayName.RemoveExtension(), drawingDistance: 0.5 ); // 3. Add part list to the top right corner. var partsList = sheet.AddPartsList(assembly.Document, PartsListLevelEnum.kStructured); // 4. Add base "ISO TOP Right", Hidden line removed, Shaded base view of the subassembly in the drawing's top right corner. var perspectiveView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.TopRightPoint(), Scale: PerspectiveScale, ViewOrientation: ViewOrientationTypeEnum.kIsoTopRightViewOrientation, // DrawingViewStyleEnum.kShadedDrawingViewStyle results in difficult to read printouts - replacing with kHiddenLineDrawingViewStyle. ViewStyle: DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); var margin = sheet.Margin(); perspectiveView.Fit( new Rectangle( AddIn.CreatePoint2D( ((sheet.Width - margin.Right) * 3 + margin.Left) / 4 + 1, ((sheet.Height - margin.Top) * 3 + margin.Bottom) / 4 + 1 ), AddIn.CreatePoint2D( topRightCorner.X - 1, topRightCorner.Y - 1 ) ) ); perspectiveView.Position = AddIn.CreatePoint2D( perspectiveView.Position.X, perspectiveView.Position.Y - partsList.RangeBox.Height() ); } catch (Exception ex) { ShowWarningMessageBox(ex.ToString()); } } }
/// <summary>实现 IDTExtensibility2 接口的 OnConnection 方法。接收正在加载外接程序的通知。</summary> /// <param term='application'>宿主应用程序的根对象。</param> /// <param term='connectMode'>描述外接程序的加载方式。</param> /// <param term='addInInst'>表示此外接程序的对象。</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { m_applicationObject = (DTE2)application; m_addInInstance = (AddIn)addInInst; if ((connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup) && m_socket == null) { initializeCallback(); object [] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)m_applicationObject.Commands; string toolsMenuName = "Tools"; //将此命令置于“工具”菜单上。 //查找 MenuBar 命令栏,该命令栏是容纳所有主菜单项的顶级命令栏: Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)m_applicationObject.CommandBars)["MenuBar"]; //在 MenuBar 命令栏上查找“工具”命令栏: // CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName]; // CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl; m_menuBarObj = menuBarCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, true); m_menuBarObj.Caption = "Code Atlas"; CommandBarPopup toolsPopup = (CommandBarPopup)m_menuBarObj; // 增加工具栏 //m_toolBarObj = m_applicationObject.Commands.AddCommandBar("Code Atlas Tools", vsCommandBarType.vsCommandBarTypeToolbar); //如果希望添加多个由您的外接程序处理的命令,可以重复此 try/catch 块, // 只需确保更新 QueryStatus/Exec 方法,使其包含新的命令名。 try { foreach (Command cmd in commands) { foreach (CommandObj cmdObj in m_commandList) { if (cmd.Name == "CodeAtlas.Connect." + cmdObj.name) { cmdObj.command = cmd; } } } int nCommand = m_commandList.Length; for (int ithCmd = 0; ithCmd < nCommand; ++ithCmd) { if (m_commandList[ithCmd].command == null) { m_commandList[ithCmd].command = commands.AddNamedCommand2( m_addInInstance, m_commandList[ithCmd].name, m_commandList[ithCmd].displayName, "Executes the command for CodeAtlas", false, Type.Missing, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton); } Command cmd = m_commandList[ithCmd].command; //将对应于该命令的控件添加到“工具”菜单: cmd.AddControl(toolsPopup.CommandBar, ithCmd + 1); //cmd.AddControl(m_toolBarObj, ithCmd + 1); string key = m_commandList[ithCmd].key; if (key != null && key.Length > 0) { cmd.Bindings = key; //cmd.Bindings = "文本编辑器::alt+LEFT"; } } } catch (System.ArgumentException exception) { //如果出现此异常,原因很可能是由于具有该名称的命令 // 已存在。如果确实如此,则无需重新创建此命令,并且 // 可以放心忽略此异常。 } m_socket = new SocketThread("127.0.0.1", 12346, "127.0.0.1", 12345, onSocketCallback); m_socket.run(); } }
public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions) { Debug.Assert(Class != null && Class.Length > 0); return(AddIn.CreateObject(Class)); }
public DefaultDialogPanelDescriptor(string id, string label, AddIn addin, string dialogPanelPath) : this(id, label) { this.addin = addin; this.dialogPanelPath = dialogPanelPath; }
public DimensionOptimizationReportPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { }
public RubberduckModule(IKernel kernel, VBE vbe, AddIn addin) { _kernel = kernel; _vbe = vbe; _addin = addin; }
public BimlExpandPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { }
protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { base.OnMouseDown(arg); if (Editor.ActiveLayer != null) { try { UID uid = new UIDClass(); uid.Value = ThisAddIn.IDs.EditForm; IDockableWindow dockWin = ArcMap.DockableWindowManager.GetDockableWindow(uid); EditForm editForm = AddIn.FromID <EditForm.AddinImpl>(ThisAddIn.IDs.EditForm).UI; IEnvelope envelop = newEnvelopeFeedback.Stop(); Position tlCorner, brCorner; if (envelop.UpperLeft.IsEmpty) { tlCorner = Raster.ScreenCoor2RasterCoor(arg.X, arg.Y, (IRasterLayer)Editor.ActiveLayer); brCorner = tlCorner; } else { tlCorner = Raster.MapCoor2RasterCoor(envelop.UpperLeft, (IRasterLayer)Editor.ActiveLayer); brCorner = Raster.MapCoor2RasterCoor(envelop.LowerRight, (IRasterLayer)Editor.ActiveLayer); } if (!IsIntersect(tlCorner, brCorner, maxIndex)) { editForm.ClearValues(); return; } tlCorner.Adjust(0, 0, maxIndex.Column, maxIndex.Row); brCorner.Adjust(0, 0, maxIndex.Column, maxIndex.Row); // Show symbols of selected pixels for (int row = tlCorner.Row; row <= brCorner.Row; row++) { for (int col = tlCorner.Column; col <= brCorner.Column; col++) { Position pos = new Position(col, row); if (!Editor.Selections.Exists(pos)) { Pixel pixel = new Pixel(pos); pixel.GraphicElement = Display.DrawBox(pixel.Position, Editor.GetSelectionSymbol(), Editor.ActiveLayer); Editor.Selections.Add(pixel); } } } Display.Refresh(); IRasterLayer rasterLayer = (IRasterLayer)Editor.ActiveLayer; double[,] values = Raster.GetValues(tlCorner, brCorner, rasterLayer.Raster); editForm.SetValues(tlCorner, brCorner, values); // If there is only one value, select that. if (values.Length == 1) { editForm.RasterGridView[0, 0].Selected = false; editForm.RasterGridView[1, 0].Selected = true; } if (!dockWin.IsVisible()) { dockWin.Show(true); } } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); } } }
public UnloadAllProjectsCommand(DTE2 dte, AddIn addIn) : base(dte) { }
/// <summary>实现 IDTExtensibility2 接口的 OnConnection 方法。接收正在加载外接程序的通知。</summary> /// <param term='application'>宿主应用程序的根对象。</param> /// <param term='connectMode'>描述外接程序的加载方式。</param> /// <param term='addInInst'>表示此外接程序的对象。</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; }
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { this._applicationObject = (DTE2)application; this._addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup || connectMode == ext_ConnectMode.ext_cm_Startup) { object[] array = new object[0]; Commands2 commands = (Commands2)this._applicationObject.Commands; string index = "Tools"; CommandBar commandBar = ((CommandBars)this._applicationObject.CommandBars)["MenuBar"]; CommandBarControl commandBarControl = commandBar.Controls[index]; CommandBarPopup commandBarPopup = (CommandBarPopup)commandBarControl; CommandBars commandBars = (CommandBars)this._applicationObject.DTE.CommandBars; CommandBar commandBar2 = commandBars["Project"]; CommandBar commandBar3 = commandBars["Item"]; CommandBar commandBar4 = commandBars["Folder"]; try { CommandBarControl commandBarControl2 = commandBar2.Controls.Add(MsoControlType.msoControlButton, 1, "", 1, true); commandBarControl2.Tag = "ConnectConfig"; commandBarControl2.Caption = "wtf配置连接"; commandBarControl2.TooltipText = "ConnectConfig"; this.connectItemHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl2); this.connectItemHandler.Click += ConnectItem_Click; CommandBarControl commandBarControl3 = commandBar2.Controls.Add(MsoControlType.msoControlButton, 1, "", 2, true); commandBarControl3.Tag = "AddRuleCode"; commandBarControl3.Caption = "wtf新增业务层"; commandBarControl3.TooltipText = "AddRuleCode"; this.addRuleCodeItemHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl3); this.addRuleCodeItemHandler.Click += AddRuleCodeItem_Click; CommandBarControl commandBarControl4 = commandBar2.Controls.Add(MsoControlType.msoControlButton, 1, "", 3, true); commandBarControl4.Tag = "AddCodeConfig"; commandBarControl4.Caption = "wtf一键生成配置文件"; commandBarControl4.TooltipText = "AddCodeConfig"; this.AddCodeConfigItemHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl4); this.AddCodeConfigItemHandler.Click += AddCodeConfigItem_Click; CommandBarControl commandBarControl5 = commandBar3.Controls.Add(MsoControlType.msoControlButton, 1, "", 1, true); commandBarControl5.Tag = "Update"; commandBarControl5.Caption = "wtf更新代码"; commandBarControl5.TooltipText = "Update"; this.updateHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl5); this.updateHandler.Click += CSItem_Click; CommandBarControl commandBarControl6 = commandBar3.Controls.Add(MsoControlType.msoControlButton, 1, "", 2, true); commandBarControl6.Tag = "Update"; commandBarControl6.Caption = "wtf更新实体和访问层"; commandBarControl6.TooltipText = "Update"; this.updateEDHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl6); this.updateEDHandler.Click += CSEDItem_Click; CommandBarControl commandBarControl7 = commandBar3.Controls.Add(MsoControlType.msoControlButton, 1, "", 3, true); commandBarControl7.Tag = "SqlEdit"; commandBarControl7.Caption = "wtf新增编辑页"; commandBarControl7.TooltipText = "SqlEdit"; this.SqlEditHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl7); this.SqlEditHandler.Click += SqlEditItem_Click; CommandBarControl commandBarControl8 = commandBar3.Controls.Add(MsoControlType.msoControlButton, 1, "", 4, true); commandBarControl8.Tag = "SqlLsit"; commandBarControl8.Caption = "wtf新增列表页"; commandBarControl8.TooltipText = "SqlLsit"; this.SqlListHandler = (CommandBarEvents)this._applicationObject.DTE.Events.get_CommandBarEvents(commandBarControl8); this.SqlListHandler.Click += SqlListItem_Click; Command command = commands.AddNamedCommand2(this._addInInstance, "WTFCode", "WTFCode", "Executes the command for WTFCode", true, 59, ref array, 3, 3, vsCommandControlType.vsCommandControlTypeButton); if (command != null && commandBarPopup != null) { command.AddControl(commandBarPopup.CommandBar, 1); } } catch (ArgumentException) { } } }
public PerformanceVisualizationPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { this.events = this.ApplicationObject.Events.DTEEvents; this.events.ModeChanged += new _dispDTEEvents_ModeChangedEventHandler(DTEEvents_ModeChanged); }
public ToDoExplorerDockablePresenter(IRubberduckParser parser, IEnumerable <ToDoMarker> markers, VBE vbe, AddIn addin, IToDoExplorerWindow window) : base(vbe, addin, window) { _parser = parser; _markers = markers; Control.NavigateToDoItem += NavigateToDoItem; Control.RefreshToDoItems += RefreshToDoList; Control.SortColumn += SortColumn; }
void ShowInstallableAddIns(IList <InstallableAddIn> addInPackages) { shownAddInPackages = addInPackages; ignoreFocusChange = true; splitContainer.Panel2Collapsed = false; dependencyTable.Visible = false; runActionButton.Visible = true; uninstallButton.Visible = false; selectedAction = AddInAction.Install; List <string> installAddIns = new List <string>(); List <string> updateAddIns = new List <string>(); foreach (InstallableAddIn addInPackage in addInPackages) { string identity = addInPackage.AddIn.Manifest.PrimaryIdentity; AddIn foundAddIn = null; foreach (AddIn addIn in AddInTree.AddIns) { if (addIn.Action != AddInAction.Install && addIn.Manifest.Identities.ContainsKey(identity)) { foundAddIn = addIn; break; } } if (foundAddIn != null) { updateAddIns.Add(addInPackage.AddIn.Name); } else { installAddIns.Add(addInPackage.AddIn.Name); } } if (updateAddIns.Count == 0) { actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionInstall"); } else if (installAddIns.Count == 0) { actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionUpdate"); } else { actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionInstall") + " + " + ResourceService.GetString("AddInManager.ActionUpdate"); } List <AddIn> addInList = new List <AddIn>(); StringBuilder b = new StringBuilder(); if (installAddIns.Count == 1) { b.Append("Installs the AddIn " + installAddIns[0]); } else if (installAddIns.Count > 1) { b.Append("Installs the AddIns " + string.Join(",", installAddIns.ToArray())); } if (updateAddIns.Count > 0 && installAddIns.Count > 0) { b.Append("; "); } if (updateAddIns.Count == 1) { b.Append("Updates the AddIn " + updateAddIns[0]); } else if (updateAddIns.Count > 1) { b.Append("Updates the AddIns " + string.Join(",", updateAddIns.ToArray())); } actionDescription.Text = b.ToString(); runActionButton.Enabled = ShowDependencies(addInList, ShowDependencyMode.Enable); }
public void Init() { AddInPathHelper helper = new AddInPathHelper("PythonBinding"); pythonAddIn = helper.CreateDummyAddInInsideAddInTree(); }
/// <summary> /// Initialize library /// </summary> /// <param name="loader"></param> /// <param name="dte2"></param> /// <param name="addIn"></param> private void init(ILoader loader, DTE2 dte2, AddIn addIn) { try { library = loader.load(dte2, addIn.SatelliteDllPath, dte2.RegistryRoot); log.info("Library: loaded from '{0}' :: v{1} [{2}] API: v{3} /'{4}':{5}", library.Dllpath, library.Version.Number.ToString(), library.Version.BranchSha1, library.Version.Bridge.Number.ToString(2), library.Version.BranchName, library.Version.BranchRevCount); coreCommand = new CoreCommand(library); coreCommand.attachCoreCommandListener(); updateBuildType(Environment.GetCommandLineArgs()); adviseEvents(); return; } catch (DllNotFoundException ex) { log.info(ex.Message); log.info(new String('.', 80)); log.info("How about:"); log.info(""); log.info("* Install vsSolutionBuildEvent as plugin for your Visual Studio v{0}", dte2.Version); log.info("* Or manually place the 'vsSolutionBuildEvent.dll' with dependencies into AddIn folder: '{0}\\'", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); log.info(""); log.info("See documentation for more details:"); log.info("- http://vssbe.r-eg.net"); log.info("- http://visualstudiogallery.msdn.microsoft.com/0d1dbfd7-ed8a-40af-ae39-281bfeca2334/"); log.info(""); log.info("Minimum requirements: vsSolutionBuildEvent.dll v{0}", loader.MinVersion.ToString()); log.info(new String('.', 80)); } catch (ReflectionTypeLoadException ex) { log.info(ex.ToString()); log.info(new String('.', 80)); foreach (FileNotFoundException le in ex.LoaderExceptions) { log.info("{2} {0}{3} {0}{0}{4} {0}{1}", Environment.NewLine, new String('~', 80), le.FileName, le.Message, le.FusionLog); } } catch (Exception ex) { log.info("Error with advising '{0}'", ex.ToString()); } termination(true); }
public ToDoExplorerDockablePresenter(IRubberduckParser parser, IEnumerable <ToDoMarker> markers, VBE vbe, AddIn addin, IToDoExplorerWindow window, GridViewSort <ToDoItem> gridViewSort) : base(vbe, addin, window) { _parser = parser; _markers = markers; _gridViewSort = gridViewSort; _view = window; _view.NavigateToDoItem += NavigateToDoItem; _view.RefreshToDoItems += RefreshToDoList; _view.RemoveToDoMarker += RemoveMarker; _view.SortColumn += SortColumn; }
public override bool CanExecute() { return(AddIn.IsCurrentDocumentExtension("sql") && AddIn.AllText.Length > 0 && AddIn.CurrentSelection.Length == 0); }
public ToDoExplorerDockablePresenter(Parser parser, IEnumerable <ToDoMarker> markers, VBE vbe, AddIn addin) : base(vbe, addin, new ToDoExplorerWindow()) { _parser = parser; _markers = markers; Control.NavigateToDoItem += NavigateToDoItem; Control.RefreshToDoItems += RefreshToDoList; RefreshToDoList(this, EventArgs.Empty); }
/// <summary> /// Initialises the host. /// </summary> /// <param name="applicationObject">The application object.</param> /// <param name="addInInstance">The add in instance.</param> public void InitialiseHost(DTE2 applicationObject, AddIn addInInstance) { this.applicationObject = applicationObject; this.addInInstance = addInInstance; LoadConfiguration(); }
public CodeInspectionsDockablePresenter(Parser parser, IEnumerable <IInspection> inspections, VBE vbe, AddIn addin) : base(vbe, addin, new CodeInspectionsWindow()) { _parser = parser; _inspections = inspections.ToList(); Control.RefreshCodeInspections += OnRefreshCodeInspections; Control.NavigateCodeIssue += OnNavigateCodeIssue; Control.QuickFix += OnQuickFix; }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; string toolsMenuName; try { //If you would like to move the command to a different menu, change the word "Tools" to the // English version of the menu. This code will take the culture, append on the name of the menu // then add the command to that menu. You can find a list of all the top-level menus in the file // CommandBar.resx. string resourceName; ResourceManager resourceManager = new ResourceManager("Randoop.CommandBar", Assembly.GetExecutingAssembly()); CultureInfo cultureInfo = new CultureInfo(_applicationObject.LocaleID); if (cultureInfo.TwoLetterISOLanguageName == "zh") { System.Globalization.CultureInfo parentCultureInfo = cultureInfo.Parent; resourceName = String.Concat(parentCultureInfo.Name, "Tools"); } else { resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools"); } toolsMenuName = resourceManager.GetString(resourceName); } catch { //We tried to find a localized version of the word Tools, but one was not found. // Default to the en-US word, which may work for the current culture. toolsMenuName = "Tools"; } //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"]; //Find the Tools command bar on the MenuBar command bar: CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName]; CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl; //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in, // just make sure you also update the QueryStatus/Exec method to include the new command names. try { //Add a command to the Commands collection: //Command command = commands.AddNamedCommand2(_addInInstance, "Randoop", "Randoop...", "Executes the command for Randoop", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); Command command = commands.AddNamedCommand2(_addInInstance, "Randoop", "Randoop...", "Executes the command for Randoop", true, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); //Add a control for the command to the tools menu: if ((command != null) && (toolsPopup != null)) { command.AddControl(toolsPopup.CommandBar, 1); } } catch (System.ArgumentException) { //If we are here, then the exception is probably because a command with that name // already exists. If so there is no need to recreate the command and we can // safely ignore the exception. } //TODO: right click to activate (p2) //_menuManager = new MenuManager(_applicationObject); //Dictionary<string, CommandBase> cmds = new Dictionary<string, CommandBase>(); //CommandBase randoopCommand = new RandoopCommand(_applicationObject); //cmds.Add("RandoopCommand", randoopCommand); //CommandBarPopup popupMenu = _menuManager.CreatePopupMenu("Assembly", _rm.GetString("RandoopMenuCaption")); //AddCommandMenu(popupMenu, cmds["RandoopCommand"], 1); #region post-randoop-functions //{ // //// Add a popup control to group our buttons under --- add submenu (new on Sep. 2012) // _cmdBarPopup = (CommandBarPopup)toolsPopup.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 2, true); // _cmdBarPopup.Caption = "post Randoop"; // _btnReduce = (CommandBarButton)_cmdBarPopup.Controls.Add(MsoControlType.msoControlButton, Type.Missing, // Type.Missing, Type.Missing, true); // _btnReduce.Style = MsoButtonStyle.msoButtonIconAndCaption; // _btnReduce.Caption = "Reducer"; // _btnReduce.TooltipText = "This command removes tests that it considers redundant"; // ////_btnFreebie.Picture = ImageConverter.ImageToIPicture(Resources.Resource.BarCode); // _btnReduce.Click += new _CommandBarButtonEvents_ClickEventHandler(_btnReduce_Click); // _btnMinimize = (CommandBarButton)_cmdBarPopup.Controls.Add(MsoControlType.msoControlButton, Type.Missing, // Type.Missing, Type.Missing, true); // _btnMinimize.Caption = "Minimizer"; // _btnMinimize.TooltipText = "This command transforms each test into a smaller one that still exhibits the same exception"; // //_btnLicensed.FaceId = 1845; // _btnMinimize.Click += new _CommandBarButtonEvents_ClickEventHandler(_btnMinimize_Click); // _btnToMSTest = (CommandBarButton)_cmdBarPopup.Controls.Add(MsoControlType.msoControlButton, Type.Missing, // Type.Missing, Type.Missing, true); // _btnToMSTest.Style = MsoButtonStyle.msoButtonIconAndCaption; // _btnToMSTest.Caption = "Converter to MSTest"; // _btnToMSTest.Click += new _CommandBarButtonEvents_ClickEventHandler(_btnMSTest_Click); //} #endregion post-randoop-functions } }
private readonly CodeInspectionsDockablePresenter _presenter; //if presenter goes out of scope, so does it's toolwindow Issue #169 public CodeInspectionsMenu(VBE vbe, AddIn addIn, CodeInspectionsWindow view, CodeInspectionsDockablePresenter presenter) : base(vbe, addIn) { _window = view; _presenter = presenter; }
public AboutForm(AddIn addIn) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); boldFont = new Font(Font, FontStyle.Bold); List <string> titles = new List <string>(); List <string> values = new List <string>(); this.Text = addIn.Name; closeButton.Text = ResourceService.GetString("Global.CloseButtonText"); titles.Add("AddIn name"); values.Add(addIn.Name); if (addIn.Manifest.PrimaryVersion != null && addIn.Manifest.PrimaryVersion.ToString() != "0.0.0.0") { titles.Add("Version"); values.Add(addIn.Manifest.PrimaryVersion.ToString()); } if (addIn.Properties["author"].Length > 0) { titles.Add("Author"); values.Add(addIn.Properties["author"]); } if (addIn.Properties["copyright"].Length > 0) { if (!addIn.Properties["copyright"].StartsWith("prj:")) { titles.Add("Copyright"); values.Add(addIn.Properties["copyright"]); } } if (addIn.Properties["license"].Length > 0) { titles.Add("License"); values.Add(addIn.Properties["license"]); } if (addIn.Properties["url"].Length > 0) { titles.Add("Website"); values.Add(addIn.Properties["url"]); } if (addIn.Properties["description"].Length > 0) { titles.Add("Description"); values.Add(addIn.Properties["description"]); } titles.Add("AddIn file"); values.Add(FileUtility.NormalizePath(addIn.FileName)); titles.Add("Internal name"); values.Add(addIn.Manifest.PrimaryIdentity); table.RowCount = titles.Count + 1; table.RowStyles.Clear(); for (int i = 0; i < titles.Count; i++) { table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); AddRow(titles[i], values[i], i); } }
public CodeInspectionsDockablePresenter(VBE vbe, AddIn addin, CodeInspectionsWindow window) : base(vbe, addin, window) { }
public MenuBuilder(DTE2 application, AddIn addin) { _application = application; _addin = addin; }
public override bool CanExecute() { return(AddIn.IsCurrentDocumentExtension("sql")); }
/// <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) { Logger.Info(string.Format("Initializing WakaTime v{0}", _version)); try { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; _editorVersion = _applicationObject.Version; _docEvents = _applicationObject.Events.DocumentEvents; _docEvents.DocumentOpened += DocEventsOnDocumentOpened; _docEvents.DocumentSaved += DocEventsOnDocumentSaved; _windowsEvents = _applicationObject.Events.WindowEvents; _windowsEvents.WindowActivated += WindowsEventsOnWindowActivated; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { var contextGuids = new object[] { }; var commands = (Commands2)_applicationObject.Commands; const string toolsMenuName = "Tools"; //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: var menuBarCommandBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"]; //Find the Tools command bar on the MenuBar command bar: var toolsControl = menuBarCommandBar.Controls[toolsMenuName]; var toolsPopup = (CommandBarPopup)toolsControl; //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in, // just make sure you also update the QueryStatus/Exec method to include the new command names. try { //Add a command to the Commands collection: var command = commands.AddNamedCommand2(_addInInstance, "WakaTime", "WakaTime", "WakaTime Settings", true, 59, ref contextGuids, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); //Add a control for the command to the tools menu: if ((command != null) && (toolsPopup != null)) { command.AddControl(toolsPopup.CommandBar, 1); } } catch (ArgumentException) { //If we are here, then the exception is probably because a command with that name // already exists. If so there is no need to recreate the command and we can // safely ignore the exception. } } // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { var dialogResult = MessageBox.Show(@"Let's download and install Python now?", @"WakaTime requires Python", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { var url = PythonManager.PythonDownloadUrl; Downloader.DownloadPython(url, WakaTimeConstants.UserConfigDir); } else { MessageBox.Show( @"Please install Python (https://www.python.org/downloads/) and restart SQL Server Management Studio to enable the WakaTime plugin.", @"WakaTime", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (!DoesCliExist() || !IsCliLatestVersion()) { try { Directory.Delete(string.Format("{0}\\wakatime-master", WakaTimeConstants.UserConfigDir), true); } catch { /* ignored */ } Downloader.DownloadCli(WakaTimeConstants.CliUrl, WakaTimeConstants.UserConfigDir); } GetSettings(); if (string.IsNullOrEmpty(ApiKey)) { PromptApiKey(); } Logger.Info(string.Format("Finished initializing WakaTime v{0}", _version)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
public UsedDatasetsPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { }
/// <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) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; string toolsMenuName; try { //If you would like to move the command to a different menu, change the word "Tools" to the // English version of the menu. This code will take the culture, append on the name of the menu // then add the command to that menu. You can find a list of all the top-level menus in the file // CommandBar.resx. string resourceName; ResourceManager resourceManager = new ResourceManager("TracExplorer.VSTrac.CommandBar", Assembly.GetExecutingAssembly()); CultureInfo cultureInfo = new CultureInfo(_applicationObject.LocaleID); if (cultureInfo.TwoLetterISOLanguageName == "zh") { System.Globalization.CultureInfo parentCultureInfo = cultureInfo.Parent; resourceName = String.Concat(parentCultureInfo.Name, "View"); } else { resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "View"); } toolsMenuName = resourceManager.GetString(resourceName); } catch { //We tried to find a localized version of the word Tools, but one was not found. // Default to the en-US word, which may work for the current culture. toolsMenuName = "View"; } //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"]; //Find the Tools command bar on the MenuBar command bar: CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName]; CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl; //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in, // just make sure you also update the QueryStatus/Exec method to include the new command names. try { //Add a command to the Commands collection: Command command = commands.AddNamedCommand2(_addInInstance, "TracExplorer", "Trac Explorer", "Opens The Trac Explorer Window", false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); //Add a control for the command to the tools menu: if ((command != null) && (toolsPopup != null)) { command.AddControl(toolsPopup.CommandBar, 1); } } catch (System.ArgumentException) { //If we are here, then the exception is probably because a command with that name // already exists. If so there is no need to recreate the command and we can // safely ignore the exception. } } }