Exemplo n.º 1
0
        void InitializePublishFlagButtons(IMenuCommandService mcs, UDNDocRunningTableMonitor rdtm)
        {
            //InitializePublishFlagButton(mcs, rdtm, GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPublishList, .Trim());

            var availabilityStrings = Settings.Default.SupportedAvailabilitiesString.Split(',').ToList();
            availabilityStrings.Insert(0, Settings.Default.PublicAvailabilitiesString);

            int i = 0;
            foreach (var availabilityString in availabilityStrings)
            {
                InitializePublishFlagButton(mcs, rdtm, GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPublishList + i + 1, availabilityStrings[i].Trim());
                ++i;
            }
        }
Exemplo n.º 2
0
        void InitializePublishFlagButton(IMenuCommandService mcs, UDNDocRunningTableMonitor rdtm, Guid pkgGuid, int cmdId, string PublishFlag)
        {
            CommandID PublishFlagCommandID = new CommandID(pkgGuid, cmdId);

            // public is necessary so we don't want to attach changing event
            OleMenuCommand PublishFlagCommand;

            if (PublishFlag == Settings.Default.PublicAvailabilitiesString.Trim())
            {
                PublishFlagCommand = new OleMenuCommand((sender, args) => { }, PublishFlagCommandID);
                PublishFlagCommand.BeforeQueryStatus += (sender, args) =>
                {
                    PublishFlagCommand.Checked = true;
                    PublishFlagCommand.Text = PublishFlag;
                };
            }
            else
            {
                PublishFlagCommand = new OleMenuCommand((sender, args) => PublishCommand(sender, args, PublishFlag), PublishFlagCommandID);
                PublishFlagCommand.BeforeQueryStatus += (sender, args) => PublishCommandBeforeQueryStatus(sender, args, PublishFlagCommand, PublishFlag);
            }

            AddCommandWithEnableFlag(mcs, PublishFlagCommand, rdtm);
        }
Exemplo n.º 3
0
 void AddSolutionExplorerCommand(IMenuCommandService mcs, OleMenuCommand command, UDNDocRunningTableMonitor rdtm)
 {
     command.BeforeQueryStatus += (sender, args) =>
     {
         var cmd = sender as OleMenuCommand;
         if (cmd != null)
         {
             var selectedItems = (Array)uih.SelectedItems;
             if (null != selectedItems)
             {
                 foreach (UIHierarchyItem selectedItem in selectedItems)
                 {
                     var projectItem = selectedItem.Object as ProjectItem;
                     var pathString = projectItem.Properties.Item("FullPath").Value.ToString();
                     if (!pathString.EndsWith(".udn"))
                     {
                         cmd.Visible = false;
                         break;
                     }
                     cmd.Visible = true;
                 }
             }
         }
     };
     mcs.AddCommand(command);
 }
Exemplo n.º 4
0
        void AddCommandWithEnableFlag(IMenuCommandService mcs, OleMenuCommand command, UDNDocRunningTableMonitor rdtm)
        {
            command.BeforeQueryStatus += new EventHandler((sender, args) =>
            {
                var cmd = sender as OleMenuCommand;
                cmd.Enabled = (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownRebuildDoxygenDatabase)
                                  ? (!_doxygenIsRebuilding && rdtm.CommandsEnabled)
                                  : rdtm.CommandsEnabled;
                cmd.Visible = rdtm.CommandsEnabled;
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownDisableParsing)
                {
                    cmd.Checked = Settings.Default.DisableAllParsing;
                }
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownDisableHighlighting)
                {
                    cmd.Enabled = !Settings.Default.DisableAllParsing;  //Turn off the highlighting button when full parsing is disabled
                    cmd.Checked = Settings.Default.DisableHighlighting;
                }
                if (cmd.CommandID.ID == PkgCmdId.cmdidMarkdownPreviewWindow)
                {
                    cmd.Enabled = !Settings.Default.DisableAllParsing;
                }
                
            });

            mcs.AddCommand(command);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            foreach (string publishFlag in Settings.SupportedAvailabilities)
            {
                PublishFlags.Add(publishFlag);
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
            if (mcs != null)
            {
                var rdt = GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
                var ms = GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

                var componentModel = GetService(typeof(SComponentModel)) as IComponentModel;

                var shell = GetService(typeof(SVsUIShell)) as IVsUIShell;
                shell.UpdateCommandUI(1);

                rdtm = new UDNDocRunningTableMonitor(rdt, ms, componentModel.GetService<IVsEditorAdaptersFactoryService>(), shell, this);

                uint cookie;
                rdt.AdviseRunningDocTableEvents(rdtm, out cookie);

				// Create the command for the tool window
                CommandID publishRecursiveCmdID = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.CmdidMarkdownPublishRecursiveCtxt);
                OleMenuCommand publishRecursiveSlnExpCommand = new OleMenuCommand(new EventHandler((sender, e) => PublishSelectedDocuments(sender, e,true)), publishRecursiveCmdID);
                AddSolutionExplorerCommand(mcs, publishRecursiveSlnExpCommand, rdtm);
                
                CommandID publishCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPublishPagesCtxt);
                OleMenuCommand publishCommand = new OleMenuCommand(new EventHandler((sender, e) => PublishSelectedDocuments(sender, e, false)), publishCommandID);
                AddSolutionExplorerCommand(mcs, publishCommand, rdtm);

                CommandID publishPreviewCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet,PkgCmdId.cmdidMarkdownPreviewPage);
                OleMenuCommand publishPreviewCommand = new OleMenuCommand(new EventHandler((sender, e) => PublishOrPreviewPage(sender, e, " -p")), publishPreviewCommandID);
                AddCommandWithEnableFlag(mcs, publishPreviewCommand, rdtm);

                CommandID publishPageCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet,PkgCmdId.cmdidMarkdownPublishPage);
                OleMenuCommand publishPageCommand = new OleMenuCommand(new EventHandler((sender,e) => PublishOrPreviewPage(sender,e,"")), publishPageCommandID);
                AddCommandWithEnableFlag(mcs, publishPageCommand, rdtm);

                CommandID publishRecursiveCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet,PkgCmdId.cmdidMarkdownPublishRecursive);
                OleMenuCommand publishRecursiveCommand = new OleMenuCommand(new EventHandler(PublishRecursive),publishRecursiveCommandID );
                AddCommandWithEnableFlag(mcs,publishRecursiveCommand,rdtm);

                CommandID SetTextToBoldCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownBoldText);
                OleMenuCommand SetTextToBoldCommand = new OleMenuCommand(new EventHandler((sender, e) => SetTextStyle(sender, e, "**")), SetTextToBoldCommandID);
                AddCommandWithEnableFlag(mcs, SetTextToBoldCommand, rdtm);

                CommandID SetTextToItalicsCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownItalicText);
                OleMenuCommand SetTextToItalicCommand = new OleMenuCommand(new EventHandler((sender, e) => SetTextStyle(sender, e, "_")), SetTextToItalicsCommandID);
                AddCommandWithEnableFlag(mcs, SetTextToItalicCommand, rdtm);

                CommandID SetTextToCodeCommandID = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownCodeText);
                OleMenuCommand SetTextToCodeCommand = new OleMenuCommand(new EventHandler((sender, e) => SetTextStyle(sender, e, "`")), SetTextToCodeCommandID);
                AddCommandWithEnableFlag(mcs, SetTextToCodeCommand, rdtm);

                // Create the command for the tool window
                var showPreviewWindowCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownPreviewWindow);
                var showPreviewWindowCommand = new OleMenuCommand(ShowToolWindow, showPreviewWindowCommandId);
                AddCommandWithEnableFlag(mcs, showPreviewWindowCommand, rdtm);

                var openImagesCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownOpenImagesFolder);
                var openImagesCommand = new OleMenuCommand(OpenImageFolder, openImagesCommandId);
                AddCommandWithEnableFlag(mcs, openImagesCommand, rdtm);

                var navigateToComboCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownNavigateToCombo);
                var navigateToCombo = new OleMenuCommand(NavigateToComboSelected, navigateToComboCommandId);
                AddCommandWithEnableFlag(mcs, navigateToCombo, rdtm);

                var navigateToComboGetListCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownNavigateToComboGetList);
                var navigateToComboGetListCmd = new OleMenuCommand(NavigateToComboGetList, navigateToComboGetListCommandId);
                AddCommandWithEnableFlag(mcs, navigateToComboGetListCmd, rdtm);

                InitializePublishFlagButtons(mcs, rdtm);

                var rebuildDoxygenCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownRebuildDoxygenDatabase);
                var rebuildDoxygenCommand = new OleMenuCommand(RebuildDoxygen, rebuildDoxygenCommandId);
                AddCommandWithEnableFlag(mcs, rebuildDoxygenCommand, rdtm);

                var checkP4ImagesCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownCheckP4Images);
                var checkP4ImagesCommand = new OleMenuCommand(CheckP4Images, checkP4ImagesCommandId);
                AddCommandWithEnableFlag(mcs, checkP4ImagesCommand, rdtm);

                var disableParsingCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownDisableParsing);
                var disableParsingCommand = new OleMenuCommand(DisableDocumentParsing, disableParsingCommandId);
                AddCommandWithEnableFlag(mcs, disableParsingCommand, rdtm);

                var disableHighlightingCommandId = new CommandID(GuidList.guidMarkdownPackageCmdSet, PkgCmdId.cmdidMarkdownDisableHighlighting);
                var disableHighlightingCommand = new OleMenuCommand(DisableHighlightingMode, disableHighlightingCommandId);
                AddCommandWithEnableFlag(mcs, disableHighlightingCommand, rdtm);
            }

            Action reloadSettings = () =>
                {
                    string newDoxygenXmlPath = null;

                    if (!string.IsNullOrEmpty(GetOptions().DoxygenXmlCachePath))
                    {
                        newDoxygenXmlPath = GetOptions().DoxygenXmlCachePath;
                    }

                    DoxygenHelper.DoxygenXmlPath = newDoxygenXmlPath;


                    FileInfo newDoxygenExec = null;

                    if (!string.IsNullOrEmpty(GetOptions().DoxygenBinaryPath))
                    {
                        var doxygenExec = new FileInfo(GetOptions().DoxygenBinaryPath);
                        if (doxygenExec.Exists)
                        {
                            newDoxygenExec = doxygenExec;
                        }
                    }

                    DoxygenHelper.DoxygenExec = newDoxygenExec;
                };

            Action loadLastPublishingOptions = () =>
            {
                if (!Settings.Default.FirstRun)
                {
                    PublishFlags.Clear();
                    if (Settings.Default.LastAvailability != "")
                    {
                        var lastSettings = Settings.Default.LastAvailability.Split(',');
                        foreach (string lastSetting in lastSettings)
                        {
                            PublishFlags.Add(lastSetting);
                        }
                    }
                }
                else
                {
                    PublishFlags.Clear();
                    Settings.Default.FirstRun = false;
                    Settings.Default.Save();
                }
                
            };

            GetOptions().Changed += () => reloadSettings();
            reloadSettings();
            loadLastPublishingOptions();
        }