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 bool CallDynamicHelp(string searchTerm, bool keywordSearch)
        {
            if (!HtmlHelp2Environment.SessionIsInitialized || HtmlHelp2Environment.DynamicHelpIsBusy)
            {
                return(false);
            }

            IHxTopicList topics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchTerm);
            bool         result = (topics != null && topics.Count > 0);

            if (result)
            {
                // debug info
                this.debugPreElement +=
                    string.Format(CultureInfo.InvariantCulture,
                                  "{0} ({1}): {2} {3}<br>", searchTerm, (keywordSearch)?"Kwd":"DH",
                                  topics.Count, (topics.Count == 1)?"topic":"topics");

                List <IHxTopic> newTopics = SortTopics(topics);
                foreach (IHxTopic topic in newTopics)
                {
                    if ((keywordSearch)?SharpDevLanguage.CheckUniqueTopicLanguage(topic):SharpDevLanguage.CheckTopicLanguage(topic))
                    {
                        this.BuildNewChild(topic.Location,
                                           topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle,
                                                           HxTopicGetTitleDefVal.HxTopicGetTitleFileName),
                                           topic.URL);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
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.º 4
0
        private static List <IHxTopic> SortTopics(IHxTopicList topics)
        {
            if (topics == null || topics.Count == 0)
            {
                return(null);
            }

            List <IHxTopic> result = new List <IHxTopic>();

            foreach (IHxTopic topic in topics)
            {
                if (!result.Contains(topic))
                {
                    result.Add(topic);
                }
            }
            TopicComparer topicComparer = new TopicComparer();

            result.Sort(topicComparer);

            return(result);
        }
Ejemplo n.º 5
0
        private void PerformFts(string searchWord, bool useDynamicHelp)
        {
            if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(searchWord) || searchIsBusy)
            {
                return;
            }

            HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;

            HtmlHelp2Dialog searchDialog = new HtmlHelp2Dialog();

            try
            {
                searchIsBusy = true;
                IHxTopicList matchingTopics = null;

                HxQuery_Options searchFlags = HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (titlesOnly.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Title_Only:HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (enableStemming.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Enable_Stemming:HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (reuseMatches.Checked)?HxQuery_Options.HxQuery_FullTextSearch_SearchPrevious:HxQuery_Options.HxQuery_No_Option;

                searchDialog.Text        = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchCaption}");
                searchDialog.ActionLabel = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchInProgress}",
                                                              new string[, ]
                {
                    { "0", searchWord }
                });
                searchDialog.Show();
                Application.DoEvents();
                Cursor.Current = Cursors.WaitCursor;
                if (useDynamicHelp)
                {
                    matchingTopics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchWord);
                }
                else
                {
                    matchingTopics = HtmlHelp2Environment.Fts.Query(searchWord, searchFlags);
                }

                Cursor.Current = Cursors.Default;

                try
                {
                    searchResults.CleanUp();
                    searchResults.SearchResultsListView.BeginUpdate();

                    foreach (IHxTopic topic in matchingTopics)
                    {
                        if (useCurrentLang.Checked && !useDynamicHelp && !SharpDevLanguage.CheckTopicLanguage(topic))
                        {
                            continue;
                        }

                        ListViewItem lvi = new ListViewItem();
                        lvi.Text = topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle,
                                                   HxTopicGetTitleDefVal.HxTopicGetTitleFileName);
                        lvi.Tag = topic;
                        lvi.SubItems.Add(topic.Location);
                        lvi.SubItems.Add(topic.Rank.ToString(CultureInfo.CurrentCulture));

                        searchResults.SearchResultsListView.Items.Add(lvi);
                    }

                    reuseMatches.Enabled = true;
                }
                finally
                {
                    searchResults.SearchResultsListView.EndUpdate();
                    searchResults.SetStatusMessage(searchTerm.Text);
                    SearchAndReplace.SearchResultPanel.Instance.ShowSearchResults(
                        new SearchAndReplace.SearchResult(searchTerm.Text, searchResults)
                        );
                    searchIsBusy = false;
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                LoggingService.Error("Help 2.0: cannot get matching search word; " + ex.ToString());

                foreach (Control control in this.mainPanel.Controls)
                {
                    control.Enabled = false;
                }
            }
            finally
            {
                searchDialog.Dispose();
            }
        }
Ejemplo n.º 6
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);
            }
        }