Exemplo n.º 1
0
        /// <summary>
        /// Determines whether this command is visible
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = false;
            button.Visible = false;

            var selProjs = VsHelper.GetSelectedCsharpProjects();

            if (!selProjs.Any())
            {
                return;
            }

            button.Visible = true;

            foreach (Project proj in selProjs)
            {
                if (!VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Exemplo n.º 2
0
        /// <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 void MenuItemCallback(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var question = MessageBox.Show("Selecting this command will install a NuGet package that will enable this project for script generation. " +
                                           "\r\rDo you want to continue?", "Install NuGet Package?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (question == DialogResult.No)
            {
                return;
            }

            foreach (Project proj in VsHelper.GetSelectedCsharpProjects())
            {
                if (!VsHelper.IsPackageInstalled(proj))
                {
                    try
                    {
                        IComponentModel     componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
                        IVsPackageInstaller installer      = componentModel.GetService <IVsPackageInstaller>();
                        installer.InstallPackage(null, proj, TypeRightPackage.NugetID, (string)null, false);
                    }
                    catch (Exception exception)
                    {
                        // Show a message box to prove we were here
                        VsShellUtilities.ShowMessageBox(
                            this.ServiceProvider,
                            "There was an error installing the package: \n\n" + exception.Message,
                            "Could not install package",
                            OLEMSGICON.OLEMSGICON_CRITICAL,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determines whether this command is visible
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = false;

            foreach (EnvDTE.Project proj in VsHelper.GetSelectedItemsOfType <EnvDTE.Project>())
            {
                if (!VsHelper.IsSolutionItemsFolder(proj) &&
                    VsHelper.IsPackageInstalled(proj) &&
                    ConfigProcessing.IsGenEnabledForProject(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Before query for Adding a config file to the solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Visible = false;
            button.Enabled = false;

            foreach (Project proj in VsHelper.GetSelectedCsharpProjects())
            {
                button.Visible = true;                  // At least one project is selected...
                if (!ConfigProcessing.ConfigExistsForProject(proj) && VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Before query for Adding a config file to the solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button  = (OleMenuCommand)sender;
            bool           hasProj = VsHelper.GetSelectedItemsOfType <Project>().Any();   // Check if the solution is selectd

            button.Visible = false;
            button.Enabled = false;

            foreach (Project proj in VsHelper.GetSelectedItemsOfType <Project>())
            {
                button.Visible = true;                  // At least one project is selected...
                if (!ConfigProcessing.IsGenEnabledForProject(proj) && VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }
        /// <summary>
        /// Determines whether this command is visible
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = false;

            if (!VsHelper.GetSelectedItemsOfType <Project>().Any())
            {
                return;
            }

            foreach (Project proj in VsHelper.GetSelectedItemsOfType <Project>())
            {
                if (!VsHelper.IsSolutionItemsFolder(proj) && !VsHelper.IsPackageInstalled(proj))
                {
                    button.Enabled = true;
                }
            }
        }