public static void Initialize(AsyncPackage aPackage)
 {
     GeneralSettings      = (ClangGeneralOptionsView)aPackage.GetDialogPage(typeof(ClangGeneralOptionsView));
     TidySettings         = (ClangTidyOptionsView)aPackage.GetDialogPage(typeof(ClangTidyOptionsView));
     TidyCustomCheckes    = (ClangTidyCustomChecksOptionsView)aPackage.GetDialogPage(typeof(ClangTidyCustomChecksOptionsView));
     TidyPredefinedChecks = (ClangTidyPredefinedChecksOptionsView)aPackage.GetDialogPage(typeof(ClangTidyPredefinedChecksOptionsView));
     ClangFormatSettings  = (ClangFormatOptionsView)aPackage.GetDialogPage(typeof(ClangFormatOptionsView));
 }
Beispiel #2
0
        public void SubscribeForReadOnlyObjectArgumentsPageProviderEvents(EventHandler <bool> action, EventHandler <bool> onReadOnlyObjectArgumentsOptionsSave)
        {
            var pageProvider = package.GetDialogPage(typeof(DialogPageProvider.ReadOnlyObjectArgumentsPageProvider)) as ReadOnlyObjectArgumentsPageProvider;

            pageProvider.OnSettingsPageActivate += action;
            pageProvider.SubstribeForModelSave(onReadOnlyObjectArgumentsOptionsSave);
        }
        /// <summary>
        ///     Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="dte"></param>
        /// <param name="options">options object</param>
        public static async Task InitializeAsync(AsyncPackage package)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await package.GetServiceAsync <DTE, DTE2>();

            var options = (Options)package.GetDialogPage(typeof(Options));

            Instance = new CleanBinAndObjCommand(package, dte, options);
        }
Beispiel #4
0
        public ClangCommand(CommandsController aCommandsController, IVsSolution aSolution,
                            DTE2 aDte, AsyncPackage aPackage, Guid aGuid, int aId)
            : base(aDte, aPackage, aGuid, aId)
        {
            if (null == mCommandsController)
            {
                mCommandsController = aCommandsController;
            }

            mGeneralOptions = (ClangGeneralOptionsView)aPackage.GetDialogPage(typeof(ClangGeneralOptionsView));

            mSolution = aSolution;
            mCommand  = DTEObj.Commands as Commands2;
            VsEdition = DTEObj.Edition;
            mVsVersions.TryGetValue(DTEObj.Version, out string version);
            VsVersion = version;
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpeninHidemaruEditorCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private OpeninHidemaruEditorCommand(AsyncPackage package, OleMenuCommandService commandService)
        {
            this._package  = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
            {
                var menuCommandID = new CommandID(PackageGuids.guidCommandAPackageCmdSet, PackageIds.CommandAId);
                var menuItem      = new MenuCommand(this.ExcuteActiveDocument, menuCommandID);
                commandService.AddCommand(menuItem);
            }
            {
                var menuCommandID = new CommandID(PackageGuids.guidCommandPackageCmdSet, PackageIds.CommandId);
                var menuItem      = new MenuCommand(this.ExecuteExplorer, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            this._settings = (Settings)package.GetDialogPage(typeof(Settings));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TidyCommand"/> 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 TidyCommand(OleMenuCommandService aCommandService, CommandsController aCommandsController,
                            ErrorWindowController aErrorWindow, OutputWindowController aOutputWindow, AsyncPackage aPackage, Guid aGuid, int aId)
            : base(aCommandsController, aErrorWindow, aOutputWindow, aPackage, aGuid, aId)
        {
            mTidyOptions      = (ClangTidyOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyOptionsView));
            mTidyChecks       = (ClangTidyPredefinedChecksOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyPredefinedChecksOptionsView));
            mTidyCustomChecks = (ClangTidyCustomChecksOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyCustomChecksOptionsView));
            mClangFormatView  = (ClangFormatOptionsView)AsyncPackage.GetDialogPage(typeof(ClangFormatOptionsView));

            if (null != aCommandService)
            {
                var menuCommandID = new CommandID(CommandSet, Id);
                var menuCommand   = new OleMenuCommand(RunClangTidy, menuCommandID);
                menuCommand.BeforeQueryStatus += mCommandsController.OnBeforeClangCommand;
                menuCommand.Enabled            = true;
                aCommandService.AddCommand(menuCommand);
            }
        }
Beispiel #7
0
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var dte2 = ((IServiceProvider)_vsPkg).GetService(typeof(SDTE)) as EnvDTE80.DTE2;
            var doc  = dte2.ActiveDocument;

            if (doc == null)
            {
                Alert("No active document");
                return;
            }

            var win = doc.ActiveWindow;

            if (win == null)
            {
                Alert("No active window");
                return;
            }

            var opts = _vsPkg.GetDialogPage(typeof(DisplayPropertiesOptionPage)) as DisplayPropertiesOptionPage;
            //opts.di

            bool ok = false;

            try
            {
                ok = win.SnapToPosition(_posKey, _screenIdx, opts);
            }
            catch (Exception ex)
            {
                Alert(ex.Info(true, true));
            }

            if (!ok)
            {
                Alert($"Invalid parameters."
                      + $"{L.F}Position key: [{_posKey}]"
                      + $"{L.f}Display index: [{_screenIdx}]");
            }
        }
        public ClangCommand(CommandsController aCommandsController, ErrorWindowController aErrorWindow,
                            OutputWindowController aOutputWindow, AsyncPackage aPackage, Guid aGuid, int aId)
            : base(aPackage, aGuid, aId)
        {
            if (null == mCommandsController)
            {
                mCommandsController = aCommandsController;
            }

            mErrorWindow    = aErrorWindow;
            mOutputWindow   = aOutputWindow;
            mGeneralOptions = (ClangGeneralOptionsView)aPackage.GetDialogPage(typeof(ClangGeneralOptionsView));

            if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
            {
                var dte2 = dte as DTE2;
                mCommand  = dte2.Commands as Commands2;
                VsEdition = dte2.Edition;
                mVsVersions.TryGetValue(dte2.Version, out string version);
                VsVersion = version;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TidyCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>

        public TidyCommand(CommandsController aCommandsController, IVsSolution aSolution,
                           DTE2 aDte, AsyncPackage aPackage, Guid aGuid, int aId)
            : base(aCommandsController, aSolution, aDte, aPackage, aGuid, aId)
        {
            mTidyOptions      = (ClangTidyOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyOptionsView));
            mTidyChecks       = (ClangTidyPredefinedChecksOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyPredefinedChecksOptionsView));
            mTidyCustomChecks = (ClangTidyCustomChecksOptionsView)AsyncPackage.GetDialogPage(typeof(ClangTidyCustomChecksOptionsView));
            mClangFormatView  = (ClangFormatOptionsView)AsyncPackage.GetDialogPage(typeof(ClangFormatOptionsView));

            mFileOpener = new FileOpener(DTEObj);

            var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != commandService)
            {
                var menuCommandID = new CommandID(CommandSet, Id);
                var menuCommand   = new OleMenuCommand(this.RunClangTidy, menuCommandID);
                menuCommand.BeforeQueryStatus += mCommandsController.QueryCommandHandler;
                menuCommand.Enabled            = true;
                commandService.AddCommand(menuCommand);
            }
        }
Beispiel #10
0
 private ClangFormatOptionsView GetUserOptions() => (ClangFormatOptionsView)AsyncPackage.GetDialogPage(typeof(ClangFormatOptionsView));
Beispiel #11
0
 public T GetPage()
 {
     return(m_package.GetDialogPage(typeof(T)) as T);
 }
        /// <summary>
        /// Start projects building
        /// </summary>
        /// <param name="projects"></param>
        private void RequestBuildProjects(EnvDTE80.SolutionConfiguration2 config, List <VCProject> projects)
        {
            OptionPageGrid page = (OptionPageGrid)package.GetDialogPage(typeof(OptionPageGrid));

            GolemBuildService.Configuration options = new GolemBuildService.Configuration()
            {
                GolemHubUrl = page.OptionGolemHubUrl, GolemServerPort = page.OptionGolemServerPort
            };

            var task = System.Threading.Tasks.Task.Run(async() =>
            {
                Stopwatch sw = Stopwatch.StartNew();
                if (!GolemBuildService.Instance.Options.Equals(options) || !GolemBuildService.Instance.IsRunning)
                {
                    GolemBuildService.Instance.Stop();
                    GolemBuildService.Instance.Options = options;
                    GolemBuildService.Instance.Start();
                }

                GolemBuild.GolemBuild builder = new GolemBuild.GolemBuild();

                int projectsSucceeded = 0;
                int projectsFailed    = 0;

                bool first = true;
                foreach (VCProject p in projects)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        builder.ClearTasks();
                    }

                    bool succeeded = builder.BuildProject(p.ProjectFile, config.Name, config.PlatformName);
                    if (succeeded)
                    {
                        projectsSucceeded++;
                    }
                    else
                    {
                        projectsFailed++;
                    }
                }
                sw.Stop();

                Logger.Log("Succeeded: " + projectsSucceeded.ToString() + " Failed: " + projectsFailed.ToString());
                Logger.Log("Build took: " + sw.Elapsed.ToString());

                string message = string.Format(CultureInfo.CurrentCulture, "Found {0} projects to build", projects.Count);
                foreach (VCProject p in projects)
                {
                    message += "\nPROJECT:" + p.ProjectFile;
                    message += builder.GetProjectInformation(p.ProjectFile);
                }
                string title = "BuildCommand";

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

                VsShellUtilities.ShowMessageBox(
                    ServiceProvider,
                    message,
                    title,
                    OLEMSGICON.OLEMSGICON_INFO,
                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            });
        }
Beispiel #13
0
 public SaveCMakeListsEventHandler(AsyncPackage package, IVsRunningDocumentTable rdt)
 {
     runningDocumentTable = rdt;
     optionPage           = package.GetDialogPage(typeof(PlcncliOptionPage)) as PlcncliOptionPage;
     cliCommunication     = Package.GetGlobalService(typeof(SPlcncliCommunication)) as IPlcncliCommunication;
 }
Beispiel #14
0
    public static async Task <T> GetDialogPageAsync <T>(this AsyncPackage package, Type dialogPageType) where T : DialogPage
    {
        await package.JoinableTaskFactory.SwitchToMainThreadAsync();

        return((T)package.GetDialogPage(dialogPageType));
    }
Beispiel #15
0
        private void AddAttachToCommand(OleMenuCommandService commandService, uint commandId, Func <GeneralOptionsPage, bool> isVisible, params string[] programsToAttach)
        {
            OleMenuCommand menuItemCommand = new OleMenuCommand(
                delegate(object sender, EventArgs e)
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                DTE dte = (DTE)ServiceProvider.GetService(typeof(DTE));
                Assumes.Present(dte);
                foreach (Process process in dte.Debugger.LocalProcesses)
                {
                    if (programsToAttach.Any(p => { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); return(process.Name.EndsWith(p)); }))
                    {
                        process.Attach();
                    }
                }
            },
                new CommandID(AttachToPackageCmdSet, (int)commandId));

            menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)package.GetDialogPage(typeof(GeneralOptionsPage)));
            commandService.AddCommand(menuItemCommand);
        }
 private IOptionsProvider GetOptions()
 {
     return((OptionsPage)_package.GetDialogPage(typeof(OptionsPage)));
 }