Browse Source

new properties for the Help3Catalog class and translatable messages and labels

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5850 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Mathias Simmack 15 years ago
parent
commit
181f2f0372
  1. 8
      src/AddIns/Misc/HelpViewer/HelpViewer.addin
  2. 10
      src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs
  3. 3
      src/AddIns/Misc/HelpViewer/Source/Controls/TocPadControl.xaml.cs
  4. 52
      src/AddIns/Misc/HelpViewer/Source/Core/DisplayHelp.cs
  5. 10
      src/AddIns/Misc/HelpViewer/Source/Core/Help3Catalog.cs
  6. 5
      src/AddIns/Misc/HelpViewer/Source/Core/Help3Service.cs
  7. 24
      src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryAgent.cs
  8. 5
      src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryManager.cs
  9. 10
      src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml
  10. 7
      src/AddIns/Misc/HelpViewer/Source/Help3OptionsPanel.xaml.cs

8
src/AddIns/Misc/HelpViewer/HelpViewer.addin

@ -17,17 +17,17 @@ @@ -17,17 +17,17 @@
</Path>
<Path name="/SharpDevelop/Pads/ErrorList/TaskContextMenu">
<MenuItem id = "Help3ShowErrorHelp" label = "Show Help" class = "MSHelpSystem.Commands.ShowErrorHelpCommand" />
<MenuItem id = "Help3ShowErrorHelp" label = "${res:AddIns.HelpViewer.ShowErrorHelpTitle}" class = "MSHelpSystem.Commands.ShowErrorHelpCommand" />
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id = "Help3Options" label = "Microsoft Help Viewer" class = "MSHelpSystem.Help3OptionsPanel" />
<OptionPanel id = "Help3Options" label = "${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}" class = "MSHelpSystem.Help3OptionsPanel" />
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "Help3TocPad"
category = "Help3"
title = "Contents"
title = "${res:AddIns.HelpViewer.ContentsPadTitle}"
icon = "HtmlHelp2.16x16.Toc"
class = "MSHelpSystem.Controls.Help3TocPad"
defaultPosition = "Right, Hidden" />
@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
<Path name = "/SharpDevelop/Workbench/MainMenu/Help">
<MenuItem id = "Help3DisplayContentCommand"
class = "MSHelpSystem.Commands.DisplayContent"
label = "Display Content"
label = "${res:AddIns.HelpViewer.DisplayContentsCommand}"
shortcut = "Control|Alt|F1"
insertbefore = "Separator1" />
</Path>

10
src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs

@ -27,7 +27,7 @@ namespace MSHelpSystem.Controls @@ -27,7 +27,7 @@ namespace MSHelpSystem.Controls
{
class TocEntry : INotifyPropertyChanged
{
const string url = "ms-xhelp://?method=children&id={3}&format=xml&product={0}&productVersion={1}&locale={2}";
const string url = "ms-xhelp://?method=children&id={1}&format=xml&{0}";
string id;
WebClient client = new WebClient();
@ -57,9 +57,11 @@ namespace MSHelpSystem.Controls @@ -57,9 +57,11 @@ namespace MSHelpSystem.Controls
{
get
{
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (children == null && !client.IsBusy)
client.DownloadStringAsync(new Uri(Help3Environment.GetHttpFromMsXHelp(string.Format(url, catalog.ProductCode, catalog.ProductVersion, catalog.Locale, id))));
if (Help3Service.ActiveCatalog != null) {
if (children == null && !client.IsBusy && HelpLibraryAgent.PortIsReady) {
client.DownloadStringAsync(new Uri(Help3Environment.GetHttpFromMsXHelp(string.Format(url, Help3Service.ActiveCatalog.AsMsXHelpParam, id))));
}
}
return children ?? defaultChild;
}
private set

3
src/AddIns/Misc/HelpViewer/Source/Controls/TocPadControl.xaml.cs

@ -31,8 +31,7 @@ namespace MSHelpSystem.Controls @@ -31,8 +31,7 @@ namespace MSHelpSystem.Controls
void LoadToc()
{
if (!Help3Environment.IsLocalHelp) DataContext = null;
// TODO: Needs a localization
else DataContext = new[] { new TocEntry("-1") { Title = "Help Library" } };
else DataContext = new[] { new TocEntry("-1") { Title = StringParser.Parse("${res:AddIns.HelpViewer.HelpLibraryRootTitle}") } };
}
void Help3TocItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

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

@ -19,18 +19,16 @@ namespace MSHelpSystem.Core @@ -19,18 +19,16 @@ namespace MSHelpSystem.Core
public static void Catalog()
{
if (!Help3Environment.IsLocalHelp) {
MessageBox.Show("You requested an offline feature in the online help mode. You have to change the mode in order to use this feature.",
"Help Viewer",
MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"),
StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"),
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (catalog == null) {
throw new ArgumentNullException("c");
if (Help3Service.ActiveCatalog == null) {
throw new ArgumentNullException("Help3Service.ActiveCatalog");
}
string helpCatalogUrl = string.Format(@"ms-xhelp://?method=page&id=-1&product={0}&productVersion={1}&locale={2}",
catalog.ProductCode, catalog.ProductVersion, catalog.Locale);
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);
}
@ -41,18 +39,16 @@ namespace MSHelpSystem.Core @@ -41,18 +39,16 @@ namespace MSHelpSystem.Core
throw new ArgumentNullException("pageId");
}
if (!Help3Environment.IsLocalHelp) {
MessageBox.Show("You requested an offline feature in the online help mode. You have to change the mode in order to use this feature.",
"Help Viewer",
MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"),
StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"),
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (catalog == null) {
throw new ArgumentNullException("c");
if (Help3Service.ActiveCatalog == null) {
throw new ArgumentNullException("Help3Service.ActiveCatalog");
}
string helpPageUrl = string.Format(@"ms-xhelp://?method=page&id={3}&product={0}&productVersion={1}&locale={2}",
catalog.ProductCode, catalog.ProductVersion, catalog.Locale, pageId);
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);
}
@ -66,12 +62,10 @@ namespace MSHelpSystem.Core @@ -66,12 +62,10 @@ namespace MSHelpSystem.Core
DisplayHelpOnMSDN(contextual);
return;
}
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (catalog == null) {
throw new ArgumentNullException("c");
if (Help3Service.ActiveCatalog == null) {
throw new ArgumentNullException("Help3Service.ActiveCatalog");
}
string helpContextualUrl = string.Format(@"ms-xhelp://?method=f1&query={3}&product={0}&productVersion={1}&locale={2}",
catalog.ProductCode, catalog.ProductVersion, catalog.Locale, contextual);
string helpContextualUrl = string.Format(@"ms-xhelp://?method=f1&query={1}&{0}", Help3Service.ActiveCatalog.AsMsXHelpParam, contextual);
LoggingService.Debug(string.Format("Help 3.0: {0}", helpContextualUrl));
DisplayLocalHelp(helpContextualUrl);
}
@ -85,12 +79,10 @@ namespace MSHelpSystem.Core @@ -85,12 +79,10 @@ namespace MSHelpSystem.Core
DisplaySearchOnMSDN(searchWords);
return;
}
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (catalog == null) {
throw new ArgumentNullException("c");
if (Help3Service.ActiveCatalog == null) {
throw new ArgumentNullException("Help3Service.ActiveCatalog");
}
string helpSearchUrl = string.Format(@"ms-xhelp://?method=search&query={3}&product={0}&productVersion={1}&locale={2}",
catalog.ProductCode, catalog.ProductVersion, catalog.Locale, searchWords.Replace(" ", "+"));
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);
}
@ -101,18 +93,16 @@ namespace MSHelpSystem.Core @@ -101,18 +93,16 @@ namespace MSHelpSystem.Core
throw new ArgumentNullException("keywords");
}
if (!Help3Environment.IsLocalHelp) {
MessageBox.Show("You requested an offline feature in the online help mode. You have to change the mode in order to use this feature.",
"Help Viewer",
MessageBox.Show(StringParser.Parse("${res:AddIns.HelpViewer.OfflineFeatureRequestMsg}"),
StringParser.Parse("${res:AddIns.HelpViewer.MicrosoftHelpViewerTitle}"),
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
Help3Catalog catalog = Help3Service.ActiveCatalog;
if (catalog == null) {
throw new ArgumentNullException("c");
if (Help3Service.ActiveCatalog == null) {
throw new ArgumentNullException("Help3Service.ActiveCatalog");
}
string helpKeywordsUrl = string.Format(@"ms-xhelp://?method=keywords&query={3}&product={0}&productVersion={1}&locale={2}",
catalog.ProductCode, catalog.ProductVersion, catalog.Locale, keywords);
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);
}

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

@ -62,5 +62,15 @@ namespace MSHelpSystem.Core @@ -62,5 +62,15 @@ namespace MSHelpSystem.Core
{
get { return brandingPackage; }
}
public string AsMsXHelpParam
{
get { return string.Format("product={0}&productVersion={1}&locale={2}", productCode, productVersion, productLocale); }
}
public string AsCmdLineParam
{
get { return string.Format("/product {0} /version {1} /locale {2}", productCode, productVersion, productLocale); }
}
}
}

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

@ -94,11 +94,6 @@ namespace MSHelpSystem.Core @@ -94,11 +94,6 @@ namespace MSHelpSystem.Core
#endregion
public static int Count
{
get { return catalogs.Count; }
}
public static ReadOnlyCollection<Help3Catalog> Items
{
get

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

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Sockets;
using Microsoft.Win32;
using ICSharpCode.Core;
@ -50,6 +52,28 @@ namespace MSHelpSystem.Core @@ -50,6 +52,28 @@ namespace MSHelpSystem.Core
}
}
public static bool PortIsReady
{
get
{
try {
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(IPAddress.Parse("127.0.0.1"), PortNumber);
bool isReady = socket.Connected;
socket.Close();
return isReady;
}
catch (SocketException ex) {
if (ex.ErrorCode == 10061) {
LoggingService.Debug("Help 3.0: Port is available but not ready");
return true;
}
LoggingService.Error(string.Format("Help 3.0: {0}", ex.ToString()));
}
return false;
}
}
public static int ProcessId
{
get

5
src/AddIns/Misc/HelpViewer/Source/Core/HelpLibraryManager.cs

@ -181,10 +181,7 @@ namespace MSHelpSystem.Core @@ -181,10 +181,7 @@ namespace MSHelpSystem.Core
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Manager;
psi.WorkingDirectory = Help3Environment.AppRoot;
psi.Arguments = string.Format("/product {0} /version {1} /locale {2}",
Help3Service.ActiveCatalog.ProductCode,
Help3Service.ActiveCatalog.ProductVersion,
Help3Service.ActiveCatalog.Locale);
psi.Arguments = Help3Service.ActiveCatalog.AsCmdLineParam;
psi.UseShellExecute = true;
psi.Verb = "runas";
psi.WindowStyle = ProcessWindowStyle.Normal;

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

@ -1,27 +1,27 @@ @@ -1,27 +1,27 @@
<gui:OptionPanel x:Class="MSHelpSystem.Help3OptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sd="http://icsharpcode.net/sharpdevelop/core"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:addin="clr-namespace:MSHelpSystem;assembly=HelpViewer"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<StackPanel>
<GroupBox Header="Installed Help catalogs" Margin="5" Padding="8" Name="groupBox1">
<GroupBox Header="{core:Localize AddIns.HelpViewer.InstalledHelpCatalogsLabel}" Margin="5" Padding="8" Name="groupBox1">
<ComboBox Name="help3Catalogs"
ItemsSource="{Binding}"
DisplayMemberPath="ShortName"
SelectedValuePath="ShortName"
SelectionChanged="Help3CatalogsSelectionChanged" />
</GroupBox>
<GroupBox Header="Help Mode" Margin="5" Padding="8" Name="groupBox2">
<GroupBox Header="{core:Localize AddIns.HelpViewer.HelpModeLabel}" Margin="5" Padding="8" Name="groupBox2">
<StackPanel>
<RadioButton Name="offlineMode"
IsChecked="True"
Content="I want to use local help"
Content="{core:Localize AddIns.HelpViewer.UseOfflineHelpLabel}"
Click="Help3OfflineModeClicked"
Margin="0,0,0,5"/>
<RadioButton Name="onlineMode"
Content="I want to use online help"
Content="{core:Localize AddIns.HelpViewer.UseOnlineHelpLabel}"
Click="Help3OnlineModeClicked" />
</StackPanel>
</GroupBox>

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

@ -24,10 +24,11 @@ namespace MSHelpSystem @@ -24,10 +24,11 @@ namespace MSHelpSystem
{
HelpLibraryAgent.Start();
DataContext = Help3Service.Items;
// TODO: Needs a localization
groupBox1.Header = string.Format("{0} ({1})", "Installed Help catalogs", Help3Service.Count);
groupBox1.Header = string.Format("{0} ({1})",
StringParser.Parse("${res:AddIns.HelpViewer.InstalledHelpCatalogsLabel}"),
Help3Service.Items.Count);
help3Catalogs.SelectedValue = Help3Service.ActiveCatalog.ShortName;
help3Catalogs.IsEnabled = (Help3Service.Count > 1 && Help3Service.Config.OfflineMode);
help3Catalogs.IsEnabled = (Help3Service.Items.Count > 1 && Help3Service.Config.OfflineMode);
onlineMode.IsChecked = !Help3Service.Config.OfflineMode;
}

Loading…
Cancel
Save