void menuCommand_BeforeQueryStatus()

in SamplesV1/ADFSecurePublish/SecurePublishMenuCommand/SecurePublishCommand.cs [71:101]


        void menuCommand_BeforeQueryStatus(object sender, EventArgs e)
        {
            // get the menu that fired the event
            var menuCommand = sender as OleMenuCommand;
            if (menuCommand != null)
            {
                // start by assuming that the menu will not be shown
                menuCommand.Visible = false;
                menuCommand.Enabled = false;

                IVsHierarchy hierarchy = null;
                uint itemid = VSConstants.VSITEMID_NIL;

                if (!IsSingleProjectItemSelection(out hierarchy, out itemid)) return;

                // Get the file path
                string itemFullPath = null;
                ((IVsProject)hierarchy).GetMkDocument(itemid, out itemFullPath);
                var projectFileInfo = new FileInfo(itemFullPath);

                // then check if the project extension is dfproj i.e. a data factory project
                bool isDfProj = projectFileInfo.Extension.Equals(".dfproj", StringComparison.InvariantCultureIgnoreCase);

                // if not leave the menu hidden
                if (!isDfProj) return;

                projName = projectFileInfo.FullName;
                menuCommand.Visible = true;
                menuCommand.Enabled = true;
            }
        }