Exemplo n.º 1
0
        /// called when the context menu is opened
        ///
        /// makes entries only visible if the document is a supported language
        /// but enable it only if it's part of a project
        private void beforeQueryStatus(object sender, EventArgs e)
        {
            OleMenuCommand menuCommand = sender as OleMenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            // reset
            menuCommand.Enabled = true;
            menuCommand.Visible = true;

            // cases:
            // normal .cpp in project
            // external .cpp file => projectItem != null, projectItem.Object == null
            // stdlib header => projectItem == null
            // "Solution Files"   => projectItem.Object == null
            // other file types like .txt or .cs

            Document doc = dte.ActiveDocument;

            // first check if it's part of a project
            ProjectItem projectItem = doc.ProjectItem;

            if (projectItem?.Object == null || projectItem.ContainingProject?.Object == null)
            {
                menuCommand.Enabled = false;
                package.writeStatus("This file is not recognized as part of any project");
            }

            if (currentFileIsHeaderFile())
            {
                menuCommand.Enabled = true;
            }

            if (doc.Language != (string)menuCommand.Properties["lang"])
            {
                menuCommand.Visible = false;
            }
        }
Exemplo n.º 2
0
        private void buildDone(vsBuildScope scope, vsBuildAction action)
        {
            // fill it up
            taskbarItemInfo.ProgressValue = 1;

            // keep it red
            if (taskbarItemInfo.ProgressState != TaskbarItemProgressState.Error)
            {
                taskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
            }

            if (scope != vsBuildScope.vsBuildScopeSolution)
            {
                return;
            }

            string msg = String.Format("Total build time: {0}", DateTime.Now - _buildStartTime);

            _vspkg.writeToBuildWindow("\n" + msg);
            _vspkg.writeStatus(msg);
        }