/// <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 (e.g. command line or UI). This is unused since /// the add-in functions the same regardless of how it was loaded. /// </param> /// <param name="addInInst">Object representing this Add-in.</param> /// <param name="custom">Unused, but could contain host specific data for the add-in.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection( object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { dte_ = (DTE2)application; debuggerEvents_ = dte_.Events.DebuggerEvents; debuggerEvents_.OnEnterDesignMode += DebuggerOnEnterDesignMode; debuggerEvents_.OnEnterRunMode += DebuggerOnEnterRunMode; commandEvents_ = dte_.Events.CommandEvents; commandEvents_.AfterExecute += CommandEventsAfterExecute; try { webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item( Strings.WebServerOutputWindowTitle); } catch (ArgumentException) { // This exception is expected if the window pane hasn't been created yet. webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Add( Strings.WebServerOutputWindowTitle); } }
/// <summary> /// Tries the open document. /// </summary> /// <param name="application">The application.</param> /// <param name="path">The path.</param> /// <returns></returns> public static bool TryOpenDocument(DTE2 application, string path) { // Go through each document in the solution. foreach(Document document in application.Documents) { if(String.CompareOrdinal(document.FullName, path) == 0) { // The document is open, we just need to activate it. if (document.Windows.Count > 0) { document.Activate(); return true; } } } // The document isn't open - does it exist? if (File.Exists(path)) { try { application.Documents.Open(path, "Text", false); return true; } catch (Exception) { // We can't open the doc. return false; } } // We couldn't open the document. return false; }
public override void OnCommand(DTE2 application, OutputWindowPane pane) { if (application.SelectedItems.Count == 0) { OnExecute(null, null, pane); } foreach (SelectedItem sel in application.SelectedItems) { if (m_executeForFileItems && sel.ProjectItem != null && m_fileItemGUID == sel.ProjectItem.Kind) { //The try catch block belowe fixed issue 57: //http://github.com/spdr870/gitextensions/issues/#issue/57 try { OnExecute(sel, sel.ProjectItem.get_FileNames(0), pane); } catch (ArgumentException) { if (sel.ProjectItem.FileCount > 0) { OnExecute(sel, sel.ProjectItem.get_FileNames(1), pane); } else { throw; } } } else if (m_executeForProjectItems && sel.Project != null) OnExecute(sel, sel.Project.FullName, pane); } }
public RoslynCodeAnalysisHelper(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider, IVsActivityLog log) { _view = view; _document = document; _text = new Adornment(); _tasks = tasks; _serviceProvider = serviceProvider; _log = log; _dispatcher = Dispatcher.CurrentDispatcher; _adornmentLayer = view.GetAdornmentLayer(RoslynCodeAnalysisFactory.LayerName); _view.ViewportHeightChanged += SetAdornmentLocation; _view.ViewportWidthChanged += SetAdornmentLocation; _text.MouseUp += (s, e) => dte.ExecuteCommand("View.ErrorList"); _timer = new Timer(750); _timer.Elapsed += (s, e) => { _timer.Stop(); System.Threading.Tasks.Task.Run(() => { _dispatcher.Invoke(new Action(() => Update(false)), DispatcherPriority.ApplicationIdle, null); }); }; _timer.Start(); }
public static Assembly GetAssembly(DTE2 dte, string assemblyName) { Assembly assembly = null; if (_assemblyCache.ContainsKey(assemblyName)) { assembly = _assemblyCache[assemblyName]; } else { lock (_syncRoot) { if (_assemblyCache.ContainsKey(assemblyName)) { assembly = _assemblyCache[assemblyName]; } else { var assemblyPath = GetAssemblyFullName(dte, assemblyName); assembly = Assembly.LoadFrom(assemblyPath); _assemblyCache[assemblyName] = assembly; } } } return assembly; }
public RemoveWhitespaceOnSave(IVsTextView textViewAdapter, IWpfTextView view, DTE2 dte, ITextDocument document) { textViewAdapter.AddCommandFilter(this, out _nextCommandTarget); _view = view; _dte = dte; _document = document; }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { DTE dte = (DTE)GetService(typeof(DTE)); DTE2 = dte as DTE2; GuidList.gPackage = this; Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // retrieve the installation directory using (RegistryKey rootKey = this.UserRegistryRoot) { using (RegistryKey packageKey = rootKey.OpenSubKey("ExtensionManager\\EnabledExtensions")) { PackageRootPath = packageKey.GetValue(GuidList.guidNPLDebuggerPackagePkgString + ",1.0") as String; } } // create the NPL Debugger NPLDebugger = new NPLDebuggerConnect(DTE2, this); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if ( null != mcs ) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidNPLDebuggerPackageCmdSet, (int)PkgCmdIDList.cmdidNPLDebuggerCommand); MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID ); mcs.AddCommand( menuItem ); // Create the command for the tool window CommandID toolwndCommandID = new CommandID(GuidList.guidNPLDebuggerPackageCmdSet, (int)PkgCmdIDList.cmdidNPLDebuggerTool); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); } }
/// <summary> /// Constructor /// </summary> public CommandManager(DTE2 dte, AddIn addin) { this.dte = dte; this.addIn = addin; commands = new Dictionary<string, CommandBase>(); }
public static void Register(DTE2 dte, MenuCommandService mcs) { _dte = dte; CommandID nestAllId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting); OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId); mcs.AddCommand(menuNestAll); }
public static List<string> GetTextEditorProperties() { System.Type t = Connect.settingsObject.VisualStudioVersion; object obj = Activator.CreateInstance(t, true); dte2 = (DTE2)obj; sln2 = (Solution2)dte2.Solution; // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.90).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 // Nested node doesn't work in C# as done in article with VB. // Tried different separators but have not found the right C# syntax. // Other links: // http://msdn.microsoft.com/en-us/library/ms165644.aspx // http://www.mztools.com/articles/2005/mz2005008.aspx // http://dotnet.dzone.com/articles/structure-visual-studio?page=0,1 EnvDTE.Properties txtEdCS = dte2.get_Properties("TextEditor", "CSharp - Formatting"); EnvDTE.Property prop = null; string msg = null; List<string> propList = new List<string>(); foreach (EnvDTE.Property temp in txtEdCS) { prop = temp; msg = ("Prop Name: " + prop.Name + " VALUE: " + prop.Value) + "\n"; propList.Add(msg); } return propList; }
public CommandBarBuilder(DTE2 dte, AddIn addin) { this.dte = dte; this.addIn = addin; createdControls = new List<CommandBarControl>(); }
protected override void Initialize() { base.Initialize(); _app = (DTE2)GetGlobalService(typeof(DTE)); InitializeMenuCommands(); LoadSettings(); }
internal static void AddNestedFile(DTE2 dte, string parent, string child, BuildActionType type) { // ignore if child doesn't exist if (!File.Exists(child)) return; if (dte == null) return; // if we can't load parent or child already part of solution, don't attempt to change anything ProjectItem parentItem, childItem; if (!TryGetProjectItem(dte.Solution, parent, out parentItem) || TryGetProjectItem(dte.Solution, child, out childItem)) return; // add the child item and save project if (parentItem.ProjectItems == null) Logger.Log("ProjectItems is null. Bad news is about to happen."); childItem = parentItem.ProjectItems.AddFromFile(child); if (childItem != null) { childItem.ContainingProject.Save(); } else { Logger.Log("Could not add child item to project."); } // schedule call to change build action // this is a work around since it seems to ignore property changes until after file saved // and even after that it still ignores it, so async makes it better Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => ChangeBuildActionType(dte, child, type)), DispatcherPriority.Background); }
public ProjectSettingsMenu(DTE2 dte, OleMenuCommandService mcs) { _dte = dte; _mcs = mcs; _dte.Events.SolutionEvents.Opened += SolutionEvents_Opened; }
protected override void Initialize() { base.Initialize(); _dte = GetService(typeof(DTE)) as DTE2; OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; CommandID cmdCustom = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCommandLine); OleMenuCommand customItem = new OleMenuCommand(OpenCustom, cmdCustom); customItem.BeforeQueryStatus += BeforeQueryStatus; mcs.AddCommand(customItem); CommandID cmdCmd = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCmd); MenuCommand cmdItem = new MenuCommand(OpenCmd, cmdCmd); mcs.AddCommand(cmdItem); CommandID cmdPowershell = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenPowershell); MenuCommand powershellItem = new MenuCommand(OpenPowershell, cmdPowershell); mcs.AddCommand(powershellItem); CommandID cmdOptions = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenOptions); MenuCommand optionsItem = new MenuCommand((s, e) => { ShowOptionPage(typeof(Options)); }, cmdOptions); mcs.AddCommand(optionsItem); CommandID cmdExe = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdExecuteCmd); OleMenuCommand exeItem = new OleMenuCommand(ExecuteFile, cmdExe); exeItem.BeforeQueryStatus += BeforeExeQuery; mcs.AddCommand(exeItem); }
public NPLDebuggerConnect(object application, NPLDebuggerPackage package_) { _applicationObject = (DTE2)application; package = package_; CheckRegisterDebugEngine(); }
public SpecRunTestRunnerGateway(IOutputWindowService outputWindowService, IIdeTracer tracer, IProjectScopeFactory projectScopeFactory, DTE2 dte) { this.outputWindowService = outputWindowService; this.dte = dte; this.projectScopeFactory = projectScopeFactory; this.tracer = tracer; }
/// <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); } }
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); }
private static void InsertText(IWpfTextView view, DTE2 dte, string text) { try { dte.UndoContext.Open("Generate text"); using (var edit = view.TextBuffer.CreateEdit()) { if (!view.Selection.IsEmpty) { edit.Delete(view.Selection.SelectedSpans[0].Span); view.Selection.Clear(); } edit.Insert(view.Caret.Position.BufferPosition, text); edit.Apply(); } } catch (Exception ex) { Logger.Log(ex); } finally { dte.UndoContext.Close(); } }
public DocumentDetetionService(Document document, VSProject2 vsProject2, DTE2 dte2, IAssemblyDetectionProvider assemblyDetectionProvider) { _document = document; _vsProject2 = vsProject2; _dte2 = dte2; _assemblyDetectionProvider = assemblyDetectionProvider; }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { DTE dte = (DTE)GetService(typeof(DTE)); DTE2 = dte as DTE2; GuidList.gPackage = this; Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // retrieve the installation directory PackageRootPath = ObtainInstallationFolder() + "\\"; // create the NPL Debugger NPLDebugger = new NPLDebuggerConnect(DTE2, this); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if ( null != mcs ) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidNPLDebuggerPackageCmdSet, (int)PkgCmdIDList.cmdidNPLDebuggerCommand); MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID ); mcs.AddCommand( menuItem ); // Create the command for the tool window CommandID toolwndCommandID = new CommandID(GuidList.guidNPLDebuggerPackageCmdSet, (int)PkgCmdIDList.cmdidNPLDebuggerTool); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); } }
public static Project GetSelectedProject(DTE2 applicationObject) { return (Project) Array.Find(GetProjectsInSolution(applicationObject), delegate(object project) { return IsSelectedUIHierarchyItemAProject(applicationObject, project); }); }
private static IEnumerable<ModelTypeInfo> GetReferencedTypes(DTE2 dte2) { Project activeProject = dte2.ActiveSolutionProjects[0]; var project = activeProject.Object as VSLangProj.VSProject; if (project != null) { foreach (VSLangProj.Reference reference in project.References) { if (reference.SourceProject != null) { if (!File.Exists(reference.Path)) { continue; } // Get type info from assembly List<ModelTypeInfo> modelTypes = ModelReflectionHelper.GetModelTypes (new FileInfo(reference.Path)); foreach (var modelType in modelTypes) { yield return modelType; } } } } }
/// <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); } }
public static void Test1a(DTE2 DTE) { DTE.ItemOperations.NewFile("General\\Object-Role Modeling File", "ORMRolePlayerRequiredModel", ""); ORMTestHooks testHooks = new ORMTestHooks(DTE); ORMTestWindow testWindow = testHooks.FindORMTestWindow(null); if (CommonTestHooks.ActivateToolboxItem(DTE, "ORM Designer", "Entity Type")) { SendKeys.SendWait("{Enter}"); } if (CommonTestHooks.ActivateToolboxItem(DTE, "ORM Designer", "Entity Type")) { SendKeys.SendWait("{Enter}"); } // Find the accesible object for the diagram AccessibleObject accDiagram = CommonTestHooks.FindAccessibleObject( testWindow.AccessibleObject, new AccessiblePathNode[] { new AccessiblePathNode("ORMDiagram") }); // Find the accessible object for the newly added Entity Type AccessibleObject accEntityType = CommonTestHooks.FindAccessibleObject( accDiagram, new AccessiblePathNode[] { new AccessiblePathNode("EntityType", 0) }); // Click on the accessible object for the newly created entity type. testWindow.ClickAccessibleObject(accEntityType); }
public SampleWizardPage(DTE2 application) { _application = application; InitializeComponent(); //AsposeComponents components = new AsposeComponents(); SetComponentsAPIs(); textBoxLocation.Text = GetExamplesRootPath(); //AsposeComponent component; //AsposeComponents.list.TryGetValue(Constants.ASPOSE_COMPONENT, out component); toolStripStatusMessage.Visible = true; toolStripStatusMessage.Text = ""; progressBar1.Visible = false; progressBar1.Value = 0; //rdbCSharp.Enabled = false; //rdbVisualBasic.Enabled = false; //checkAndUpdateRepo(component); //rdbCSharp.Enabled = true; //rdbVisualBasic.Enabled = true; GroupDocsComponent component; GroupDocsComponents.list.TryGetValue(Constants.GROUPDOCS_COMPONENT, out component); string repoPath = GitHelper.getLocalRepositoryPath(component); //PopulateTreeView(repoPath + "/Examples/" ); PopulateTreeView(repoPath + "/Examples/" + (rdbCSharp.Checked ? "CSharp" : "VisualBasic")); }
protected override void Initialize() { base.Initialize(); _dte = GetService(typeof(DTE)) as DTE2; _activityLogger = new ActivityLogger(GetService(typeof(SVsActivityLog)) as IVsActivityLog); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand); OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId); button.BeforeQueryStatus += button_BeforeQueryStatus; mcs.AddCommand(button); CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.SWMenuGroup); OleMenuCommand menuItem = new OleMenuCommand(OpenSettings, menuCommandID); mcs.AddCommand(menuItem); } System.Threading.Tasks.Task.Run(async () => { await System.Threading.Tasks.Task.Delay(100); try { new DynamicTemplateBuilder(_dte, _activityLogger).ProcessTemplates(); } catch (Exception ex) { _activityLogger.Error(ex.ToString()); _dte.StatusBar.Text = @"An error occured while updating templates, check the activity log"; // Leave this for now until we are sure activity logger above works well System.Windows.MessageBox.Show(ex.ToString()); } }); }
public GoDiagramPlayWindow(DTE2 dte) { _dte = dte; lifelines = new Dictionary<string, Lifeline>(); InitializeComponent(); goView1.DefaultTool = new GoToolManager(goView1); }
public frmEEPReport(DTE2 dte2, AddIn addIn, bool isWebReport) { InitializeComponent(); _dte2 = dte2; _addIn = addIn; _isWebReport = isWebReport; }
public DimensionOptimizationReportPlugin(Connect con, DTE2 appObject, AddIn addinInstance) : base(con, appObject, addinInstance) { }
public static IOsbideEvent FromCommand(string commandName, DTE2 dte) { IOsbideEvent oEvent = null; //debugging events if (debugCommands.Contains(commandName)) { DebugActions action = (DebugActions)debugCommands.IndexOf(commandName); DebugEvent debug = new DebugEvent(); debug.SolutionName = dte.Solution.FullName; debug.EventDate = DateTime.UtcNow; //sometimes document name can be null try { debug.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { debug.DocumentName = dte.Solution.FullName; } //add line number if applicable if (action == DebugActions.StepInto || action == DebugActions.StepOut || action == DebugActions.StepOver ) { //line number can be null if there is no document open try { TextSelection debugSelection = dte.ActiveDocument.Selection; debugSelection.SelectLine(); int lineNumber = debugSelection.CurrentLine; debug.LineNumber = lineNumber; debug.DebugOutput = debugSelection.Text; } catch (Exception) { debug.LineNumber = 0; } } //kind of reappropriating this for our current use. Consider refactoring. debug.ExecutionAction = (int)action; //throw the content of the output window into the event if we just stopped debugging if (action == DebugActions.StopDebugging) { OutputWindowPane debugWindow = dte.ToolWindows.OutputWindow.OutputWindowPanes.Item("Debug"); if (debugWindow != null) { TextDocument text = debugWindow.TextDocument; TextSelection selection = text.Selection; selection.StartOfDocument(); selection.EndOfDocument(true); debug.DebugOutput = selection.Text; selection.EndOfDocument(); } } oEvent = debug; } else if (cutCopyPasteCommands.Contains(commandName)) { CutCopyPasteEvent ccp = new CutCopyPasteEvent(); ccp.SolutionName = dte.Solution.FullName; ccp.EventDate = DateTime.UtcNow; ccp.EventAction = cutCopyPasteCommands.IndexOf(commandName); ccp.Content = Clipboard.GetText(); //sometimes document name can be null try { ccp.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { ccp.DocumentName = dte.Solution.FullName; } oEvent = ccp; } return(oEvent); }
public SelectExistingViewModel(DTE2 dte) : base() { this.Dte = dte; ModelViews = new ObservableCollection <ModelViewSerializable>(); }
/// <summary> /// Runs custom wizard logic at the beginning of a template wizard run. /// </summary> /// <param name="automationObject"></param> /// <param name="replacementsDictionary"></param> /// <param name="runKind"></param> /// <param name="customParams"></param> public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { Diagnostics.Enter(); myDTE = (DTE2)automationObject; DialogResult dialogResult = DialogResult.Cancel; try { // Display a form to the user. The form collects // input for the custom message. inputForm = new DeviceDriverForm(TL); // Pass our trace logger into the form so all Wizard trace goes into one file dialogResult = inputForm.ShowDialog(); } catch (Exception ex) { TL.LogMessageCrLf("RunStarted", "Form Exception: " + ex.ToString()); MessageBox.Show("Form Exception: " + ex.ToString()); } if (dialogResult != DialogResult.OK) { throw new WizardCancelledException("The wizard has been cancelled"); } try { // Save user inputs. DeviceId = inputForm.DeviceId; DeviceName = inputForm.DeviceName; DeviceClass = inputForm.DeviceClass; DeviceInterface = inputForm.DeviceInterface; InterfaceVersion = inputForm.InterfaceVersion; Namespace = inputForm.Namespace; TL.Enabled = true; TL.LogMessage("DeviceId", DeviceId); TL.LogMessage("DeviceName", DeviceName); TL.LogMessage("DeviceClass", DeviceClass); TL.LogMessage("DeviceInterface", DeviceInterface); TL.LogMessage("InterfaceVersion", InterfaceVersion.ToString()); TL.LogMessage("Namespace", Namespace); inputForm.Dispose(); inputForm = null; // Add custom parameters. replacementsDictionary.Add("$deviceid$", DeviceId); replacementsDictionary.Add("$deviceclass$", DeviceClass); replacementsDictionary.Add("$devicename$", DeviceName); replacementsDictionary.Add("$namespace$", Namespace); replacementsDictionary["$projectname$"] = DeviceId; replacementsDictionary["$safeprojectname$"] = DeviceId; replacementsDictionary.Add("TEMPLATEDEVICENAME", DeviceName); if (DeviceClass == "VideoUsingBaseClass") // Special handling for "VideoWithBaseClass" template because its file name is not the same as the device type "Video" { replacementsDictionary.Add("TEMPLATEDEVICECLASS", "Video"); // This ensures that the class is named Video and not VideoWithBaseClass } else // ALl other templates process normally because the selected device name exatly matches the device type e.g. Telescope, Rotator etc. { replacementsDictionary.Add("TEMPLATEDEVICECLASS", DeviceClass); } replacementsDictionary.Add("ITEMPLATEDEVICEINTERFACE", DeviceInterface); replacementsDictionary.Add("TEMPLATENAMESPACE", Namespace); replacementsDictionary.Add("TEMPLATEINTERFACEVERSION", InterfaceVersion.ToString()); // create and replace guids replacementsDictionary.Add(csTemplateAssemblyGuid, Guid.NewGuid().ToString()); replacementsDictionary.Add(csTemplateInterfaceGuid, Guid.NewGuid().ToString()); replacementsDictionary.Add(csTemplateRateGuid, Guid.NewGuid().ToString()); replacementsDictionary.Add(csTemplateAxisRatesGuid, Guid.NewGuid().ToString()); replacementsDictionary.Add(csTemplateTrackingRatesGuid, Guid.NewGuid().ToString()); } catch (Exception ex) { TL.LogMessageCrLf("RunStarted", "Result Exception: " + ex.ToString()); MessageBox.Show("Form result setup exception: " + ex.ToString()); } Diagnostics.Exit(); }
public BundleFilesMenu(DTE2 dte, OleMenuCommandService mcs) { _dte = dte; _mcs = mcs; }
public BundleFilesMenu() { // Used by the IWpfTextViewCreationListener _dte = EditorExtensionsPackage.DTE; }
public TransformMenu(DTE2 dte, OleMenuCommandService mcs) { _dte = dte; _mcs = mcs; }
public ExecutionContext(IOutputWindowPane pane, Dispatcher dispatcher, System.Diagnostics.Process process, bool debug, DTE2 dte, IIdeTracer tracer, Version specRunVersion) { this.pane = pane; this.dispatcher = dispatcher; this.process = process; this.debug = debug; this.dte = dte; this.tracer = tracer; this.specRunVersion = specRunVersion; if (specRunVersion >= SpecRun12) { shouldAttachToMain = null; } process.OutputDataReceived += OnMessageReceived; process.ErrorDataReceived += OnMessageReceived; }
public VisualStudioRunnerCallback(DTE2 dte, IVsStatusbar statusBar) { this.dte = dte; this.statusBar = statusBar; }
public SpecRunTestRunnerGateway(IOutputWindowService outputWindowService, IIdeTracer tracer, IProjectScopeFactory projectScopeFactory, DTE2 dte, InstallServices installServices) { this.outputWindowService = outputWindowService; this.dte = dte; this.installServices = installServices; this.projectScopeFactory = projectScopeFactory; this.tracer = tracer; }
private bool ProcessIncludeLinkNavigate(Match match) { string IncludeFileFolderName = ""; string IncludeRegion = ""; if (match.Groups["IncludeFileRegion"].Value.Contains("#")) { IncludeFileFolderName = match.Groups["IncludeFileRegion"].Value.Split('#')[0]; IncludeRegion = match.Groups["IncludeFileRegion"].Value.Split('#')[1]; } else { IncludeFileFolderName = match.Groups["IncludeFileRegion"].Value; } bool IsURLProblem = false; bool bChangedLanguage = false; string FileNameLocation = ""; if (String.IsNullOrWhiteSpace(IncludeFileFolderName)) { if (String.IsNullOrWhiteSpace(IncludeRegion)) { log.Error(MarkdownSharp.Language.Message("UnableToNavigateToPage") + MarkdownSharp.Language.Message("ExcerptRegionToIncludeWhenNoFileGiven")); IsURLProblem = true; } else { //Assume that this is a reference to a location in this file IncludeFileFolderName = CurrentFolderFromMarkdownAsTopLeaf; } } if (IncludeFileFolderName.ToUpper().Contains("%ROOT%")) { IncludeFileFolderName = "."; } if (!IsURLProblem) { //We know location of file we want but not the file name AbsoluteMarkdownPath\IncludeFileName\*.Language.udn if (!Directory.Exists(Path.Combine(AbsoluteMarkdownPath, IncludeFileFolderName))) { //unable to locate the path to the file raise error log.Error(MarkdownSharp.Language.Message("BadPathForIncludeFile", match.Groups[0].Value)); IsURLProblem = true; } else { FileInfo[] LanguageFileInfo = new DirectoryInfo(Path.Combine(AbsoluteMarkdownPath, IncludeFileFolderName)).GetFiles("*." + Language + ".udn"); if (LanguageFileInfo.Length > 0) { FileNameLocation = LanguageFileInfo[0].FullName; } else { // File not found // if this is not an INT file check for the INT version. if (!Language.Equals("INT")) { LanguageFileInfo = new DirectoryInfo(Path.Combine(AbsoluteMarkdownPath, IncludeFileFolderName)).GetFiles("*.INT.udn"); if (LanguageFileInfo.Length == 0) { //unable to locate an INT file to replace the language raise error log.Error(MarkdownSharp.Language.Message("UnableToNavigateToPage") + MarkdownSharp.Language.Message("BadIncludeOrMissingMarkdownFileAndNoINTFile", match.Groups[0].Value)); IsURLProblem = true; } else { FileNameLocation = (LanguageFileInfo[0].FullName); //Raise info so that know we are allowing missing linked files to still allow processing of the file if INT file is there log.Info(MarkdownSharp.Language.Message("NavigatingToINTPage") + MarkdownSharp.Language.Message("BadIncludeOrMissingMarkdownFileINTUsed", match.Groups[0].Value)); IsURLProblem = true; bChangedLanguage = true; } } else { log.Error(MarkdownSharp.Language.Message("UnableToNavigateToPage") + MarkdownSharp.Language.Message("BadIncludeOrMissingMarkdownFile", match.Groups[0].Value)); IsURLProblem = true; } } } } // If no problem detected if (!IsURLProblem || bChangedLanguage) { if (String.IsNullOrWhiteSpace(IncludeRegion)) { //No region to consider, navigate straight to the page. DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2; //File found open it, this also makes the editor switch tabs to this file, so the preview window updates. dte.ItemOperations.OpenFile(FileNameLocation); return(true); } else { //Are we able to navigate to a region in the file? string IncludeFile = File.ReadAllText(FileNameLocation); Match Excerpts = Regex.Match(IncludeFile, Markdown.GetSubRegionOfFileMatcher(IncludeRegion)); if (Excerpts.Success) { //Found excerpt section, get the line number int LineNumber = 0; for (int i = 0; i <= Excerpts.Groups[0].Index - 1; ++i) { if (IncludeFile[i] == '\n') { ++LineNumber; } } DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2; //File found open it, this also makes the editor switch tabs to this file, so the preview window updates. dte.ItemOperations.OpenFile(FileNameLocation); dte.ExecuteCommand("Edit.Goto", LineNumber.ToString()); } else { //Region not found log.Error(MarkdownSharp.Language.Message("UnableToNavigateToPage") + MarkdownSharp.Language.Message("NotAbleToFindRegionInFile", match.Groups[0].Value)); IsURLProblem = true; DTE2 dte = Package.GetGlobalService(typeof(DTE)) as DTE2; //File found open it, this also makes the editor switch tabs to this file, so the preview window updates. dte.ItemOperations.OpenFile(FileNameLocation); } return(true); } } return(false); }
public TsLintMenu(DTE2 dte, OleMenuCommandService mcs) { _dte = dte; _mcs = mcs; }
protected override void Initialize() { base.Initialize(); _dte2 = GetService(typeof(DTE)) as DTE2; if (_dte2 == null) { return; } var oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (oleMenuCommandService != null) { var menuCommandId3 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDgmlBuild); var menuItem3 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId3); oleMenuCommandService.AddCommand(menuItem3); var menuCommandId4 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidReverseEngineerDgml); var menuItem4 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId4); oleMenuCommandService.AddCommand(menuItem4); var menuCommandId5 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidReverseEngineerCodeFirst); var menuItem5 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId5); oleMenuCommandService.AddCommand(menuItem5); var menuCommandId7 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidAbout); var menuItem7 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId7); oleMenuCommandService.AddCommand(menuItem7); var menuCommandId8 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDgmlNuget); var menuItem8 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId8); oleMenuCommandService.AddCommand(menuItem8); var menuCommandId9 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidSqlBuild); var menuItem9 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId9); oleMenuCommandService.AddCommand(menuItem9); var menuCommandId10 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDebugViewBuild); var menuItem10 = new OleMenuCommand(OnProjectContextMenuInvokeHandler, null, OnProjectMenuBeforeQueryStatus, menuCommandId10); oleMenuCommandService.AddCommand(menuItem10); } AssemblyBindingRedirectHelper.ConfigureBindingRedirects(); //Boot Telemetry Telemetry.Enabled = false; if (Telemetry.Enabled) { Telemetry.Initialize(Dte2, Assembly.GetExecutingAssembly().GetName().Version.ToString(), VisualStudioVersion.ToString(), "d4881a82-2247-42c9-9272-f7bc8aa29315"); } Telemetry.TrackEvent("Platform: Visual Studio " + VisualStudioVersion.ToString(1)); }
public FindUsedBiz(DTE2 dte) { _dte = dte; _serviceFunc = new ServiceFunc(); }
public VisualStudio(DTE2 applicationObject) { this.applicationObject = applicationObject; }
private void InitTestprojectStructure() { //mock exist file *.cs with name equal to name method mainMethodFileProjectItem = Substitute.For <ProjectItem>(); mainMethodFileProjectItem.Name.Returns("TestMethodName.cs"); methodWrapperFileProjectItem = Substitute.For <ProjectItem>(); methodWrapperFileProjectItem.Name.Returns("TestMethodNameWrapper.cs"); methodTestsFileProjectItem = Substitute.For <ProjectItem>(); methodTestsFileProjectItem.Name.Returns("TestMethodNameTests.cs"); List <ProjectItem> methodFiles = new List <ProjectItem>() { mainMethodFileProjectItem, methodWrapperFileProjectItem, methodTestsFileProjectItem }; ProjectItems specialMethodFolderProjectItems = Substitute.For <ProjectItems>(); specialMethodFolderProjectItems.GetEnumerator().Returns(methodFiles.GetEnumerator()); specialMethodFolderProjectItems.Item("TestMethodName.cs").Returns(mainMethodFileProjectItem); specialMethodFolderProjectItems.Item("TestMethodNameWrapper.cs").Returns(methodWrapperFileProjectItem); specialMethodFolderProjectItems.Item("TestMethodNameTests.cs").Returns(methodTestsFileProjectItem); //mock folder with method specialMethodFolder = Substitute.For <ProjectItem>(); specialMethodFolder.Name.Returns("TestMethodName"); specialMethodFolder.ProjectItems.Returns(specialMethodFolderProjectItems); List <ProjectItem> methodFolders = new List <ProjectItem>() { specialMethodFolder }; ProjectItems serverMethodsFolderItems = Substitute.For <ProjectItems>(); serverMethodsFolderItems.GetEnumerator().Returns(methodFolders.GetEnumerator()); serverMethodsFolderItems.Item("TestMethodName").Returns(specialMethodFolder); //mock main methods folder "ServerMethods" ProjectItem serverMethodsFolderProjectItem = Substitute.For <ProjectItem>(); serverMethodsFolderProjectItem.Name.Returns("ServerMethods"); serverMethodsFolderProjectItem.ProjectItems.Returns(serverMethodsFolderItems); List <ProjectItem> projectFolders = new List <ProjectItem>() { serverMethodsFolderProjectItem }; ProjectItems projectItems = Substitute.For <ProjectItems>(); projectItems.Item("ServerMethods").Returns(serverMethodsFolderProjectItem); projectItems.GetEnumerator().Returns(projectFolders.GetEnumerator()); Project project = Substitute.For <Project>(); project.UniqueName.Returns("ProjectName"); project.ProjectItems.Returns(projectItems); DTE2 dte2 = Substitute.For <DTE2>(); dte2.ActiveSolutionProjects.Returns(new Project[] { project }); this.serviceProvider.GetService(Arg.Any <Type>()).Returns(dte2); }
public SettingsStoreService(DTE2 dte2) { _dte2 = dte2; }
public void SetDTE(DTE2 app) { m_app = app; }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); // Every plugin needs a command bar. DTE2 application = await base.GetServiceAsync(typeof(DTE)).ConfigureAwait(false) as DTE2; IVsProfferCommands3 profferCommands3 = await base.GetServiceAsync(typeof(SVsProfferCommands)) as IVsProfferCommands3; OleMenuCommandService oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Load up the options from file. string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftyPerforce.xml"); Config options = Config.Load(optionsFileName); ImageList icons = new ImageList(); icons.Images.AddStrip(Properties.Resources.Icons); m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftyPerforce", "Aurora.NiftyPerforce.Connect", options); // Cleanup(); // TODO: remove this line CommandBar commandBar = m_plugin.AddCommandBar("NiftyPerforce", MsoBarPosition.msoBarTop); m_commandRegistry = new CommandRegistry(m_plugin, commandBar, new Guid(PackageGuidString), new Guid(PackageGuidGroup)); // Initialize the logging system. if (Log.HandlerCount == 0) { #if DEBUG Log.AddHandler(new DebugLogHandler()); #endif Log.AddHandler(new VisualStudioLogHandler(m_plugin)); Log.Prefix = "NiftyPerforce"; } // Now we can take care of registering ourselves and all our commands and hooks. Log.Debug("Booting up..."); Log.IncIndent(); bool doContextCommands = true; bool doBindings = options.EnableBindings; m_commandRegistry.RegisterCommand(doBindings, new NiftyConfigure(m_plugin, "NiftyConfig"), true); m_commandRegistry.RegisterCommand(doBindings, new P4EditModified(m_plugin, "NiftyEditModified"), true); m_commandRegistry.RegisterCommand(doBindings, new P4EditItem(m_plugin, "NiftyEdit"), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4EditItem(m_plugin, "NiftyEditItem"), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4EditSolution(m_plugin, "NiftyEditSolution"), false); } m_commandRegistry.RegisterCommand(doBindings, new P4DiffItem(m_plugin, "NiftyDiff")); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4DiffItem(m_plugin, "NiftyDiffItem"), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4DiffSolution(m_plugin, "NiftyDiffSolution"), false); } m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistory", false), true); m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryMain", true), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryItem", false), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistoryItem(m_plugin, "NiftyHistoryItemMain", true), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevisionHistorySolution(m_plugin, "NiftyHistorySolution"), false); } m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapse", false), true); m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseMain", true), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseItem", false), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4TimeLapseItem(m_plugin, "NiftyTimeLapseItemMain", true), false); } m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraph", false), true); m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphMain", true), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphItem", false), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevisionGraphItem(m_plugin, "NiftyRevisionGraphItemMain", true), false); } m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevert", false), true); m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertUnchanged", true), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertItem", false), false); } if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4RevertItem(m_plugin, "NiftyRevertUnchangedItem", true), false); } m_commandRegistry.RegisterCommand(doBindings, new P4ShowItem(m_plugin, "NiftyShow"), true); if (doContextCommands) { m_commandRegistry.RegisterCommand(doBindings, new P4ShowItem(m_plugin, "NiftyShowItem"), false); } m_plugin.AddFeature(new AutoAddDelete(m_plugin)); m_plugin.AddFeature(new AutoCheckoutProject(m_plugin)); m_plugin.AddFeature(new AutoCheckoutOnBuild(m_plugin)); m_plugin.AddFeature(new AutoCheckoutTextEdit(m_plugin)); m_plugin.AddFeature(new AutoCheckoutOnSave(m_plugin)); #if DEBUG // Use this to track down event GUIDs. //m_plugin.AddFeature(new FindEvents(m_plugin)); #endif P4Operations.CheckInstalledFiles(); AsyncProcess.Init(); Log.DecIndent(); Log.Debug("Initialized..."); #if DEBUG Log.Info("NiftyPerforce (Debug)"); #else //Log.Info("NiftyPerforce (Release)"); #endif // Show where we are and when we were compiled... Log.Info("I'm running {0} compiled on {1}", Assembly.GetExecutingAssembly().Location, System.IO.File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location)); }
void IDTWizard.Execute(object application, int hwndOwner, ref object[] contextParams, ref object[] customParams, ref wizardResult result) { // Initialisation des paramètres // DTE2 dte = (DTE2)application; string wizardType = (string)contextParams[0]; string projectFolder = (string)contextParams[2]; string localDirectory = (string)contextParams[3]; bool fExclusive = (bool)contextParams[4]; string solutionName = (string)contextParams[5]; // Fermeture de la solution si NewprojectType if (wizardType.Equals("{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}", StringComparison.InvariantCultureIgnoreCase) && fExclusive) { if (dte.Solution.IsOpen && (dte.ItemOperations.PromptToSave == vsPromptResult.vsPromptResultCancelled)) { result = wizardResult.wizardResultCancel; return; } } try { if (String.IsNullOrEmpty(solutionName)) { solutionName = (string)contextParams[1]; } // On descend d'un niveau car on travaille au niveau de la solution int pos = projectFolder.LastIndexOf(Path.DirectorySeparatorChar); projectFolder = projectFolder.Substring(0, pos); // Création de la solution Directory.CreateDirectory(projectFolder); dte.Solution.Create(projectFolder, solutionName); // Chargement du package IVsShell shell = (IVsShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShell)); Guid packageGuid = new Guid(Constants.CandlePackageId); IVsPackage package = null; shell.LoadPackage(ref packageGuid, out package); if (package == null) { throw new Exception("Unable to load package."); } // Recherche du template passé en paramètre sous la forme // modelTemplate = xxxxxxx // string template = ExtractParam(customParams, "modelTemplate", null); string strategyTemplate = ExtractParam(customParams, "strategy", "default"); string showDialog = ExtractParam(customParams, "showDialog", "true"); ServiceLocator.Instance.ShellHelper.AddDSLModelToSolution(template, strategyTemplate, solutionName, showDialog != null && showDialog.ToLower() == "true"); result = wizardResult.wizardResultSuccess; } catch (Exception ex) { if (!(ex is CanceledByUser)) { MessageBox.Show(ex.Message); } result = wizardResult.wizardResultCancel; } }
/// <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 = (EnvDTE.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("JsParser_AddIn.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: var comShow = commands.AddNamedCommand2(_addInInstance, "Show", "Javascript Parser", "Javascript Parser AddIn Show", true, 629, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton ); //Add a command to the Commands collection: var comFind = commands.AddNamedCommand2(_addInInstance, "Find", "Javascript Parser Find", "Javascript Parser AddIn 'Find' Feature", true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton ); //Add a control for the command to the tools menu: if (toolsPopup != null) { if (comShow != null) { comShow.AddControl(toolsPopup.CommandBar, 1); } if (comFind != null) { comFind.Bindings = "Text Editor::SHIFT+ALT+J"; comFind.AddControl(toolsPopup.CommandBar, 2); } } } 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. } } //Subscribe to IDE events Events events = _applicationObject.Events; _documentEvents = events.get_DocumentEvents(null); _windowEvents = events.get_WindowEvents(null); _documentEvents.DocumentSaved += documentEvents_DocumentSaved; _documentEvents.DocumentOpened += documentEvents_DocumentOpened; _windowEvents.WindowActivated += windowEvents_WindowActivated; _uiThemeProvider = new DefaultUIThemeProvider(); _jsParserService = new JsParserService(Settings.Default); _jsParserToolWindowManager = new JsParserToolWindowManager(_jsParserService, _uiThemeProvider, () => { return(EnsureWindowCreated()); }); }
public FindController(RadialControllerMenuItem menuItem, DTE2 dte) : base(menuItem) { _commands = dte.Commands; }
private static CommandTarget GetSelectedItemTarget(SelectedItem selectedItem, DTE2 application) { if (selectedItem.ProjectItem != null) { return(GetProjectItemTarget(selectedItem.ProjectItem)); } if (selectedItem.Project != null) { return(CommandTarget.Project); } if (application.Solution.IsOpen) { return(CommandTarget.Solution); } return(CommandTarget.Empty); }
public LessExtractMixinCommandTarget(IVsTextView adapter, IWpfTextView textView) : base(adapter, textView, GuidList.guidExtractCmdSet, PkgCmdIDList.ExtractMixin) { _dte = EditorExtensionsPackage.DTE; }
public ProjectItemManager(DTE2 dte, TemplateMap templateMap) { _templateMap = templateMap; _dte = dte; }
public static void Initialize(DTE2 dte, Options options) { Instance = new SolutionExplorerFocus(dte, options); }
/// <summary> /// Determines whether this instance can switch given the specified document. /// </summary> /// <param name="application">The application.</param> /// <param name="activeDocument">The active document.</param> /// <returns> /// <c>true</c> if this instance can switch the specified application; otherwise, <c>false</c>. /// </returns> public bool CanSwitch(DTE2 application, Document activeDocument) { // For now we always enable the command. return(true); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { CurrnetDte = (DTE2)automationObject; ReplacementsDictionary = replacementsDictionary; CurrentSolutionPath = replacementsDictionary["$destinationdirectory$"]; }
public DebugHandler(DTE2 application) { _application = application; }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(Package package) { serviceProvider = package; dte = ((IServiceProvider)serviceProvider).GetService(typeof(SDTE)) as DTE2; Instance = new FolderCommand(package); }