Ejemplo n.º 1
0
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var cmdId = prgCmds[0].cmdID;

            if (pguidCmdGroup.Equals(CommandSetGuids.ReferencesContextCmdSet))
            {
                if (cmdId == AddProjectReference.CommandId)
                {
                    bool          visible = false;
                    CommandStatus status  = 0;
                    if (TryGetSelectedProject(package, out ProjectModel proj) && proj.IsBSIPAProject)
                    {
                        status |= CommandStatus.Supported;
                        status |= CommandStatus.Enabled;
                        visible = true;
                    }
                    if (visible)
                    {
                        status &= ~CommandStatus.Invisible;
                    }
                    else
                    {
                        status |= CommandStatus.Invisible;
                    }
                    prgCmds[0].cmdf = (uint)GetVsStatus(status);
                }
            }
            else if (pguidCmdGroup.Equals(CommandSetGuids.ProjectContextCmdSet))
            {
                if (cmdId == ProjectContextSubmenu.CommandId)
                {
                    bool          visible = false;
                    CommandStatus status  = 0;
                    if (TryGetSelectedProject(package, out ProjectModel proj) && proj.IsBSIPAProject)
                    {
                        status |= CommandStatus.Supported;
                        status |= CommandStatus.Enabled;
                        visible = true;
                    }
                    if (visible)
                    {
                        status &= ~CommandStatus.Invisible;
                    }
                    else
                    {
                        status |= CommandStatus.Invisible;
                    }
                    prgCmds[0].cmdf = (uint)GetVsStatus(status);
                }
                else if (cmdId == SetBeatSaberDirCommand.CommandId)
                {
                    bool          visible = false;
                    CommandStatus status  = 0;
                    if (TryGetSelectedProject(package, out ProjectModel projectModel, out var project, out _) && projectModel.IsBSIPAProject)
                    {
                        status |= CommandStatus.Supported;
                        string prop = project.GetProperty("BeatSaberDir")?.UnevaluatedValue;
                        if (prop != BSMTSettingsManager.Instance.CurrentSettings.ChosenInstallPath)
                        {
                            status |= CommandStatus.Enabled;
                        }
                        visible = true;
                    }
                    if (visible)
                    {
                        status &= ~CommandStatus.Invisible;
                    }
                    else
                    {
                        status |= CommandStatus.Invisible;
                    }
                    prgCmds[0].cmdf = (uint)GetVsStatus(status);
                }
                else if (cmdId == AddProjectReferencePaths.CommandId)
                {
                    bool          visible = false;
                    CommandStatus status  = 0;
                    if (TryGetSelectedProject(package, out ProjectModel projectModel, out var project, out _) &&
                        projectModel.IsBSIPAProject)
                    {
                        status |= CommandStatus.Supported;
                        string prop = project.GetProperty("ReferencePath")?.UnevaluatedValue;
                        if (prop != EnvUtils.GetReferencePathString(BSMTSettingsManager.Instance.CurrentSettings.ChosenInstallPath))
                        {
                            status |= CommandStatus.Enabled;
                        }
                        visible = true;
                    }
                    if (visible)
                    {
                        status &= ~CommandStatus.Invisible;
                    }
                    else
                    {
                        status |= CommandStatus.Invisible;
                    }
                    prgCmds[0].cmdf = (uint)GetVsStatus(status);
                }
            }


            return(VSConstants.S_OK);
        }