コード例 #1
0
        private void ShowManageLibraryPackageDialog(object sender, EventArgs e)
        {
            string parameterString   = null;
            OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;

            if (null != args)
            {
                parameterString = args.InValue as string;
            }

            if (VsMonitorSelection.GetIsSolutionNodeSelected())
            {
                ShowManageLibraryPackageDialog(null, parameterString);
            }
            else
            {
                Project project = VsMonitorSelection.GetActiveProject();
                if (project != null && !project.IsUnloaded() && project.IsSupported())
                {
                    ShowManageLibraryPackageDialog(project, parameterString);
                }
                else
                {
                    // show error message when no supported project is selected.
                    string projectName = project != null ? project.Name : String.Empty;

                    string errorMessage = String.IsNullOrEmpty(projectName)
                        ? Resources.NoProjectSelected
                        : String.Format(CultureInfo.CurrentCulture, VsResources.DTE_ProjectUnsupported, projectName);

                    MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle);
                }
            }
        }
コード例 #2
0
        private void ShowManageLibraryPackageDialog(object sender, EventArgs e)
        {
            if (VsMonitorSelection.GetIsSolutionNodeSelected())
            {
                ShowManageLibraryPackageDialog(null);
            }
            else
            {
                Project project = VsMonitorSelection.GetActiveProject();
                if (project != null && !project.IsUnloaded() && project.IsSupported())
                {
                    ShowManageLibraryPackageDialog(project);
                }
                else
                {
                    // show error message when no supported project is selected.
                    string projectName = project != null ? project.Name : String.Empty;

                    string errorMessage;
                    if (String.IsNullOrEmpty(projectName))
                    {
                        errorMessage = Resources.NoProjectSelected;
                    }
                    else
                    {
                        errorMessage = String.Format(CultureInfo.CurrentCulture, VsResources.DTE_ProjectUnsupported, projectName);
                    }

                    MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle);
                }
            }
        }
コード例 #3
0
ファイル: NuGetPackage.cs プロジェクト: hu19891110/NuGet
        private void BeforeQueryStatusForAddPackageDialog(object sender, EventArgs args)
        {
            bool isSolutionSelected = VsMonitorSelection.GetIsSolutionNodeSelected();

            OleMenuCommand command = (OleMenuCommand)sender;

            command.Visible = SolutionManager.IsSolutionOpen && !IsIDEInDebuggingOrBuildingContext() && (isSolutionSelected || HasActiveLoadedSupportedProject);
            // disable the dialog menu if the console is busy executing a command;
            command.Enabled = !ConsoleStatus.IsBusy;
            if (command.Visible)
            {
                command.Text = isSolutionSelected ? Resources.ManagePackageForSolutionLabel : Resources.ManagePackageLabel;
            }
        }