Ejemplo n.º 1
0
        /// <summary>
        /// Befores the query status.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void BeforeQueryStatus(object sender, EventArgs e)
        {
            // get the menu that fired the event
            var menuCommand = sender as OleMenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            // start by assuming that the menu will not be shown
            menuCommand.Visible = false;
            menuCommand.Enabled = false;

            // ReSharper disable once RedundantAssignment
            IVsHierarchy hierarchy = null;
            // ReSharper disable once RedundantAssignment
            var itemID = VSConstants.VSITEMID_NIL;

            if (!SolutionHelper.IsSingleProjectItemSelection(out hierarchy, out itemID))
            {
                return;
            }


            var vsProject = (IVsProject)hierarchy;

            if (!SolutionHelper.ProjectSupportsTransforms(vsProject))
            {
                return;
            }

            var fileName = SolutionHelper.GetFileNameFromItem(vsProject, itemID);

            if (fileName == null || !IsTransformationFile(fileName))
            {
                return;
            }

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