Browse Source

Help 2.0: a few fixes and a first bunch of FxCop suggestions

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1554 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mathias Simmack 19 years ago
parent
commit
9c197e6ed8
  1. 2
      src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs
  2. 2
      src/AddIns/Misc/HtmlHelp2/Project/HtmlHelp2.addin
  3. 2
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs
  4. 1
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/FavoritesPad.cs
  5. 28
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs
  6. 41
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs
  7. 85
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs
  8. 22
      src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/ShowHelpBrowser.cs
  9. 4
      src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs
  10. 20
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs
  11. 196
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs
  12. 29
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Dialog.cs
  13. 12
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs
  14. 186
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs
  15. 4
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs
  16. 72
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs

2
src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs

@ -19,3 +19,5 @@ using System.Runtime.CompilerServices; @@ -19,3 +19,5 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: System.Runtime.InteropServices.ComVisible(false)]

2
src/AddIns/Misc/HtmlHelp2/Project/HtmlHelp2.addin

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "HtmlHelp2Options"
label = "${res:AddIns.HtmlHelp2.Environment}"
class = "HtmlHelp2.OptionsPanel.HtmlHelp2OptionsPanel"/>
class = "HtmlHelp2.Environment.HtmlHelp2OptionsPanel"/>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Help">

2
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs

@ -21,8 +21,6 @@ namespace HtmlHelp2 @@ -21,8 +21,6 @@ namespace HtmlHelp2
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor;
using HtmlHelp2.Environment;
using HtmlHelp2.ResourcesHelperClass;
using HtmlHelp2.SharpDevLanguageClass;
using MSHelpServices;

1
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/FavoritesPad.cs

@ -17,7 +17,6 @@ namespace HtmlHelp2 @@ -17,7 +17,6 @@ namespace HtmlHelp2
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using HtmlHelp2.Environment;
using HtmlHelp2.ResourcesHelperClass;
public class ShowFavoritesMenuCommand : AbstractMenuCommand

28
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs

@ -9,6 +9,7 @@ namespace HtmlHelp2 @@ -9,6 +9,7 @@ namespace HtmlHelp2
{
using System;
using System.Drawing;
using System.Security.Permissions;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
@ -17,7 +18,6 @@ namespace HtmlHelp2 @@ -17,7 +18,6 @@ namespace HtmlHelp2
using MSHelpControls;
using MSHelpServices;
using HtmlHelp2.Environment;
using HtmlHelp2.ControlsValidation;
public class ShowIndexMenuCommand : AbstractMenuCommand
@ -31,7 +31,7 @@ namespace HtmlHelp2 @@ -31,7 +31,7 @@ namespace HtmlHelp2
public class HtmlHelp2IndexPad : AbstractPadContent
{
protected MsHelp2IndexControl help2IndexControl;
MSHelp2IndexControl help2IndexControl;
public override Control Control
{
@ -50,20 +50,20 @@ namespace HtmlHelp2 @@ -50,20 +50,20 @@ namespace HtmlHelp2
public HtmlHelp2IndexPad()
{
help2IndexControl = new MsHelp2IndexControl();
help2IndexControl = new MSHelp2IndexControl();
}
}
public class MsHelp2IndexControl : UserControl
public class MSHelp2IndexControl : UserControl
{
AxHxIndexCtrl indexControl = null;
AxHxIndexCtrl indexControl;
ComboBox filterCombobox = new ComboBox();
ComboBox searchTerm = new ComboBox();
Label label1 = new Label();
Label label2 = new Label();
Label infoLabel = new Label();
bool indexControlFailed = false;
bool itemClicked = false;
bool indexControlFailed;
bool itemClicked;
protected override void Dispose(bool disposing)
{
@ -74,7 +74,8 @@ namespace HtmlHelp2 @@ -74,7 +74,8 @@ namespace HtmlHelp2
}
}
public MsHelp2IndexControl()
[PermissionSet(SecurityAction.LinkDemand, Name="Execution")]
public MSHelp2IndexControl()
{
this.InitializeComponents();
this.UpdateControls();
@ -136,11 +137,6 @@ namespace HtmlHelp2 @@ -136,11 +137,6 @@ namespace HtmlHelp2
LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString());
this.indexControlFailed = true;
}
catch (Exception ex)
{
LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString());
this.indexControlFailed = true;
}
}
Panel panel1 = new Panel();
@ -269,7 +265,7 @@ namespace HtmlHelp2 @@ -269,7 +265,7 @@ namespace HtmlHelp2
HtmlHelp2Environment.GetIndex(HtmlHelp2Environment.FindFilterQuery(filterName));
return true;
}
catch
catch (System.Runtime.InteropServices.COMException)
{
LoggingService.Error("Help 2.0: cannot connect to IHxIndex interface (Index)");
return false;
@ -322,9 +318,9 @@ namespace HtmlHelp2 @@ -322,9 +318,9 @@ namespace HtmlHelp2
break;
}
}
catch (Exception ex)
catch (System.Runtime.InteropServices.COMException cEx)
{
LoggingService.Error("Help 2.0: cannot get matching index entries; " + ex.ToString());
LoggingService.Error("Help 2.0: cannot get matching index entries; " + cEx.ToString());
}
}

41
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs

@ -9,14 +9,13 @@ namespace HtmlHelp2 @@ -9,14 +9,13 @@ namespace HtmlHelp2
{
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using HtmlHelp2.Environment;
using HtmlHelp2.HelperDialog;
using HtmlHelp2.SharpDevLanguageClass;
using MSHelpServices;
@ -46,8 +45,7 @@ namespace HtmlHelp2 @@ -46,8 +45,7 @@ namespace HtmlHelp2
CheckBox useCurrentLang = new CheckBox();
Label label1 = new Label();
Label label2 = new Label();
string selectedQuery = "";
bool searchIsBusy = false;
bool searchIsBusy;
public override Control Control
{
@ -60,6 +58,11 @@ namespace HtmlHelp2 @@ -60,6 +58,11 @@ namespace HtmlHelp2
}
public override void RedrawContent()
{
this.RedrawContentInternal();
}
void RedrawContentInternal()
{
searchButton.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Search}");
titlesOnly.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.SearchInTitlesOnly}");
@ -189,8 +192,7 @@ namespace HtmlHelp2 @@ -189,8 +192,7 @@ namespace HtmlHelp2
label2.TextAlign = ContentAlignment.MiddleLeft;
label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent();
this.RedrawContentInternal();
}
private void FilterChanged(object sender, EventArgs e)
@ -198,7 +200,7 @@ namespace HtmlHelp2 @@ -198,7 +200,7 @@ namespace HtmlHelp2
string selectedFilterName = filterCombobox.SelectedItem.ToString();
if (!string.IsNullOrEmpty(selectedFilterName))
{
selectedQuery = HtmlHelp2Environment.FindFilterQuery(selectedFilterName);
HtmlHelp2Environment.FindFilterQuery(selectedFilterName);
}
}
@ -212,7 +214,6 @@ namespace HtmlHelp2 @@ -212,7 +214,6 @@ namespace HtmlHelp2
{
filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged);
filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(HtmlHelp2Environment.CurrentFilterName);
selectedQuery = HtmlHelp2Environment.CurrentFilterQuery;
filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged);
}
}
@ -235,7 +236,7 @@ namespace HtmlHelp2 @@ -235,7 +236,7 @@ namespace HtmlHelp2
if (!string.IsNullOrEmpty(searchTerm.Text))
{
this.AddTermToList(searchTerm.Text);
this.PerformFTS(searchTerm.Text);
this.PerformFts(searchTerm.Text);
}
}
@ -250,7 +251,7 @@ namespace HtmlHelp2 @@ -250,7 +251,7 @@ namespace HtmlHelp2
{
e.Handled = true;
this.AddTermToList(searchTerm.Text);
this.PerformFTS(searchTerm.Text);
this.PerformFts(searchTerm.Text);
}
}
@ -265,12 +266,12 @@ namespace HtmlHelp2 @@ -265,12 +266,12 @@ namespace HtmlHelp2
}
#region FTS
private void PerformFTS(string searchWord)
private void PerformFts(string searchWord)
{
this.PerformFTS(searchWord, false);
this.PerformFts(searchWord, false);
}
private void PerformFTS(string searchWord, bool useDynamicHelp)
private void PerformFts(string searchWord, bool useDynamicHelp)
{
if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(searchWord) || searchIsBusy)
{
@ -300,7 +301,7 @@ namespace HtmlHelp2 @@ -300,7 +301,7 @@ namespace HtmlHelp2
if (useDynamicHelp)
matchingTopics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchWord);
else
matchingTopics = HtmlHelp2Environment.FTS.Query(searchWord, searchFlags);
matchingTopics = HtmlHelp2Environment.Fts.Query(searchWord, searchFlags);
Cursor.Current = Cursors.Default;
@ -319,7 +320,7 @@ namespace HtmlHelp2 @@ -319,7 +320,7 @@ namespace HtmlHelp2
HxTopicGetTitleDefVal.HxTopicGetTitleFileName);
lvi.Tag = topic;
lvi.SubItems.Add(topic.Location);
lvi.SubItems.Add(topic.Rank.ToString());
lvi.SubItems.Add(topic.Rank.ToString(CultureInfo.CurrentCulture));
searchResults.SearchResultsListView.Items.Add(lvi);
}
@ -334,7 +335,7 @@ namespace HtmlHelp2 @@ -334,7 +335,7 @@ namespace HtmlHelp2
searchIsBusy = false;
}
}
catch (Exception ex)
catch (System.Runtime.InteropServices.COMException ex)
{
LoggingService.Error("Help 2.0: cannot get matching search word; " + ex.ToString());
@ -349,19 +350,19 @@ namespace HtmlHelp2 @@ -349,19 +350,19 @@ namespace HtmlHelp2
}
}
public bool PerformF1FTS(string keyword)
public bool PerformF1Fts(string keyword)
{
return this.PerformF1FTS(keyword, false);
return this.PerformF1Fts(keyword, false);
}
public bool PerformF1FTS(string keyword, bool useDynamicHelp)
public bool PerformF1Fts(string keyword, bool useDynamicHelp)
{
if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(keyword) || searchIsBusy)
{
return false;
}
this.PerformFTS(keyword, useDynamicHelp);
this.PerformFts(keyword, useDynamicHelp);
HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;
return searchResults.SearchResultsListView.Items.Count > 0;

85
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs

@ -9,6 +9,7 @@ namespace HtmlHelp2 @@ -9,6 +9,7 @@ namespace HtmlHelp2
{
using System;
using System.Drawing;
using System.Security.Permissions;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
@ -17,8 +18,6 @@ namespace HtmlHelp2 @@ -17,8 +18,6 @@ namespace HtmlHelp2
using MSHelpControls;
using MSHelpServices;
using HtmlHelp2.Environment;
using HtmlHelp2.ControlsValidation;
using HtmlHelp2.ResourcesHelperClass;
using PrintOptions = MSHelpServices.HxHierarchy_PrintNode_Options;
using TSC = MSHelpControls.HxTreeStyleConstant;
@ -34,7 +33,7 @@ namespace HtmlHelp2 @@ -34,7 +33,7 @@ namespace HtmlHelp2
public class HtmlHelp2TocPad : AbstractPadContent
{
protected MsHelp2TocControl help2TocControl;
MSHelp2TocControl help2TocControl;
public override Control Control
{
@ -53,12 +52,12 @@ namespace HtmlHelp2 @@ -53,12 +52,12 @@ namespace HtmlHelp2
public HtmlHelp2TocPad()
{
help2TocControl = new MsHelp2TocControl();
help2TocControl = new MSHelp2TocControl();
}
public void SyncToc(string topicUrl)
public void SyncToc(string topic)
{
help2TocControl.SynchronizeToc(topicUrl);
help2TocControl.SynchronizeToc(topic);
}
public void GetPrevFromNode()
@ -66,9 +65,9 @@ namespace HtmlHelp2 @@ -66,9 +65,9 @@ namespace HtmlHelp2
help2TocControl.GetPrevFromNode();
}
public void GetPrevFromUrl(string topicUrl)
public void GetPrevFromUrl(string topic)
{
help2TocControl.GetPrevFromUrl(topicUrl);
help2TocControl.GetPrevFromUrl(topic);
}
public void GetNextFromNode()
@ -76,9 +75,9 @@ namespace HtmlHelp2 @@ -76,9 +75,9 @@ namespace HtmlHelp2
help2TocControl.GetNextFromNode();
}
public void GetNextFromUrl(string topicUrl)
public void GetNextFromUrl(string topic)
{
help2TocControl.GetNextFromUrl(topicUrl);
help2TocControl.GetNextFromUrl(topic);
}
public bool IsNotFirstNode
@ -92,16 +91,16 @@ namespace HtmlHelp2 @@ -92,16 +91,16 @@ namespace HtmlHelp2
}
}
public class MsHelp2TocControl : UserControl
public class MSHelp2TocControl : UserControl
{
AxHxTocCtrl tocControl = null;
AxHxTocCtrl tocControl;
ComboBox filterCombobox = new ComboBox();
Label label1 = new Label();
Label infoLabel = new Label();
ContextMenuStrip printContextMenu = new ContextMenuStrip();
ToolStripMenuItem printTopic = new ToolStripMenuItem();
ToolStripMenuItem printTopicAndSubTopics = new ToolStripMenuItem();
bool tocControlFailed = false;
bool tocControlFailed;
protected override void Dispose(bool disposing)
{
@ -112,7 +111,8 @@ namespace HtmlHelp2 @@ -112,7 +111,8 @@ namespace HtmlHelp2
}
}
public MsHelp2TocControl()
[PermissionSet(SecurityAction.LinkDemand, Name="Execution")]
public MSHelp2TocControl()
{
this.InitializeComponents();
this.UpdateControl();
@ -188,11 +188,6 @@ namespace HtmlHelp2 @@ -188,11 +188,6 @@ namespace HtmlHelp2
LoggingService.Error("Help 2.0: TOC control failed: " + cEx.ToString());
this.tocControlFailed = true;
}
catch(Exception ex)
{
LoggingService.Error("Help 2.0: TOC control failed; " + ex.ToString());
this.tocControlFailed = true;
}
}
Panel panel1 = new Panel();
@ -239,10 +234,10 @@ namespace HtmlHelp2 @@ -239,10 +234,10 @@ namespace HtmlHelp2
{
if (e.hNode != 0)
{
printTopic.Enabled = tocControl.Hierarchy.GetURL(e.hNode) != "";
printTopic.Enabled = !string.IsNullOrEmpty(tocControl.Hierarchy.GetURL(e.hNode));
printTopicAndSubTopics.Enabled = tocControl.Hierarchy.GetFirstChild(e.hNode) != 0;
bool selectTextFlag = (tocControl.Hierarchy.GetFirstChild(e.hNode) == 0 ||
tocControl.Hierarchy.GetURL(e.hNode) == "");
string.IsNullOrEmpty(tocControl.Hierarchy.GetURL(e.hNode)));
printTopicAndSubTopics.Text =
StringParser.Parse((selectTextFlag)?
"${res:AddIns.HtmlHelp2.PrintSubtopics}":
@ -301,24 +296,24 @@ namespace HtmlHelp2 @@ -301,24 +296,24 @@ namespace HtmlHelp2
HtmlHelp2Environment.GetTocHierarchy(HtmlHelp2Environment.FindFilterQuery(filterName));
return true;
}
catch
catch (System.Runtime.InteropServices.COMException)
{
LoggingService.Error("Help 2.0: Cannot connect to the IHxHierarchy interface.");
return false;
}
}
private void CallHelp(string topicUrl)
private void CallHelp(string topic)
{
this.CallHelp(topicUrl, true);
this.CallHelp(topic, true);
}
private void CallHelp(string topicUrl, bool syncToc)
private void CallHelp(string topic, bool syncToc)
{
if (!string.IsNullOrEmpty(topicUrl))
if (!string.IsNullOrEmpty(topic))
{
if (syncToc) this.SynchronizeToc(topicUrl);
ShowHelpBrowser.OpenHelpView(topicUrl);
if (syncToc) this.SynchronizeToc(topic);
ShowHelpBrowser.OpenHelpView(topic);
}
}
@ -348,11 +343,11 @@ namespace HtmlHelp2 @@ -348,11 +343,11 @@ namespace HtmlHelp2
#endregion
#region Published Help 2.0 Commands
public void SynchronizeToc(string topicUrl)
public void SynchronizeToc(string topic)
{
try
{
tocControl.Synchronize(topicUrl);
tocControl.Synchronize(topic);
}
catch (System.Runtime.InteropServices.COMException)
{
@ -371,17 +366,14 @@ namespace HtmlHelp2 @@ -371,17 +366,14 @@ namespace HtmlHelp2
catch (System.Runtime.InteropServices.COMException)
{
}
catch
{
}
}
public void GetNextFromUrl(string url)
public void GetNextFromUrl(string topic)
{
if (url == null || url.Length == 0) return;
if (topic == null || topic.Length == 0) return;
try
{
int currentNode = tocControl.Hierarchy.GetNextFromUrl(url);
int currentNode = tocControl.Hierarchy.GetNextFromUrl(topic);
string topicUrl = tocControl.Hierarchy.GetURL(currentNode);
this.CallHelp(topicUrl, true);
}
@ -405,17 +397,14 @@ namespace HtmlHelp2 @@ -405,17 +397,14 @@ namespace HtmlHelp2
catch (System.Runtime.InteropServices.COMException)
{
}
catch
{
}
}
public void GetPrevFromUrl(string url)
public void GetPrevFromUrl(string topic)
{
if (url == null || url.Length == 0) return;
if (topic == null || topic.Length == 0) return;
try
{
int currentNode = tocControl.Hierarchy.GetPrevFromUrl(url);
int currentNode = tocControl.Hierarchy.GetPrevFromUrl(topic);
string topicUrl = tocControl.Hierarchy.GetURL(currentNode);
this.CallHelp(topicUrl, true);
}
@ -434,10 +423,10 @@ namespace HtmlHelp2 @@ -434,10 +423,10 @@ namespace HtmlHelp2
{
try
{
int currentNode = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection);
return (currentNode != 0);
int node = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection);
return node != 0;
}
catch
catch (System.Runtime.InteropServices.COMException)
{
return true;
}
@ -450,10 +439,10 @@ namespace HtmlHelp2 @@ -450,10 +439,10 @@ namespace HtmlHelp2
{
try
{
int currentNode = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection);
return (currentNode != 0);
int node = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection);
return (node != 0);
}
catch
catch (System.Runtime.InteropServices.COMException)
{
return true;
}

22
src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/ShowHelpBrowser.cs

@ -10,22 +10,31 @@ namespace HtmlHelp2 @@ -10,22 +10,31 @@ namespace HtmlHelp2
// With a big "Thank you" to Robert_G (Delphi-PRAXiS)
using System;
using System.Security.Permissions;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.BrowserDisplayBinding;
using MSHelpServices;
public static class ShowHelpBrowser
{
static bool hiliteMatches = false;
static IHxTopic lastTopic = null;
static bool hiliteMatches;
static IHxTopic lastTopic;
public static void OpenHelpView(IHxTopic topic)
{
if (topic == null)
{
throw new ArgumentNullException("topic");
}
OpenHelpView(topic.URL, null, false);
}
public static void OpenHelpView(IHxTopic topic, bool hiliteMatchingWords)
{
if (topic == null)
{
throw new ArgumentNullException("topic");
}
OpenHelpView(topic.URL, topic, hiliteMatchingWords);
}
@ -43,7 +52,7 @@ namespace HtmlHelp2 @@ -43,7 +52,7 @@ namespace HtmlHelp2
{
hiliteMatches = hiliteMatchingWords;
lastTopic = topic;
BrowserPane help2Browser = GetActiveHelp2BrowserView();
BrowserPane help2Browser = ActiveHelp2BrowserView();
if (help2Browser != null)
{
@ -52,7 +61,7 @@ namespace HtmlHelp2 @@ -52,7 +61,7 @@ namespace HtmlHelp2
}
}
public static BrowserPane GetActiveHelp2BrowserView()
public static BrowserPane ActiveHelp2BrowserView()
{
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null)
@ -78,8 +87,13 @@ namespace HtmlHelp2 @@ -78,8 +87,13 @@ namespace HtmlHelp2
return tempPane;
}
[PermissionSet(SecurityAction.LinkDemand, Name="Execution")]
public static void HighlightDocument(HtmlViewPane htmlViewPane)
{
if (htmlViewPane == null)
{
throw new ArgumentNullException("htmlViewPane");
}
if (hiliteMatches && lastTopic != null)
{
lastTopic.HighlightDocument(htmlViewPane.WebBrowser.Document.DomDocument);

4
src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs

@ -22,7 +22,7 @@ namespace HtmlHelp2 @@ -22,7 +22,7 @@ namespace HtmlHelp2
try
{
PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad));
return ((HtmlHelp2SearchPad)search.PadContent).PerformF1FTS(fullTypeName, true);
return ((HtmlHelp2SearchPad)search.PadContent).PerformF1Fts(fullTypeName, true);
}
catch
{
@ -37,7 +37,7 @@ namespace HtmlHelp2 @@ -37,7 +37,7 @@ namespace HtmlHelp2
try
{
PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad));
return ((HtmlHelp2SearchPad)search.PadContent).PerformF1FTS(keyword);
return ((HtmlHelp2SearchPad)search.PadContent).PerformF1Fts(keyword);
}
catch
{

20
src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.ControlsValidation
namespace HtmlHelp2.Environment
{
using System;
using System.IO;
@ -13,6 +13,10 @@ namespace HtmlHelp2.ControlsValidation @@ -13,6 +13,10 @@ namespace HtmlHelp2.ControlsValidation
public sealed class Help2ControlsValidation
{
Help2ControlsValidation()
{
}
public static bool IsTocControlRegistered
{
get
@ -33,16 +37,16 @@ namespace HtmlHelp2.ControlsValidation @@ -33,16 +37,16 @@ namespace HtmlHelp2.ControlsValidation
{
try
{
using (RegistryKey tempRegKey = Registry.ClassesRoot.OpenSubKey(String.Format("CLSID\\{0}\\InprocServer32", classId)))
{
string help2Dll = (string)tempRegKey.GetValue("");
return (help2Dll != null && help2Dll != "" && File.Exists(help2Dll));
}
RegistryKey tmp = Registry.ClassesRoot.OpenSubKey
(string.Format(null, @"CLSID\{0}\InprocServer32", classId), false);
string help2Library = (string)tmp.GetValue("", string.Empty);
tmp.Close();
return (!string.IsNullOrEmpty(help2Library) && File.Exists(help2Library));
}
catch
catch (System.NullReferenceException)
{
return false;
}
return false;
}
}
}

196
src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.RegistryWalker
namespace HtmlHelp2.Environment
{
using System;
using System.Runtime.InteropServices;
@ -15,29 +15,48 @@ namespace HtmlHelp2.RegistryWalker @@ -15,29 +15,48 @@ namespace HtmlHelp2.RegistryWalker
public sealed class Help2RegistryWalker
{
Help2RegistryWalker()
{
}
public static bool BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection)
{
if (help2Collections == null)
{
throw new ArgumentNullException("help2Collections");
}
HxRegistryWalkerClass registryWalker;
IHxRegNamespaceList help2Namespaces;
try
{
registryWalker = new HxRegistryWalkerClass();
help2Namespaces = registryWalker.get_RegisteredNamespaceList("");
}
catch (System.Runtime.InteropServices.COMException)
{
help2Namespaces = null;
registryWalker = null;
}
if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0)
{
return false;
}
help2Collections.Items.Clear();
help2Collections.BeginUpdate();
bool result = true;
try
{
string currentDescription = string.Empty;
HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in namespaces)
foreach (IHxRegNamespace currentNamespace in help2Namespaces)
{
help2Collections.Items.Add
((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription));
if (!string.IsNullOrEmpty(selectedHelp2Collection) &&
string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
{
currentDescription =
(string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
@ -49,93 +68,158 @@ namespace HtmlHelp2.RegistryWalker @@ -49,93 +68,158 @@ namespace HtmlHelp2.RegistryWalker
else
help2Collections.SelectedIndex = 0;
}
catch
{
result = false;
}
finally
{
help2Collections.EndUpdate();
}
return result;
return true;
// if (help2Collections == null)
// {
// return false;
// }
// help2Collections.Items.Clear();
// help2Collections.BeginUpdate();
// bool result = true;
//
// try
// {
// string currentDescription = string.Empty;
// HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
// IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
//
// foreach (IHxRegNamespace currentNamespace in namespaces)
// {
// help2Collections.Items.Add
// ((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription));
//
// if (!string.IsNullOrEmpty(selectedHelp2Collection) &&
// string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
// {
// currentDescription =
// (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
// }
// }
//
// if (!string.IsNullOrEmpty(currentDescription))
// help2Collections.SelectedIndex = help2Collections.Items.IndexOf(currentDescription);
// else
// help2Collections.SelectedIndex = 0;
// }
// catch
// {
// result = false;
// }
// finally
// {
// help2Collections.EndUpdate();
// }
//
// return result;
}
public static string GetNamespaceName(string description)
{
HxRegistryWalkerClass registryWalker;
IHxRegNamespaceList help2Namespaces;
try
{
HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
registryWalker = new HxRegistryWalkerClass();
help2Namespaces = registryWalker.get_RegisteredNamespaceList("");
}
catch (System.Runtime.InteropServices.COMException)
{
help2Namespaces = null;
registryWalker = null;
}
foreach (IHxRegNamespace currentNamespace in namespaces)
{
string currentDescription =
(string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
if (string.Compare(currentDescription, description) == 0)
{
return currentNamespace.Name;
}
}
if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0)
{
return string.Empty;
}
catch
foreach (IHxRegNamespace currentNamespace in help2Namespaces)
{
LoggingService.Error("Help 2.0: cannot find selected namespace name");
string currentDescription =
(string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
if (string.Compare(currentDescription, description) == 0)
{
return currentNamespace.Name;
}
}
return string.Empty;
}
public static string GetFirstNamespace(string name)
{
HxRegistryWalkerClass registryWalker;
IHxRegNamespaceList help2Namespaces;
try
{
HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in namespaces)
{
if (string.Compare(currentNamespace.Name, name) == 0)
{
return name;
}
}
return namespaces.ItemAt(1).Name;
registryWalker = new HxRegistryWalkerClass();
help2Namespaces = registryWalker.get_RegisteredNamespaceList("");
}
catch (System.Runtime.InteropServices.COMException)
{
help2Namespaces = null;
registryWalker = null;
}
catch
if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0)
{
return string.Empty;
}
foreach (IHxRegNamespace currentNamespace in help2Namespaces)
{
if (string.Compare(currentNamespace.Name, name) == 0)
{
return name;
}
}
return help2Namespaces.ItemAt(1).Name;
}
public static string GetFirstMatchingNamespaceName(string matchingName)
{
if (!string.IsNullOrEmpty(matchingName))
HxRegistryWalkerClass registryWalker;
IHxRegNamespaceList help2Namespaces;
try
{
try
{
HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
registryWalker = new HxRegistryWalkerClass();
help2Namespaces = registryWalker.get_RegisteredNamespaceList("");
}
catch (System.Runtime.InteropServices.COMException)
{
help2Namespaces = null;
registryWalker = null;
}
foreach (IHxRegNamespace currentNamespace in namespaces)
{
if (PathMatchSpec(currentNamespace.Name, matchingName))
{
return currentNamespace.Name;
}
}
}
catch
if (registryWalker == null ||
help2Namespaces == null || help2Namespaces.Count == 0 ||
string.IsNullOrEmpty(matchingName))
{
return string.Empty;
}
foreach (IHxRegNamespace currentNamespace in help2Namespaces)
{
if (NativeMethods.PathMatchSpec(currentNamespace.Name, matchingName))
{
// I don't care about an exception here ;-)
return currentNamespace.Name;
}
}
return string.Empty;
}
#region PatchMatchSpec@Win32API
}
internal class NativeMethods
{
NativeMethods()
{
}
#region PatchMatchSpec
[DllImport("shlwapi.dll")]
static extern bool PathMatchSpec(string pwszFile, string pwszSpec);
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool PathMatchSpec(string pwszFile, string pwszSpec);
#endregion
}
}

29
src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Dialog.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.HelperDialog
namespace HtmlHelp2.Environment
{
using System;
using System.Drawing;
@ -13,7 +13,7 @@ namespace HtmlHelp2.HelperDialog @@ -13,7 +13,7 @@ namespace HtmlHelp2.HelperDialog
public class IconPictureBox : PictureBox
{
private Icon icon = null;
private Icon icon;
public Icon Icon
{
@ -23,8 +23,15 @@ namespace HtmlHelp2.HelperDialog @@ -23,8 +23,15 @@ namespace HtmlHelp2.HelperDialog
}
set
{
this.icon = value;
base.Image = this.icon.ToBitmap();
if (value == null)
{
throw new ArgumentNullException("value");
}
else
{
this.icon = value;
base.Image = this.icon.ToBitmap();
}
}
}
@ -48,7 +55,17 @@ namespace HtmlHelp2.HelperDialog @@ -48,7 +55,17 @@ namespace HtmlHelp2.HelperDialog
public Icon ActionIcon
{
get { return pictureBox1.Icon; }
set { pictureBox1.Icon = value; }
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
else
{
pictureBox1.Icon = value;
}
}
}
public HtmlHelp2Dialog()
@ -98,7 +115,7 @@ namespace HtmlHelp2.HelperDialog @@ -98,7 +115,7 @@ namespace HtmlHelp2.HelperDialog
this.ControlBox = false;
this.Name = "HtmlHelp2Dialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "HtmlHelp2Dialog";
// this.Text = "HtmlHelp2Dialog";
this.ResumeLayout(false);
}
#endregion

12
src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.OptionsPanel
namespace HtmlHelp2.Environment
{
using System;
using System.Drawing;
@ -17,13 +17,11 @@ namespace HtmlHelp2.OptionsPanel @@ -17,13 +17,11 @@ namespace HtmlHelp2.OptionsPanel
using System.Xml.Serialization;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using HtmlHelp2.Environment;
using HtmlHelp2.RegistryWalker;
public class HtmlHelp2OptionsPanel : AbstractOptionPanel
{
ComboBox help2Collections = null;
CheckBox tocPictures = null;
ComboBox help2Collections;
CheckBox tocPictures;
string selectedHelp2Collection = string.Empty;
public override void LoadPanelContents()
@ -78,8 +76,8 @@ namespace HtmlHelp2.OptionsPanel @@ -78,8 +76,8 @@ namespace HtmlHelp2.OptionsPanel
public class HtmlHelp2Options
{
private string selectedCollection = string.Empty;
private bool tocPictures = true;
private bool dynamicHelpDebugInfo = false;
private bool tocPictures;
private bool dynamicHelpDebugInfo;
[XmlElement("collection")]
public string SelectedCollection

186
src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs

@ -14,34 +14,34 @@ namespace HtmlHelp2.Environment @@ -14,34 +14,34 @@ namespace HtmlHelp2.Environment
using System.Xml.Serialization;
using ICSharpCode.Core;
using MSHelpServices;
using HtmlHelp2.RegistryWalker;
using HtmlHelp2.HelperDialog;
using HtmlHelp2.OptionsPanel;
public sealed class HtmlHelp2Environment
{
static Guid TocGuid = new Guid("314111B2-A502-11D2-BBCA-00C04F8EC294");
static Guid IndexGuid = new Guid("314111CC-A502-11D2-BBCA-00C04F8EC294");
static Guid QueryGuid = new Guid("31411193-A502-11D2-BBCA-00C04F8EC294");
static HxSession session = null;
static IHxRegFilterList namespaceFilters = null;
static IHxQuery fulltextSearch = null;
static IHxIndex dynamicHelp = null;
public static string DefaultNamespaceName = "MS.NETFramework.v20*";
static HxSession session;
static IHxRegFilterList namespaceFilters;
static IHxQuery fulltextSearch;
static IHxIndex dynamicHelp;
static string defaultNamespaceName =
Help2RegistryWalker.GetFirstMatchingNamespaceName("MS.NETFramework.v20*");
static string currentSelectedFilterQuery = "";
static string currentSelectedFilterName = "";
static string defaultPage = "about:blank";
static string searchPage = "http://msdn.microsoft.com";
static bool dynamicHelpIsBusy = false;
static bool dynamicHelpIsBusy;
static HtmlHelp2Options config = new HtmlHelp2Options();
HtmlHelp2Environment()
{
}
static HtmlHelp2Environment()
{
LoadHelp2Config();
DefaultNamespaceName = Help2RegistryWalker.GetFirstMatchingNamespaceName(DefaultNamespaceName);
InitializeNamespace(DefaultNamespaceName);
InitializeNamespace(defaultNamespaceName);
}
#region Properties
@ -50,6 +50,11 @@ namespace HtmlHelp2.Environment @@ -50,6 +50,11 @@ namespace HtmlHelp2.Environment
get { return session != null; }
}
public static string DefaultNamespaceName
{
get { return defaultNamespaceName; }
}
public static string CurrentFilterQuery
{
get { return currentSelectedFilterQuery; }
@ -70,7 +75,7 @@ namespace HtmlHelp2.Environment @@ -70,7 +75,7 @@ namespace HtmlHelp2.Environment
get { return searchPage; }
}
public static IHxQuery FTS
public static IHxQuery Fts
{
get { return fulltextSearch; }
}
@ -92,15 +97,15 @@ namespace HtmlHelp2.Environment @@ -92,15 +97,15 @@ namespace HtmlHelp2.Environment
LoadConfiguration();
if (!string.IsNullOrEmpty(config.SelectedCollection))
{
DefaultNamespaceName = config.SelectedCollection;
defaultNamespaceName = config.SelectedCollection;
}
}
public static void ReloadNamespace()
{
LoadHelp2Config();
DefaultNamespaceName = Help2RegistryWalker.GetFirstNamespace(DefaultNamespaceName);
InitializeNamespace(DefaultNamespaceName);
defaultNamespaceName = Help2RegistryWalker.GetFirstNamespace(defaultNamespaceName);
InitializeNamespace(defaultNamespaceName);
OnNamespaceReloaded(EventArgs.Empty);
}
@ -125,18 +130,18 @@ namespace HtmlHelp2.Environment @@ -125,18 +130,18 @@ namespace HtmlHelp2.Environment
currentSelectedFilterName = string.Empty;
session = new HxSession();
session.Initialize(String.Format("ms-help://{0}", namespaceName), 0);
session.Initialize(String.Format(null, "ms-help://{0}", namespaceName), 0);
namespaceFilters = session.GetFilterList();
ReloadDefaultPages();
ReloadFTSSystem();
ReloadDynamicHelpSystem();
LoggingService.Info("Help 2.0: service sucessfully loaded");
LoggingService.Info("Help 2.0: Service sucessfully loaded");
}
catch(Exception ex)
catch (System.Runtime.InteropServices.COMException cEx)
{
LoggingService.Error("Help 2.0: not initialize service; " + ex.ToString());
LoggingService.Error("Help 2.0: Cannot not initialize service; " + cEx.ToString());
session = null;
}
finally
@ -147,46 +152,66 @@ namespace HtmlHelp2.Environment @@ -147,46 +152,66 @@ namespace HtmlHelp2.Environment
private static void ReloadFTSSystem()
{
fulltextSearch = (IHxQuery)session.GetNavigationInterface
("!DefaultFullTextSearch", currentSelectedFilterQuery, ref QueryGuid);
try
{
fulltextSearch = (IHxQuery)session.GetNavigationInterface
("!DefaultFullTextSearch", currentSelectedFilterQuery, ref QueryGuid);
}
catch (System.Runtime.InteropServices.COMException)
{
fulltextSearch = null;
}
}
private static void ReloadDynamicHelpSystem()
{
dynamicHelp = (IHxIndex)session.GetNavigationInterface
("!DefaultContextWindowIndex", currentSelectedFilterQuery, ref IndexGuid);
try
{
dynamicHelp = (IHxIndex)session.GetNavigationInterface
("!DefaultContextWindowIndex", currentSelectedFilterQuery, ref IndexGuid);
}
catch (System.Runtime.InteropServices.COMException)
{
dynamicHelp = null;
}
}
private static void ReloadDefaultPages()
{
defaultPage = GetDefaultPage("HomePage", "DefaultPage", "about:blank");
defaultPage = GetDefaultPage("HomePage", "DefaultPage");
searchPage = GetDefaultPage("SearchHelpPage", "SearchWebPage", "http://msdn.microsoft.com");
}
private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue)
private static string GetDefaultPage(string pageName, string alternatePageName)
{
string result = string.Empty;
return GetDefaultPage(pageName, alternatePageName, "about:blank");
}
private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue)
{
if (string.IsNullOrEmpty(pageName) && string.IsNullOrEmpty(alternatePageName))
{
throw new ArgumentNullException("pageName & alternatePageName");
}
try
{
string result = string.Empty;
IHxIndex namedUrlIndex =
(IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex", "", ref IndexGuid);
IHxTopicList topics = namedUrlIndex.GetTopicsFromString(pageName, 0);
if (topics.Count == 0 && !string.IsNullOrEmpty(alternatePageName))
{
topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0);
}
if (topics.Count > 0)
result = topics.ItemAt(1).URL;
if (string.IsNullOrEmpty(result))
result = defaultValue;
if (topics.Count > 0) result = topics.ItemAt(1).URL;
if (string.IsNullOrEmpty(result)) result = defaultValue;
return result;
}
catch
catch (System.Runtime.InteropServices.COMException)
{
return defaultValue;
}
@ -210,12 +235,19 @@ namespace HtmlHelp2.Environment @@ -210,12 +235,19 @@ namespace HtmlHelp2.Environment
{
if (filterCombobox == null)
{
return;
throw new ArgumentNullException("filterCombobox");
}
filterCombobox.Items.Clear();
filterCombobox.BeginUpdate();
try
if (namespaceFilters == null || namespaceFilters.Count == 0)
{
filterCombobox.Items.Add
(StringParser.Parse("${res:AddIns.HtmlHelp2.DefaultEmptyFilter}"));
filterCombobox.SelectedIndex = 0;
}
else
{
foreach (IHxRegFilter filter in namespaceFilters)
{
@ -229,22 +261,11 @@ namespace HtmlHelp2.Environment @@ -229,22 +261,11 @@ namespace HtmlHelp2.Environment
}
}
if (namespaceFilters.Count == 0)
{
filterCombobox.Items.Add
(StringParser.Parse("${res:AddIns.HtmlHelp2.DefaultEmptyFilter}"));
}
if (string.IsNullOrEmpty(currentSelectedFilterName))
filterCombobox.SelectedIndex = 0;
else
filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(currentSelectedFilterName);
}
catch(Exception ex)
{
LoggingService.Error("Help 2.0: Cannot build filters; " + ex.Message);
}
filterCombobox.EndUpdate();
}
@ -254,41 +275,53 @@ namespace HtmlHelp2.Environment @@ -254,41 +275,53 @@ namespace HtmlHelp2.Environment
{
return currentSelectedFilterQuery;
}
if (namespaceFilters == null || namespaceFilters.Count == 0)
{
return string.Empty;
}
try
IHxRegFilter filter = namespaceFilters.FindFilter(filterName);
if (filter == null)
{
IHxRegFilter filter = namespaceFilters.FindFilter(filterName);
currentSelectedFilterName = filterName;
currentSelectedFilterQuery =
(string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery);
return string.Empty;
}
currentSelectedFilterName = filterName;
currentSelectedFilterQuery =
(string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery);
OnFilterQueryChanged(EventArgs.Empty);
OnFilterQueryChanged(EventArgs.Empty);
try
{
ReloadFTSSystem();
ReloadDynamicHelpSystem();
ReloadDefaultPages();
return currentSelectedFilterQuery;
}
catch
catch (System.Runtime.InteropServices.COMException cEx)
{
return string.Empty;
LoggingService.Error("Help 2.0: Cannot not initialize service; " + cEx.ToString());
}
return currentSelectedFilterQuery;
}
public static IHxTopicList GetMatchingTopicsForDynamicHelp(string searchTerm)
{
if(dynamicHelpIsBusy) return null;
IHxTopicList topics = null;
if (dynamicHelpIsBusy || dynamicHelp == null || string.IsNullOrEmpty(searchTerm))
{
return null;
}
IHxTopicList topics;
try
{
dynamicHelpIsBusy = true;
topics = dynamicHelp.GetTopicsFromString(searchTerm, 0);
LoggingService.Info("Help 2.0: Dynamic Help called");
}
catch
catch (System.Runtime.InteropServices.COMException)
{
LoggingService.Error("Help 2.0: Dynamic Help search failed");
topics = null;
}
finally
{
@ -322,46 +355,41 @@ namespace HtmlHelp2.Environment @@ -322,46 +355,41 @@ namespace HtmlHelp2.Environment
#region Configuration
public static void LoadConfiguration()
{
string configFile = Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
if (!File.Exists(configFile))
{
return;
}
try
{
string configFile =
Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
if(!File.Exists(configFile))
{
return;
}
XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options));
StreamReader file = new StreamReader(configFile);
TextReader file = new StreamReader(configFile);
config = (HtmlHelp2Options)serialize.Deserialize(file);
file.Close();
LoggingService.Info("Help 2.0: Configuration successfully loaded.");
LoggingService.Info("Help 2.0: Configuration successfully loaded");
}
catch
catch (InvalidOperationException)
{
LoggingService.Error("Help 2.0: Error while trying to load configuration.");
LoggingService.Error("Help 2.0: Error while trying to load configuration");
}
}
public static void SaveConfiguration()
{
string configFile = Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
try
{
string configFile =
Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options));
StreamWriter file = new StreamWriter(configFile);
TextWriter file = new StreamWriter(configFile);
serialize.Serialize(file, config);
file.Close();
LoggingService.Info("Help 2.0: Configuration successfully saved.");
LoggingService.Info("Help 2.0: Configuration successfully saved");
}
catch
catch (InvalidOperationException)
{
LoggingService.Error("Help 2.0: Error while trying to save configuration.");
LoggingService.Error("Help 2.0: Error while trying to save configuration");
}
}
#endregion

4
src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.ResourcesHelperClass
namespace HtmlHelp2.Environment
{
using System;
using System.Drawing;
@ -19,7 +19,7 @@ namespace HtmlHelp2.ResourcesHelperClass @@ -19,7 +19,7 @@ namespace HtmlHelp2.ResourcesHelperClass
public static Bitmap GetBitmap(string resourceName)
{
Assembly assembly = typeof(ResourcesHelper).Assembly;
string fullName = string.Format("HtmlHelp2.Resources.{0}", resourceName);
string fullName = string.Format(null, "HtmlHelp2.Resources.{0}", resourceName);
return new Bitmap(assembly.GetManifestResourceStream(fullName));
}

72
src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
// <version>$Revision$</version>
// </file>
namespace HtmlHelp2.SharpDevLanguageClass
namespace HtmlHelp2.Environment
{
using System;
using System.Collections.Generic;
@ -15,48 +15,67 @@ namespace HtmlHelp2.SharpDevLanguageClass @@ -15,48 +15,67 @@ namespace HtmlHelp2.SharpDevLanguageClass
public sealed class SharpDevLanguage
{
private static Dictionary<string, string>languages = new Dictionary<string, string>();
static Dictionary<string, string> languages = InitializeLanguages();
static SharpDevLanguage()
static Dictionary<string, string> InitializeLanguages()
{
Dictionary<string, string> result = new Dictionary<string, string>();
result.Add("C#", "CSharp");
result.Add("VBNet", "VB");
return result;
}
SharpDevLanguage()
{
languages.Add("C#", "CSharp");
languages.Add("VBNet", "VB");
}
private static int DevLangCounter(IHxTopic topic)
{
try
if (topic == null)
{
int counter = 0;
IHxAttributeList topicAttributes = topic.Attributes;
foreach (IHxAttribute attr in topicAttributes)
{
if (String.Compare(attr.DisplayName, "DevLang") == 0)
{
counter++;
}
}
return counter;
return 0;
}
catch
int counter = 0;
IHxAttributeList topicAttributes = topic.Attributes;
if (topicAttributes == null || topicAttributes.Count == 0)
{
return 0;
}
foreach (IHxAttribute attr in topicAttributes)
{
if (String.Compare(attr.DisplayName, "DevLang") == 0)
{
counter++;
}
}
return counter;
}
public static bool CheckTopicLanguage(IHxTopic topic)
{
if (ProjectService.CurrentProject != null) {
if (ProjectService.CurrentProject != null)
{
return CheckTopicLanguage(topic, ProjectService.CurrentProject.Language);
} else {
}
else
{
return true;
}
}
public static bool CheckTopicLanguage(IHxTopic topic, string expectedLanguage)
{
if (string.IsNullOrEmpty(expectedLanguage)) { return true; }
if (topic == null) { return false; }
if (string.IsNullOrEmpty(expectedLanguage))
{
return true;
}
if (topic == null)
{
return false;
}
string tempLanguage = String.Empty;
if (!languages.ContainsKey(expectedLanguage) ||
@ -65,12 +84,19 @@ namespace HtmlHelp2.SharpDevLanguageClass @@ -65,12 +84,19 @@ namespace HtmlHelp2.SharpDevLanguageClass
tempLanguage = expectedLanguage;
}
return (tempLanguage == String.Empty || topic.HasAttribute("DevLang", tempLanguage));
return (string.IsNullOrEmpty(tempLanguage) || topic.HasAttribute("DevLang", tempLanguage));
}
public static bool CheckUniqueTopicLanguage(IHxTopic topic)
{
return CheckUniqueTopicLanguage(topic, ProjectService.CurrentProject.Language);
if (ProjectService.CurrentProject != null)
{
return CheckUniqueTopicLanguage(topic, ProjectService.CurrentProject.Language);
}
else
{
return CheckUniqueTopicLanguage(topic, string.Empty);
}
}
public static bool CheckUniqueTopicLanguage(IHxTopic topic, string expectedLanguage)

Loading…
Cancel
Save