diff --git a/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs b/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs index 7921dcc839..cdba04ac28 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs @@ -121,7 +121,7 @@ namespace MSHelpSystem.Core static void DisplayLocalHelp(string arguments) { // TODO: set "embedded" to TRUE if we have a TOC control or something similar - DisplayLocalHelp(arguments, true); + DisplayLocalHelp(arguments, false); } static void DisplayLocalHelp(string arguments, bool embedded) diff --git a/src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs b/src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs index cb5157c16d..259b85bd84 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs @@ -42,6 +42,11 @@ namespace MSHelpSystem.Core { get { return displayName; } } + + public string ShortName + { + get { return string.Format(@"{0}/{1}/{2}", productCode, productVersion, productLocale); } + } public string CatalogPath { @@ -57,10 +62,5 @@ namespace MSHelpSystem.Core { get { return brandingPackage; } } - - public override string ToString() - { - return string.Format(@"{0}/{1}/{2}", productCode, productVersion, productLocale); - } } } \ No newline at end of file diff --git a/src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs b/src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs index 4b84a7405c..44be723831 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs @@ -67,17 +67,17 @@ namespace MSHelpSystem.Core static void Help3HasUpdatedTheCatalogs(object sender, EventArgs e) { if (string.IsNullOrEmpty(config.ActiveCatalogId)) { - config.ActiveCatalogId = (catalogs.Count > 0) ? catalogs[0].ToString():string.Empty; + config.ActiveCatalogId = (catalogs.Count > 0) ? catalogs[0].ShortName:string.Empty; } - activeCatalog = (string.IsNullOrEmpty(config.ActiveCatalogId)) ? null:FindCatalogByItsString(config.ActiveCatalogId); + activeCatalog = (string.IsNullOrEmpty(config.ActiveCatalogId)) ? null:FindCatalogByItsShortName(config.ActiveCatalogId); } static void Help3ActiveCatalogIdChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(config.ActiveCatalogId)) { - config.ActiveCatalogId = (catalogs.Count > 0) ? catalogs[0].ToString():string.Empty; + config.ActiveCatalogId = (catalogs.Count > 0) ? catalogs[0].ShortName:string.Empty; } - activeCatalog = (string.IsNullOrEmpty(config.ActiveCatalogId)) ? null:FindCatalogByItsString(config.ActiveCatalogId); + activeCatalog = (string.IsNullOrEmpty(config.ActiveCatalogId)) ? null:FindCatalogByItsShortName(config.ActiveCatalogId); } static void Help3ConfigurationUpdated(object sender, EventArgs e) @@ -111,7 +111,7 @@ namespace MSHelpSystem.Core public static Help3Catalog FindCatalogByProductCode(string productCode) { foreach (Help3Catalog catalog in catalogs) { - if (string.Compare(productCode, catalog.ProductCode, true) == 0) { + if (productCode.Equals(catalog.ProductCode, StringComparison.InvariantCultureIgnoreCase)) { return catalog; } } @@ -121,17 +121,17 @@ namespace MSHelpSystem.Core public static Help3Catalog FindCatalogByDisplayName(string displayName) { foreach (Help3Catalog catalog in catalogs) { - if (string.Compare(displayName, catalog.DisplayName, true) == 0) { + if (displayName.Equals(catalog.DisplayName, StringComparison.InvariantCultureIgnoreCase)) { return catalog; } } return null; } - public static Help3Catalog FindCatalogByItsString(string stringValue) + public static Help3Catalog FindCatalogByItsShortName(string catalogString) { foreach (Help3Catalog catalog in catalogs) { - if (string.Compare(stringValue, catalog.ToString()) == 0) { + if (catalogString.Equals(catalog.ShortName, StringComparison.InvariantCultureIgnoreCase)) { return catalog; } } diff --git a/src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs b/src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs index 2625d1f7ad..68627dca15 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs @@ -56,7 +56,7 @@ namespace MSHelpSystem.Core { Process[] agents = Process.GetProcessesByName("HelpLibAgent"); int processId = (agents.Length > 0) ? agents[0].Id:0; - LoggingService.Debug(string.Format("Help 3.0: Help library agent uses has the process ID \"{0}\"", processId)); + LoggingService.Debug(string.Format("Help 3.0: Help library agent has the process ID \"{0}\"", processId)); return processId; } } diff --git a/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml b/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml index e7a7afbee4..c15d45ca78 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml +++ b/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml @@ -7,12 +7,22 @@ > - + - - + + diff --git a/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs b/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs index 65ed11f7bf..6472351cb3 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Forms; @@ -15,46 +17,26 @@ namespace MSHelpSystem public Help3OptionsPanel() { InitializeComponent(); - LoadCatalogs(); - onlineMode.IsChecked = !Help3Service.Config.OfflineMode; + Load(); } - void LoadCatalogs() + void Load() { HelpLibraryAgent.Start(); - - help3Catalogs.Items.Clear(); - if (Help3Service.Count > 0) { - foreach (Help3Catalog catalog in Help3Service.Items) { - LoggingService.Debug(string.Format("Help 3.0: Found help catalog \"{0}\"", catalog.ToString())); - ComboBoxItem cbi = new ComboBoxItem(); - cbi.Content = catalog.ToString(); - help3Catalogs.Items.Add(cbi); - } - } + DataContext = Help3Service.Items; // TODO: Needs a localization groupBox1.Header = string.Format("{0} ({1})", "Installed Help catalogs", Help3Service.Count); - - if (help3Catalogs.Items.Count == 1) help3Catalogs.SelectedIndex = 0; - else { - foreach (ComboBoxItem item in help3Catalogs.Items) { - if (string.Compare((string)item.Content, Help3Service.ActiveCatalog.ToString(), true) == 0) { - help3Catalogs.SelectedItem = item; - break; - } - } - // TODO: There has to be a much more elegant way to select the catalog?! - } - help3Catalogs.IsEnabled = (help3Catalogs.Items.Count > 1 && Help3Service.Config.OfflineMode); + help3Catalogs.SelectedValue = Help3Service.ActiveCatalog.ShortName; + help3Catalogs.IsEnabled = (Help3Service.Count > 1 && Help3Service.Config.OfflineMode); + onlineMode.IsChecked = !Help3Service.Config.OfflineMode; } void Help3CatalogsSelectionChanged(object sender, SelectionChangedEventArgs e) { - ComboBoxItem selectedItem = (ComboBoxItem)help3Catalogs.SelectedItem; - if (selectedItem == null) return; - string activeCatalog = (string)selectedItem.Content; - if (!string.IsNullOrEmpty(activeCatalog)) - Help3Service.ActiveCatalogId =activeCatalog; + string item = (string)help3Catalogs.SelectedValue; + if (!string.IsNullOrEmpty(item)) { + Help3Service.ActiveCatalogId = item; + } } void Help3OfflineModeClicked(object sender, RoutedEventArgs e) diff --git a/src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs b/src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs index d4e7714b52..c346cc567c 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs @@ -40,7 +40,7 @@ namespace MSHelpSystem.Helper public static bool IsLocalHelp { - get { return string.Compare("offline", helpMode, true) == 0; } + get { return helpMode.Equals("offline", StringComparison.InvariantCultureIgnoreCase); } } public static void EnableLocalHelp()