protected override void OnBeforeQueryStatus()

in src/Microsoft.VisualStudio.SlowCheetah.VS/Package/PreviewTransformCommand.cs [85:115]


        protected override void OnBeforeQueryStatus(object sender, EventArgs e)
        {
            // Get the menu that fired the event
            if (sender is OleMenuCommand menuCommand)
            {
                // Start by assuming that the menu will not be shown
                menuCommand.Visible = false;
                menuCommand.Enabled = false;
                uint itemid = VSConstants.VSITEMID_NIL;

                if (!ProjectUtilities.IsSingleProjectItemSelection(out IVsHierarchy hierarchy, out itemid))
                {
                    return;
                }

                IVsProject vsProject = (IVsProject)hierarchy;
                if (!this.ScPackage.ProjectSupportsTransforms(vsProject))
                {
                    return;
                }

                // The file need to be a transform item to preview
                if (!this.ScPackage.IsItemTransformItem(vsProject, itemid))
                {
                    return;
                }

                menuCommand.Visible = true;
                menuCommand.Enabled = true;
            }
        }