Пример #1
0
        public static void Initialize()
        {
            Instance           = new Launcher();
            Instance.debugger  = VsServiceProvider.GetService <IVsDebugger>();
            Instance.debugger4 = VsServiceProvider.GetService <IVsDebugger, IVsDebugger4>();
            if (Instance.debugger != null && Instance.debugger4 != null)
            {
                Instance.debugger.AdviseDebugEventCallback(Instance);
            }

            var outputWindow = VsServiceProvider.GetService <SVsOutputWindow, IVsOutputWindow>();

            if (outputWindow != null)
            {
                var debugOutputGuid = VSConstants.OutputWindowPaneGuid.DebugPane_guid;
                var result          = outputWindow.GetPane(ref debugOutputGuid, out Instance.debugOutput);
                if (result != VSConstants.S_OK || Instance.debugOutput == null)
                {
                    Messages.PaneMessageSafe(Vsix.Instance.Dte,
                                             "Unable to get reference to output window debug pane.", 5000);
                }
            }
            else
            {
                Messages.PaneMessageSafe(Vsix.Instance.Dte,
                                         "Unable to get reference to output window.", 5000);
            }
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private async void RunClangCompile(object sender, EventArgs e)
        {
            if (mCommandsController.Running)
            {
                return;
            }

            mCommandsController.Running = true;

            await System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
                    {
                        DocumentsHandler.SaveActiveDocuments();
                        AutomationUtil.SaveDirtyProjects((dte as DTE2).Solution);
                    }

                    CollectSelectedItems(ScriptConstants.kAcceptedFileExtensions);
                    RunScript(OutputWindowConstants.kComplileCommand);
                }
                catch (Exception exception)
                {
                    VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error",
                                                    OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            });

            mCommandsController.OnAfterClangCommand();
        }
        /// <summary>
        /// It is called before every command. Update the running state.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnBeforeClangCommand(object sender, EventArgs e)
        {
            UIUpdater.Invoke(() =>
            {
                if (!(sender is OleMenuCommand command))
                {
                    return;
                }

                if (VsServiceProvider.TryGetService(typeof(DTE), out object dte) && !(dte as DTE2).Solution.IsOpen)
                {
                    command.Visible = command.Enabled = false;
                }

                else if (vsBuildRunning && command.CommandID.ID != CommandIds.kSettingsId)
                {
                    command.Visible = command.Enabled = false;
                }

                else
                {
                    command.Visible = command.Enabled = command.CommandID.ID != CommandIds.kStopClang ? !running : running;
                }
            });
        }
Пример #4
0
        private async System.Threading.Tasks.Task OnMSVCBuildSucceededAsync()
        {
            if (!CompileCommand.Instance.VsCompileFlag)
            {
                return;
            }

            var exitCode = int.MaxValue;

            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                exitCode = (dte as DTE2).Solution.SolutionBuild.LastBuildInfo;
            }

            // VS compile detected errors and there is not necessary to run clang compile
            if (0 != exitCode)
            {
                CompileCommand.Instance.VsCompileFlag = false;
                return;
            }

            // Run clang compile after the VS compile succeeded

            OnBeforeClangCommand(CommandIds.kCompileId);
            await CompileCommand.Instance.RunClangCompileAsync(CommandIds.kCompileId, CommandUILocation.ContextMenu);

            CompileCommand.Instance.VsCompileFlag = false;
            OnAfterClangCommand();
        }
Пример #5
0
        public static void WriteMessageWithLink(string path, int line, string format, params object[] args)
        {
            IVsOutputWindow outputWindow = VsServiceProvider.Get(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid guidGeneral = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;

            if (outputWindow == null)
            {
                return;
            }

            IVsOutputWindowPane pane;
            int hr = outputWindow.CreatePane(guidGeneral, "General", 1, 0);

            hr = outputWindow.GetPane(guidGeneral, out pane);

            if (pane == null)
            {
                return;
            }


            if (!format.EndsWith("\r\n"))
            {
                format = format + "\r\n";
            }

            pane.Activate();

            pane.OutputTaskItemString(string.Format(format, args) + "\r\n",
                                      VSTASKPRIORITY.TP_NORMAL, VSTASKCATEGORY.CAT_BUILDCOMPILE, "MergeUi", 0, path, (uint)line - 1, string.Format(format, args));
        }
Пример #6
0
        public static void Text(string aText, int aFreezeStatusBar)
        {
            UIUpdater.Invoke(() =>
            {
                if (!VsServiceProvider.TryGetService(typeof(SVsStatusbar), out object statusBarService) || null == statusBarService as IVsStatusbar)
                {
                    return;
                }

                var statusBar = statusBarService as IVsStatusbar;

                // Make sure the status bar is not frozen
                if (VSConstants.S_OK != statusBar.IsFrozen(out int frozen))
                {
                    return;
                }

                if (0 != frozen)
                {
                    statusBar.FreezeOutput(0);
                }

                // Set the status bar text
                statusBar.SetText(aText);

                // Freeze the status bar.
                statusBar.FreezeOutput(aFreezeStatusBar);

                // Clear the status bar text.
                if (0 == aFreezeStatusBar)
                {
                    statusBar.Clear();
                }
            });
        }
Пример #7
0
        /// <summary>
        /// Stop ignoring the file changes for a certain files
        /// </summary>
        public void Resume(SilentFileChangerModel aSilentFileChanger)
        {
            if (null == aSilentFileChanger)
            {
                return;
            }

            if (!aSilentFileChanger.IsSuspended || null == aSilentFileChanger.PersistDocData)
            {
                return;
            }

            if (null != aSilentFileChanger.PersistDocData && aSilentFileChanger.ReloadDocumentFlag)
            {
                aSilentFileChanger.PersistDocData.ReloadDocData(0);
            }

            if (!VsServiceProvider.TryGetService(typeof(SVsFileChangeEx), out object vsFileChangeService) || null == vsFileChangeService as IVsFileChangeEx)
            {
                return;
            }

            var vsFileChange = vsFileChangeService as IVsFileChangeEx;

            aSilentFileChanger.IsSuspended = false;
            ErrorHandler.ThrowOnFailure(vsFileChange.SyncFile(aSilentFileChanger.DocumentFileName));
            ErrorHandler.ThrowOnFailure(vsFileChange.IgnoreFile(0, aSilentFileChanger.DocumentFileName, 0));
            if (aSilentFileChanger.FileChangeControl != null)
            {
                ErrorHandler.ThrowOnFailure(aSilentFileChanger.FileChangeControl.IgnoreFileChanges(0));
            }
        }
Пример #8
0
        // TODO : Refactor this method. Generics can be a solution.
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      dte            = (DTE)VsServiceProvider.GetService(typeof(DTE));
                Document activeDocument = dte.ActiveDocument;

                if (activeDocument == null)
                {
                    return;
                }

                IItem item = null;
                if (SolutionInfo.IsOpenFolderModeActive())
                {
                    item = new CurrentDocument(activeDocument);
                }
                else
                {
                    item = new CurrentProjectItem(activeDocument.ProjectItem);
                }

                Items.Add(item);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Пример #9
0
        private void OnBrowseButtonClick(object sender, RoutedEventArgs e)
        {
            var block = System.IntPtr.Zero;

            try {
                var dte             = VsServiceProvider.GetService <DTE>();
                var serviceProvider = new ServiceProvider(dte as IServiceProvider);
                var iVsUIShell      = VsServiceProvider.GetService <SVsUIShell, IVsUIShell>();

                System.IntPtr owner;
                iVsUIShell.GetDialogOwnerHwnd(out owner);

                var browseInfo = new VSBROWSEINFOW[1];
                browseInfo[0].lStructSize   = (uint)Marshal.SizeOf(typeof(VSBROWSEINFOW));
                browseInfo[0].pwzInitialDir = Location;
                browseInfo[0].pwzDlgTitle   = @"Location";
                browseInfo[0].hwndOwner     = owner;
                browseInfo[0].nMaxDirName   = 260;
                block = Marshal.AllocCoTaskMem(520);
                browseInfo[0].pwzDirName = block;

                var result = iVsUIShell.GetDirectoryViaBrowseDlg(browseInfo);
                if (result == Microsoft.VisualStudio.VSConstants.S_OK)
                {
                    Location = Marshal.PtrToStringAuto(browseInfo[0].pwzDirName);
                    LocationComboBox.Text = Marshal.PtrToStringAuto(browseInfo[0].pwzDirName);
                }
            } finally {
                if (block != System.IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(block);
                }
            }
        }
Пример #10
0
        QtHelpMenu(Package pkg)
        {
            if (pkg == null)
            {
                throw new ArgumentNullException("package");
            }
            package = pkg;

            var commandService = VsServiceProvider
                                 .GetService <IMenuCommandService, OleMenuCommandService>();

            if (commandService == null)
            {
                return;
            }

            var menuCommandID = new CommandID(HelpMenuGroupGuid, F1QtHelpId);

            commandService.AddCommand(new MenuCommand(F1QtHelpCallback, menuCommandID));

            menuCommandID = new CommandID(HelpMenuGroupGuid, ViewQtHelpId);
            commandService.AddCommand(new MenuCommand(ViewQtHelpCallback, menuCommandID));

            var command = new OleMenuCommand(ExecHandler, new CommandID(HelpMenuGroupGuid,
                                                                        OfflineDocumentationId));

            command.BeforeQueryStatus += BeforeQueryStatus;
            commandService.AddCommand(command);

            command = new OleMenuCommand(ExecHandler, new CommandID(HelpMenuGroupGuid,
                                                                    OnlineDocumentationId));
            command.BeforeQueryStatus += BeforeQueryStatus;
            commandService.AddCommand(command);
        }
        public void Build()
        {
            // Get the VS Output Window
            if (null == mOutputWindowModel.VsOutputWindow)
            {
                if (VsServiceProvider.TryGetService(typeof(SVsOutputWindow), out object vsOutputWindow))
                {
                    mOutputWindowModel.VsOutputWindow = vsOutputWindow as IVsOutputWindow;
                }
            }

            if (null == mOutputWindowModel.Pane)
            {
                // Get the Pane object
                Guid generalPaneGuid = mOutputWindowModel.PaneGuid;
                mOutputWindowModel.VsOutputWindow.GetPane(ref generalPaneGuid, out IVsOutputWindowPane pane);

                // If pane does not exists, create it
                if (null == pane)
                {
                    mOutputWindowModel.VsOutputWindow.CreatePane(ref generalPaneGuid, OutputWindowConstants.paneName, 0, 1);
                    mOutputWindowModel.VsOutputWindow.GetPane(ref generalPaneGuid, out pane);
                }
                mOutputWindowModel.Pane = pane;
            }
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QtMainMenu"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private QtSolutionContextMenu(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            m_package = package;

            var commandService = VsServiceProvider
                                 .GetService <IMenuCommandService, OleMenuCommandService>();

            if (commandService == null)
            {
                return;
            }

            commandService.AddCommand(new OleMenuCommand(execHandler,
                                                         new CommandID(SolutionContextMenuGuid, lUpdateOnSolutionId)));

            commandService.AddCommand(new OleMenuCommand(execHandler,
                                                         new CommandID(SolutionContextMenuGuid, lReleaseOnSolutionId)));

            commandService.AddCommand(new OleMenuCommand(execHandler,
                                                         new CommandID(SolutionContextMenuGuid, ChangeSolutionQtVersionId)));

            commandService.AddCommand(new OleMenuCommand(execHandler,
                                                         new CommandID(SolutionContextMenuGuid, SolutionConvertToQtMsBuild)));
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QtMainMenu"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private QtProjectContextMenu(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            m_package = package;

            var commandService = VsServiceProvider
                                 .GetService <IMenuCommandService, OleMenuCommandService>();

            if (commandService == null)
            {
                return;
            }

            foreach (var id in Enum.GetValues(typeof(CommandId)))
            {
                var command = new OleMenuCommand(execHandler,
                                                 new CommandID(ProjectContextMenuGuid, (int)id));
                command.BeforeQueryStatus += beforeQueryStatus;
                commandService.AddCommand(command);
            }
        }
        /// <summary>
        /// It is called before every command. Update the running state.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnBeforeClangCommand(object sender, EventArgs e)
        {
            if (!(sender is OleMenuCommand command))
            {
                return;
            }

            if (IsAToolbarCommand(command))
            {
                if (SolutionInfo.AreToolbarCommandsEnabled() == false)
                {
                    command.Enabled = false;
                    return;
                }
            }
            else if (SolutionInfo.AreContextMenuCommandsEnabled() == false)
            {
                command.Enabled = false;
                return;
            }


            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte) && !(dte as DTE2).Solution.IsOpen)
            {
                command.Visible = command.Enabled = false;
            }
            else if (vsBuildRunning && command.CommandID.ID != CommandIds.kSettingsId)
            {
                command.Visible = command.Enabled = false;
            }
            else
            {
                command.Visible = command.Enabled = command.CommandID.ID != CommandIds.kStopClang ? !running : running;
            }
        }
Пример #15
0
 // Open the changed files in the editor
 public static void Open(object source, FileSystemEventArgs e)
 {
     if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
     {
         (dte as DTE2).ExecuteCommand(kOpenCommand, e.FullPath);
     }
 }
Пример #16
0
        public ItemsCollector(List <string> aExtensions = null)
        {
            mAcceptedFileExtensions = aExtensions;
            var dte2 = (DTE2)VsServiceProvider.GetService(typeof(DTE));

            selectedItems = dte2.ToolWindows.SolutionExplorer.SelectedItems as Array;
        }
Пример #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QtMainMenu"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private QtItemContextMenu(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            m_package = package;

            var commandService = VsServiceProvider
                                 .GetService <IMenuCommandService, OleMenuCommandService>();

            if (commandService == null)
            {
                return;
            }

            var command = new OleMenuCommand(execHandler,
                                             new CommandID(ItemContextMenuGuid, lUpdateOnItemId));

            command.BeforeQueryStatus += beforeQueryStatus;
            commandService.AddCommand(command);

            command = new OleMenuCommand(execHandler,
                                         new CommandID(ItemContextMenuGuid, lReleaseOnItemId));
            command.BeforeQueryStatus += beforeQueryStatus;
            commandService.AddCommand(command);
        }
Пример #18
0
        public static void WriteMessage(string format, params object[] args)
        {
            IVsOutputWindow outputWindow = VsServiceProvider.Get(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid guidGeneral = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;

            if (outputWindow == null)
            {
                return;
            }

            IVsOutputWindowPane pane;
            int hr = outputWindow.CreatePane(guidGeneral, "General", 1, 0);

            hr = outputWindow.GetPane(guidGeneral, out pane);

            if (pane == null)
            {
                return;
            }


            if (!format.EndsWith("\r\n"))
            {
                format = format + "\r\n";
            }

            pane.Activate();
            pane.OutputString(string.Format(format, args));
        }
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value is string)
            {
                var dte = VsServiceProvider.GetService <SDTE, DTE>();
                if (dte == null)
                {
                    return(ValidationResult.ValidResult);
                }

                var project = HelperFunctions.GetSelectedProject(dte);
                if (project == null)
                {
                    return(ValidationResult.ValidResult);
                }

                var files = HelperFunctions.GetProjectFiles(project, Filter);
                if (files.Count == 0)
                {
                    return(ValidationResult.ValidResult);
                }

                var fileName = (value as string).ToUpperInvariant();
                if (files.FirstOrDefault(x => x.ToUpperInvariant() == fileName) != null)
                {
                    return(new ValidationResult(false, @"File already exists."));
                }
                return(ValidationResult.ValidResult);
            }
            return(new ValidationResult(false, @"Invalid file name."));
        }
        private async Task RegisterVsServicesAsync()
        {
            // Get DTE service async
            var dte = await GetServiceAsync(typeof(DTE)) as DTE2;

            VsServiceProvider.Register(typeof(DTE), dte);

            // Get VS Output Window service async
            var vsOutputWindow = await GetServiceAsync(typeof(SVsOutputWindow));

            VsServiceProvider.Register(typeof(SVsOutputWindow), vsOutputWindow);

            // Get the status bar service async
            var vsStatusBar = await GetServiceAsync(typeof(SVsStatusbar));

            VsServiceProvider.Register(typeof(SVsStatusbar), vsStatusBar);

            // Get Vs Running Document Table service async
            var vsRunningDocumentTable = await GetServiceAsync(typeof(SVsRunningDocumentTable));

            VsServiceProvider.Register(typeof(SVsRunningDocumentTable), vsRunningDocumentTable);

            // Get Vs File Change service async
            var vsFileChange = await GetServiceAsync(typeof(SVsFileChangeEx));

            VsServiceProvider.Register(typeof(SVsFileChangeEx), vsFileChange);

            // Get VS Solution service async
            var vsSolution = await GetServiceAsync(typeof(SVsSolution));

            VsServiceProvider.Register(typeof(SVsSolution), vsSolution);
        }
Пример #21
0
        static WaitDialog Create()
        {
            if (factory == null)
            {
                factory = VsServiceProvider
                          .GetService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory>();
                if (factory == null)
                {
                    return(null);
                }
            }

            IVsThreadedWaitDialog2 vsWaitDialog = null;

            factory.CreateInstance(out vsWaitDialog);
            if (vsWaitDialog == null)
            {
                return(null);
            }

            return(new WaitDialog
            {
                VsWaitDialog = vsWaitDialog,
                Running = true,
            });
        }
Пример #22
0
        private async Task OnMSVCBuildSucceededAsync()
        {
            var runClang = SettingsProvider.CompilerSettingsModel.ClangAfterMSVC;

            if (runClang == false || SolutionInfo.ContainsCppProject() == false)
            {
                return;
            }

            var exitCode = int.MaxValue;

            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                exitCode = (dte as DTE2).Solution.SolutionBuild.LastBuildInfo;
            }

            // VS compile detected errors and there is not necessary to run clang compile
            if (exitCode != 0)
            {
                return;
            }

            // Run clang compile after the VS compile succeeded

            OnBeforeClangCommand(CommandIds.kCompileId);
            await CompileCommand.Instance.RunClangCompileAsync(CommandIds.kCompileId, CommandUILocation.ContextMenu);

            OnAfterClangCommand();
        }
        public override void OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            if (false == mExecuteCompile)
            {
                return;
            }

            var exitCode = int.MaxValue;

            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                exitCode = (dte as DTE2).Solution.SolutionBuild.LastBuildInfo;
            }

            // VS compile detected errors and there is not necessary to run clang compile
            if (0 != exitCode)
            {
                mExecuteCompile = false;
                return;
            }

            // Run clang compile after the VS compile succeeded
            RunClangCompile(new object(), new EventArgs());
            mExecuteCompile = false;
        }
Пример #24
0
        public void RunClangCompile(int aCommandId)
        {
            if (mCommandsController.Running)
            {
                return;
            }

            mCommandsController.Running = true;

            var task = System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
                    {
                        DocumentsHandler.SaveActiveDocuments();
                        AutomationUtil.SaveDirtyProjects((dte as DTE2).Solution);
                    }

                    CollectSelectedItems(false, ScriptConstants.kAcceptedFileExtensions);
                    RunScript(aCommandId);
                }
                catch (Exception exception)
                {
                    VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error",
                                                    OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            }).ContinueWith(tsk => mCommandsController.OnAfterClangCommand());
        }
Пример #25
0
        public async Task RunClangTidyAsync(int aCommandId, CommandUILocation commandUILocation, Document document = null)
        {
            await PrepareCommmandAsync(commandUILocation);

            await Task.Run(() =>
            {
                lock (mutex)
                {
                    try
                    {
                        using var silentFileController = new SilentFileChangerController();
                        using var fileChangerWatcher   = new FileChangerWatcher();

                        var tidySettings = SettingsProvider.TidySettingsModel;

                        if (CommandIds.kTidyFixId == aCommandId || tidySettings.TidyOnSave)
                        {
                            fileChangerWatcher.OnChanged += FileOpener.Open;

                            var dte2 = VsServiceProvider.GetService(typeof(DTE)) as DTE2;
                            string solutionFolderPath = SolutionInfo.IsOpenFolderModeActive() ?
                                                        dte2.Solution.FullName : dte2.Solution.FullName
                                                        .Substring(0, dte2.Solution.FullName.LastIndexOf('\\'));

                            fileChangerWatcher.Run(solutionFolderPath);

                            FilePathCollector fileCollector = new FilePathCollector();
                            var filesPath = fileCollector.Collect(mItemsCollector.Items).ToList();

                            silentFileController.SilentFiles(filesPath);
                            silentFileController.SilentFiles(dte2.Documents);
                        }

                        if (tidySettings.DetectClangTidyFile && !mItemsCollector.IsEmpty)
                        {
                            // Check for .clang-tidy congif file
                            if (FileSystem.SearchAllTopDirectories(mItemsCollector.Items[0].GetPath(), FileSystem.ConfigClangTidyFileName))
                            {
                                tidySettings.UseChecksFrom = ClangTidyUseChecksFrom.TidyFile;
                            }
                            else
                            {
                                tidySettings.UseChecksFrom = ClangTidyUseChecksFrom.PredefinedChecks;
                            }

                            var settingsHandlder = new SettingsHandler();
                            settingsHandlder.SaveSettings();
                        }

                        RunScript(aCommandId, false);
                    }
                    catch (Exception exception)
                    {
                        VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error",
                                                        OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                }
            });
        }
 public CommandController(AsyncPackage aAsyncPackage)
 {
     if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
     {
         var dte2 = dte as DTE2;
         mCommand = dte2.Commands as Commands2;
     }
 }
Пример #27
0
        /// <summary>
        /// Check if any VS Solution is open
        /// </summary>
        /// <returns>True if any VS Solution is open. False otherwise.</returns>
        public static bool IsSolutionOpen()
        {
            var solution = (IVsSolution)VsServiceProvider.GetService(typeof(SVsSolution));

            solution.GetProperty((int)__VSPROPID.VSPROPID_IsSolutionOpen, out object open);
            SolutionOpen = (bool)open;
            return(SolutionOpen);
        }
Пример #28
0
        /// <summary>
        /// Check if VS runs in Open Folder Mode
        /// </summary>
        /// <returns>True if VS runs in Open Folder Mode. False otherwise.</returns>
        public static bool IsOpenFolderModeActive()
        {
            var solution = (IVsSolution)VsServiceProvider.GetService(typeof(SVsSolution));

            solution.GetProperty((int)__VSPROPID7.VSPROPID_IsInOpenFolderMode, out object folderMode);
            OpenFolderModeActive = (bool)folderMode;
            return(OpenFolderModeActive);
        }
Пример #29
0
        protected VCLanguageManagerValidationRule()
        {
            ValidatesOnTargetUpdated = true;

            var dte = VsServiceProvider.GetService <DTE>();

            Vclm = dte.GetObject("VCLanguageManager") as VCLanguageManager;
        }
 private void ShowToolbare()
 {
     if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
     {
         var        cbs = ((CommandBars)(dte as DTE2).CommandBars);
         CommandBar cb  = cbs["Clang Power Tools"];
         cb.Visible = true;
     }
 }