Browse Source

new property for catalog class replaces the ToString() usage, fixed a misspelling in a debug message, options dialog uses data binding

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5843 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Mathias Simmack 16 years ago
parent
commit
34a8c8b85f
  1. 2
      src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs
  2. 10
      src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs
  3. 16
      src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs
  4. 2
      src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs
  5. 16
      src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml
  6. 42
      src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs
  7. 2
      src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs

2
src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs

@ -121,7 +121,7 @@ namespace MSHelpSystem.Core
static void DisplayLocalHelp(string arguments) static void DisplayLocalHelp(string arguments)
{ {
// TODO: set "embedded" to TRUE if we have a TOC control or something similar // 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) static void DisplayLocalHelp(string arguments, bool embedded)

10
src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs

@ -42,6 +42,11 @@ namespace MSHelpSystem.Core
{ {
get { return displayName; } get { return displayName; }
} }
public string ShortName
{
get { return string.Format(@"{0}/{1}/{2}", productCode, productVersion, productLocale); }
}
public string CatalogPath public string CatalogPath
{ {
@ -57,10 +62,5 @@ namespace MSHelpSystem.Core
{ {
get { return brandingPackage; } get { return brandingPackage; }
} }
public override string ToString()
{
return string.Format(@"{0}/{1}/{2}", productCode, productVersion, productLocale);
}
} }
} }

16
src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs

@ -67,17 +67,17 @@ namespace MSHelpSystem.Core
static void Help3HasUpdatedTheCatalogs(object sender, EventArgs e) static void Help3HasUpdatedTheCatalogs(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(config.ActiveCatalogId)) { 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) static void Help3ActiveCatalogIdChanged(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(config.ActiveCatalogId)) { 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) static void Help3ConfigurationUpdated(object sender, EventArgs e)
@ -111,7 +111,7 @@ namespace MSHelpSystem.Core
public static Help3Catalog FindCatalogByProductCode(string productCode) public static Help3Catalog FindCatalogByProductCode(string productCode)
{ {
foreach (Help3Catalog catalog in catalogs) { foreach (Help3Catalog catalog in catalogs) {
if (string.Compare(productCode, catalog.ProductCode, true) == 0) { if (productCode.Equals(catalog.ProductCode, StringComparison.InvariantCultureIgnoreCase)) {
return catalog; return catalog;
} }
} }
@ -121,17 +121,17 @@ namespace MSHelpSystem.Core
public static Help3Catalog FindCatalogByDisplayName(string displayName) public static Help3Catalog FindCatalogByDisplayName(string displayName)
{ {
foreach (Help3Catalog catalog in catalogs) { foreach (Help3Catalog catalog in catalogs) {
if (string.Compare(displayName, catalog.DisplayName, true) == 0) { if (displayName.Equals(catalog.DisplayName, StringComparison.InvariantCultureIgnoreCase)) {
return catalog; return catalog;
} }
} }
return null; return null;
} }
public static Help3Catalog FindCatalogByItsString(string stringValue) public static Help3Catalog FindCatalogByItsShortName(string catalogString)
{ {
foreach (Help3Catalog catalog in catalogs) { foreach (Help3Catalog catalog in catalogs) {
if (string.Compare(stringValue, catalog.ToString()) == 0) { if (catalogString.Equals(catalog.ShortName, StringComparison.InvariantCultureIgnoreCase)) {
return catalog; return catalog;
} }
} }

2
src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs

@ -56,7 +56,7 @@ namespace MSHelpSystem.Core
{ {
Process[] agents = Process.GetProcessesByName("HelpLibAgent"); Process[] agents = Process.GetProcessesByName("HelpLibAgent");
int processId = (agents.Length > 0) ? agents[0].Id:0; 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; return processId;
} }
} }

16
src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml

@ -7,12 +7,22 @@
> >
<StackPanel> <StackPanel>
<GroupBox Header="Installed Help catalogs" Margin="5" Padding="8" Name="groupBox1"> <GroupBox Header="Installed Help catalogs" Margin="5" Padding="8" Name="groupBox1">
<ComboBox Name="help3Catalogs" SelectionChanged="Help3CatalogsSelectionChanged" /> <ComboBox Name="help3Catalogs"
ItemsSource="{Binding}"
DisplayMemberPath="ShortName"
SelectedValuePath="ShortName"
SelectionChanged="Help3CatalogsSelectionChanged" />
</GroupBox> </GroupBox>
<GroupBox Header="Help Mode" Margin="5" Padding="8" Name="groupBox2"> <GroupBox Header="Help Mode" Margin="5" Padding="8" Name="groupBox2">
<StackPanel> <StackPanel>
<RadioButton Name="offlineMode" IsChecked="True" Content="I want to use local help" Click="Help3OfflineModeClicked" Margin="0,0,0,5"/> <RadioButton Name="offlineMode"
<RadioButton Name="onlineMode" Content="I want to use online help" Click="Help3OnlineModeClicked" /> IsChecked="True"
Content="I want to use local help"
Click="Help3OfflineModeClicked"
Margin="0,0,0,5"/>
<RadioButton Name="onlineMode"
Content="I want to use online help"
Click="Help3OnlineModeClicked" />
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
</StackPanel> </StackPanel>

42
src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs

@ -1,4 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms; using System.Windows.Forms;
@ -15,46 +17,26 @@ namespace MSHelpSystem
public Help3OptionsPanel() public Help3OptionsPanel()
{ {
InitializeComponent(); InitializeComponent();
LoadCatalogs(); Load();
onlineMode.IsChecked = !Help3Service.Config.OfflineMode;
} }
void LoadCatalogs() void Load()
{ {
HelpLibraryAgent.Start(); HelpLibraryAgent.Start();
DataContext = Help3Service.Items;
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);
}
}
// TODO: Needs a localization // TODO: Needs a localization
groupBox1.Header = string.Format("{0} ({1})", "Installed Help catalogs", Help3Service.Count); groupBox1.Header = string.Format("{0} ({1})", "Installed Help catalogs", Help3Service.Count);
help3Catalogs.SelectedValue = Help3Service.ActiveCatalog.ShortName;
if (help3Catalogs.Items.Count == 1) help3Catalogs.SelectedIndex = 0; help3Catalogs.IsEnabled = (Help3Service.Count > 1 && Help3Service.Config.OfflineMode);
else { onlineMode.IsChecked = !Help3Service.Config.OfflineMode;
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);
} }
void Help3CatalogsSelectionChanged(object sender, SelectionChangedEventArgs e) void Help3CatalogsSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
ComboBoxItem selectedItem = (ComboBoxItem)help3Catalogs.SelectedItem; string item = (string)help3Catalogs.SelectedValue;
if (selectedItem == null) return; if (!string.IsNullOrEmpty(item)) {
string activeCatalog = (string)selectedItem.Content; Help3Service.ActiveCatalogId = item;
if (!string.IsNullOrEmpty(activeCatalog)) }
Help3Service.ActiveCatalogId =activeCatalog;
} }
void Help3OfflineModeClicked(object sender, RoutedEventArgs e) void Help3OfflineModeClicked(object sender, RoutedEventArgs e)

2
src/AddIns/Misc/HelpViewer/Source/Helper/HelpClientWatcher.cs

@ -40,7 +40,7 @@ namespace MSHelpSystem.Helper
public static bool IsLocalHelp public static bool IsLocalHelp
{ {
get { return string.Compare("offline", helpMode, true) == 0; } get { return helpMode.Equals("offline", StringComparison.InvariantCultureIgnoreCase); }
} }
public static void EnableLocalHelp() public static void EnableLocalHelp()

Loading…
Cancel
Save