diff --git a/src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs b/src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs index 9711bc73f4..a8affef636 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Controls/SearchPadControl.xaml.cs @@ -34,13 +34,12 @@ namespace MSHelpSystem.Controls void DoSearchClicked(object sender, RoutedEventArgs e) { string term = searchCB.Text; - if (string.IsNullOrEmpty(term)) { - throw new ArgumentNullException("term"); + if (!string.IsNullOrEmpty(term)) { + searchCB.Text = ""; + if (searchTerms.IndexOf(term) < 0) searchTerms.Insert(0,term); + else searchTerms.Move(searchTerms.IndexOf(term), 0); + DisplayHelp.Search(term); } - searchCB.Text = ""; - if (searchTerms.IndexOf(term) < 0) searchTerms.Insert(0,term); - else searchTerms.Move(searchTerms.IndexOf(term), 0); - DisplayHelp.Search(term); } } } \ No newline at end of file diff --git a/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs b/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs index 2e2618eb49..49be86a114 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs @@ -17,53 +17,55 @@ namespace MSHelpSystem.Core { } - public static void Catalog() + public static bool Catalog() { if (!Help3Environment.IsLocalHelp) { MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"), StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"), MessageBoxButtons.OK, MessageBoxIcon.Error); - return; + return false; } if (Help3Service.ActiveCatalog == null) { - throw new ArgumentNullException("Help3Service.ActiveCatalog"); + return false; } string helpCatalogUrl = string.Format(@"ms-xhelp://?method=page&id=-1&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam); LoggingService.Debug(string.Format("Help 3.0: {0}", helpCatalogUrl)); DisplayLocalHelp(helpCatalogUrl); + return true; } - public static void Page(string pageId) + public static bool Page(string pageId) { if (string.IsNullOrEmpty(pageId)) { - throw new ArgumentNullException("pageId"); + return false; } if (!Help3Environment.IsLocalHelp) { MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"), StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"), MessageBoxButtons.OK, MessageBoxIcon.Error); - return; + return false; } if (Help3Service.ActiveCatalog == null) { - throw new ArgumentNullException("Help3Service.ActiveCatalog"); + return false; } string helpPageUrl = string.Format(@"ms-xhelp://?method=page&id={1}&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam, pageId); LoggingService.Debug(string.Format("Help 3.0: {0}", helpPageUrl)); DisplayLocalHelp(helpPageUrl); + return true; } public static bool ContextualHelp(string contextual) { if (string.IsNullOrEmpty(contextual)) { - throw new ArgumentNullException("contextual"); + return false; } if (!Help3Environment.IsLocalHelp) { DisplayHelpOnMSDN(contextual); return true; } - if (Help3Service.ActiveCatalog == null) { + if (Help3Service.ActiveCatalog == null) { return false; } string helpContextualUrl = string.Format(@"ms-xhelp://?method=f1&query={1}&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam, contextual); @@ -72,41 +74,43 @@ namespace MSHelpSystem.Core return true; } - public static void Search(string searchWords) + public static bool Search(string searchWords) { if (string.IsNullOrEmpty(searchWords)) { - throw new ArgumentNullException("searchWords"); + return false; } if (!Help3Environment.IsLocalHelp) { DisplaySearchOnMSDN(searchWords); - return; + return true; } if (Help3Service.ActiveCatalog == null) { - throw new ArgumentNullException("Help3Service.ActiveCatalog"); + return false; } string helpSearchUrl = string.Format(@"ms-xhelp://?method=search&query={1}&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam, searchWords.Replace(" ", "+")); LoggingService.Debug(string.Format("Help 3.0: {0}", helpSearchUrl)); DisplayLocalHelp(helpSearchUrl); + return true; } - public static void Keywords(string keywords) + public static bool Keywords(string keywords) { if (string.IsNullOrEmpty(keywords)) { - throw new ArgumentNullException("keywords"); + return false; } if (!Help3Environment.IsLocalHelp) { MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"), StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"), MessageBoxButtons.OK, MessageBoxIcon.Error); - return; + return false; } if (Help3Service.ActiveCatalog == null) { - throw new ArgumentNullException("Help3Service.ActiveCatalog"); + return false; } string helpKeywordsUrl = string.Format(@"ms-xhelp://?method=keywords&query={1}&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam, keywords.Replace(" ", "+")); LoggingService.Debug(string.Format("Help 3.0: {0}", helpKeywordsUrl)); DisplayLocalHelp(helpKeywordsUrl); + return true; }