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 @@ -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)

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

@ -42,6 +42,11 @@ namespace MSHelpSystem.Core @@ -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 @@ -57,10 +62,5 @@ namespace MSHelpSystem.Core
{
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 @@ -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 @@ -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 @@ -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;
}
}

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

@ -56,7 +56,7 @@ namespace MSHelpSystem.Core @@ -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;
}
}

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

@ -7,12 +7,22 @@ @@ -7,12 +7,22 @@
>
<StackPanel>
<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 Header="Help Mode" Margin="5" Padding="8" Name="groupBox2">
<StackPanel>
<RadioButton Name="offlineMode" 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" />
<RadioButton Name="offlineMode"
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>
</GroupBox>
</StackPanel>

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

@ -1,4 +1,6 @@ @@ -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 @@ -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)

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

@ -40,7 +40,7 @@ namespace MSHelpSystem.Helper @@ -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()

Loading…
Cancel
Save