Ejemplo n.º 1
0
        private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue)
        {
            if (string.IsNullOrEmpty(pageName) && string.IsNullOrEmpty(alternatePageName))
            {
                throw new ArgumentNullException("pageName & alternatePageName");
            }
            try
            {
                string result = string.Empty;

                IHxIndex namedUrlIndex =
                    (IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex", "", ref IndexGuid);
                IHxTopicList topics = namedUrlIndex.GetTopicsFromString(pageName, 0);

                if (topics.Count == 0 && !string.IsNullOrEmpty(alternatePageName))
                {
                    topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0);
                }

                if (topics.Count > 0)
                {
                    result = topics.ItemAt(1).URL;
                }
                if (string.IsNullOrEmpty(result))
                {
                    result = defaultValue;
                }

                return(result);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                return(defaultValue);
            }
        }
Ejemplo n.º 2
0
        private void ShowSelectedItemEntry(string indexTerm, int indexSlot)
        {
            PadDescriptor indexResults =
                WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2IndexResultsPad));

            if (indexResults == null)
            {
                return;
            }

            try
            {
                IHxTopicList matchingTopics = indexControl.IndexData.GetTopicsFromSlot(indexSlot);

                try
                {
                    ((HtmlHelp2IndexResultsPad)indexResults.PadContent).CleanUp();
                    ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.BeginUpdate();

                    foreach (IHxTopic topic in matchingTopics)
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi.Text =
                            topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle,
                                            HxTopicGetTitleDefVal.HxTopicGetTitleFileName);
                        lvi.Tag = topic;
                        lvi.SubItems.Add(topic.Location);
                        ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.Items.Add(lvi);
                    }
                }
                finally
                {
                    ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.EndUpdate();
                    ((HtmlHelp2IndexResultsPad)indexResults.PadContent).SortLV(0);
                    ((HtmlHelp2IndexResultsPad)indexResults.PadContent).SetStatusMessage(indexTerm);
                }

                switch (matchingTopics.Count)
                {
                case 0:
                    break;

                case 1:
                    IHxTopic topic = (IHxTopic)matchingTopics.ItemAt(1);
                    if (topic != null)
                    {
                        ShowHelpBrowser.OpenHelpView(topic);
                    }
                    break;

                default:
                    indexResults.BringPadToFront();
                    break;
                }
            }
            catch (System.Runtime.InteropServices.COMException cEx)
            {
                LoggingService.Error("Help 2.0: cannot get matching index entries; " + cEx.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts the command
        /// </summary>
        public override void Run()
        {
            ICSharpCode.SharpDevelop.Gui.TaskView view = (ICSharpCode.SharpDevelop.Gui.TaskView)Owner;

            // Search all selected tasks
            foreach (Task t in new List <Task>(view.SelectedTasks))
            {
                if (t.BuildError == null)
                {
                    continue;
                }

                string code = t.BuildError.ErrorCode;

                if (string.IsNullOrEmpty(code))
                {
                    return;
                }

                // Get help content
                MSHelpServices.IHxTopic topic;

                // If HtmlHelp2 AddIn is initialised correctly we can start!
                if (HtmlHelp2.Environment.HtmlHelp2Environment.SessionIsInitialized)
                {
                    // Get the topic
                    IHxIndex index = HtmlHelp2.Environment.HtmlHelp2Environment.GetIndex("");
                    if (index == null)
                    {
                        MessageService.ShowErrorFormatted("No help available for {0}!", code);
                        return;
                    }
                    int indexSlot = index.GetSlotFromString(code);
                    if (indexSlot <= 0)
                    {
                        MessageService.ShowErrorFormatted("No help available for {0}!", code);
                        return;
                    }
                    IHxTopicList list = index.GetTopicsFromSlot(indexSlot);
                    if (list == null)
                    {
                        MessageService.ShowErrorFormatted("No help available for {0}!", code);
                        return;
                    }
                    try {
                        topic = list.ItemAt(1);
                    } catch (ArgumentException) {
                        topic = null;
                    }
                    if (topic == null)
                    {
                        MessageService.ShowErrorFormatted("No help available for {0}!", code);
                        return;
                    }
                    string topicTitle = topic.get_Title(HxTopicGetTitleType.HxTopicGetTOCTitle, HxTopicGetTitleDefVal.HxTopicGetTitleFileName);
                    if (topicTitle == null || !topicTitle.Contains(code))
                    {
                        MessageService.ShowErrorFormatted("No help available for {0}!", code);
                        return;
                    }
                }
                else                     // Otherwise we have to show an Error message ...
                {
                    LoggingService.Error("Couldn't initialize help database");
                    return;
                }

                // Show Browser window
                HtmlHelp2.ShowHelpBrowser.OpenHelpView(topic);
            }
        }