private static void ResetZoom(_DTE dte, IWpfTextView view) { ThreadHelper.ThrowIfNotOnUIThread(); view.ZoomLevel = Options.Instance.DefaultZoomLevel; dte.ExecuteCommand("View.ZoomOut"); dte.ExecuteCommand("View.ZoomIn"); }
private bool SafeExecuteCommand(string command, string args = "") { try { _dte.ExecuteCommand(command, args); return(true); } catch { return(false); } }
/// <summary> /// Perform a vertical buffer split, which is essentially just another window in a different tab group. /// </summary> public override void SplitViewVertically(ITextView value) { try { _dte.ExecuteCommand("Window.NewWindow"); _dte.ExecuteCommand("Window.NewVerticalTabGroup"); } catch (Exception e) { _vim.ActiveStatusUtil.OnError(e.Message); } }
private static void ResetZoom(_DTE dte, IWpfTextView view) { int defaultZoom = ResetZoomPackage.Options.DefaultZoomLevel; if (Math.Round(view.ZoomLevel) == defaultZoom) { return; } view.ZoomLevel = defaultZoom; dte.ExecuteCommand("View.ZoomOut"); dte.ExecuteCommand("View.ZoomIn"); }
private void OnEventReady(object sender, EventArrivedEventArgs args) { //output to OutputWindow _DTE dteObj = (_DTE)GetNodeSite().GetService(typeof(_DTE)); if (outputPane == null) { OutputWindow ouputWindow = (OutputWindow)dteObj.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object; outputPane = ouputWindow.OutputWindowPanes.Item("{1BD8A850-02D1-11d1-bee7-00a0c913d1f8}"); } dteObj.ExecuteCommand("View.Output", ""); outputPane.Activate(); outputPane.OutputString(FormEventString(args.NewEvent) + "\n"); //also, add a child node WMIInstanceNode eventNode = new WMIInstanceNode((ManagementObject)args.NewEvent, new ManagementClass(args.NewEvent.ClassPath.Path, null), this.connectAs, this.password); eventNodes.Add(eventNode); GetNodeSite().AddChild(eventNode); }
public bool ExecuteCommand(ITextView textView, string command, string args, bool postCommand) { // Many Visual Studio commands expect the focus to be in the editor // when running. Switch focus there if an appropriate ITextView // is available. if (textView is IWpfTextView wpfTextView) { wpfTextView.VisualElement.Focus(); } // Some commands like 'Edit.GoToDefinition' only work like they do // when they are bound a key in Visual Studio like 'F12' when they // are posted instead of executed synchronously. See issue #2535. if (postCommand) { var dteCommand = _dte.Commands.Item(command, 0); var guid = new Guid(dteCommand.Guid); return(_uiShell.PostExecCommand(ref guid, (uint)dteCommand.ID, 0, args) == VSConstants.S_OK); } else { _dte.ExecuteCommand(command, args); return(true); } }
/// <summary> /// Runs commands or macros listed in the Keyboard section of the Environment panel of Options dialog box on /// the Tools menu. This wrapper method first checks that the command is available and, if so, runs it. /// </summary> /// <param name="commandName">The name of the command to invoke.</param> /// <param name="commandArgs">A string containing the same arguments you would supply if you were invoking /// the command from the Command window. If a string is supplied, it is passed to the command line as the /// command's first argument and is parsed to form the various arguments for the command. This is similar /// to how commands are invoked in the Command window.</param> private void ExecuteCommand(string commandName, string commandArgs = "") { var commands = _ide.Commands; if (commands.Item(commandName).IsAvailable) { _ide.ExecuteCommand(commandName, commandArgs); } }
private void buttonReloadProject_Click(object sender, EventArgs e) { // reload project string solutionPath = dte.Solution.FullName; dte.ExecuteCommand("File.CloseSolution"); dte.Solution.Open(solutionPath); }
private bool SafeExecuteCommand(ITextView contextTextView, string command, string args = "") { try { // Many Visual Studio commands expect focus to be in the editor when // running. Switch focus there if an appropriate ITextView is available if (contextTextView is IWpfTextView wpfTextView) { wpfTextView.VisualElement.Focus(); } _dte.ExecuteCommand(command, args); return(true); } catch { return(false); } }
public override void OnCommand(_DTE application, OutputWindowPane pane) { ThreadPool.QueueUserWorkItem( o => { string file = GitCommands.RunGitExWait("searchfile", application.Solution.FullName); if (string.IsNullOrEmpty(file?.Trim())) { return; } application.ExecuteCommand("File.OpenFile", file); }); }