Browse Source

Help 2.0: a lot of changes in the code

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1521 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mathias Simmack 19 years ago
parent
commit
e1c75232e5
  1. 2
      src/AddIns/Misc/HtmlHelp2/Project/HtmlHelp2.csproj
  2. 21
      src/AddIns/Misc/HtmlHelp2/Project/Resources/HtmlHelp2Options.xfrm
  3. 4
      src/AddIns/Misc/HtmlHelp2/Project/Resources/context.html
  4. 232
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs
  5. 16
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs
  6. 1
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexResultsPad.cs
  7. 26
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs
  8. 1
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs
  9. 4
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs
  10. 8
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs
  11. 81
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs
  12. 35
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs
  13. 133
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs
  14. 2
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs
  15. 4
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs

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

@ -88,7 +88,7 @@
<None Include="Resources\Favorites.16x16.Rename.bmp" /> <None Include="Resources\Favorites.16x16.Rename.bmp" />
<EmbeddedResource Include="Resources\HtmlHelp2Options.xfrm" /> <EmbeddedResource Include="Resources\HtmlHelp2Options.xfrm" />
<EmbeddedResource Include="Resources\HtmlHelp2.16x16.TextZoom.png" /> <EmbeddedResource Include="Resources\HtmlHelp2.16x16.TextZoom.png" />
<EmbeddedResource Include="Resources\HtmlHelp2.16x16.AddToFavorites.png" /> <None Include="Resources\HtmlHelp2.16x16.AddToFavorites.png" />
<Compile Include="src\BrowserControl\HelpBrowserCommands.cs" /> <Compile Include="src\BrowserControl\HelpBrowserCommands.cs" />
<Compile Include="src\BrowserScheme.cs" /> <Compile Include="src\BrowserScheme.cs" />
<EmbeddedResource Include="Resources\HtmlHelp2.16x16.Print.bmp" /> <EmbeddedResource Include="Resources\HtmlHelp2.16x16.Print.bmp" />

21
src/AddIns/Misc/HtmlHelp2/Project/Resources/HtmlHelp2Options.xfrm

@ -7,19 +7,10 @@
<Name value="groupBox1" /> <Name value="groupBox1" />
<Location value="{X=8, Y=8}" /> <Location value="{X=8, Y=8}" />
<Text value="${res:AddIns.HtmlHelp2.Options.Groupbox}" /> <Text value="${res:AddIns.HtmlHelp2.Options.Groupbox}" />
<Size value="{Width=344, Height=124}" /> <Size value="{Width=344, Height=112}" />
<TabIndex value="0" /> <TabIndex value="0" />
<Anchor value="Top, Left, Right" /> <Anchor value="Top, Left, Right" />
<Controls> <Controls>
<!-- ReRegisterButton
<System.Windows.Forms.Button>
<Name value="reregisterButton" />
<Location value="{X=73,Y=107}" />
<Text value="${res:AddIns.HtmlHelp2.Options.Reregister}" />
<Size value="{Width=204, Height=23}" />
<Anchor value="Top" />
<TabIndex value="2" />
</System.Windows.Forms.Button> -->
<System.Windows.Forms.ComboBox> <System.Windows.Forms.ComboBox>
<Name value="help2Collections" /> <Name value="help2Collections" />
<TabIndex value="1" /> <TabIndex value="1" />
@ -27,7 +18,7 @@
<Size value="{Width=312, Height=21}" /> <Size value="{Width=312, Height=21}" />
<FormattingEnabled value="True" /> <FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" /> <DropDownStyle value="DropDownList" />
<Location value="{X=16,Y=80}" /> <Location value="{X=16, Y=75}" />
</System.Windows.Forms.ComboBox> </System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label> <System.Windows.Forms.Label>
<Name value="label1" /> <Name value="label1" />
@ -41,9 +32,9 @@
</System.Windows.Forms.GroupBox> </System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox> <System.Windows.Forms.GroupBox>
<Name value="groupBox2" /> <Name value="groupBox2" />
<Location value="{X=8, Y=145}" /> <Location value="{X=8, Y=130}" />
<Text value="${res:AddIns.HtmlHelp2.Options.AdditionOptions}" /> <Text value="${res:AddIns.HtmlHelp2.Options.AdditionOptions}" />
<Size value="{Width=344, Height=124}" /> <Size value="{Width=344, Height=55}" />
<TabIndex value="1" /> <TabIndex value="1" />
<Anchor value="Top, Left, Right" /> <Anchor value="Top, Left, Right" />
<Controls> <Controls>
@ -51,8 +42,8 @@
<Name value="tocPictures" /> <Name value="tocPictures" />
<TabIndex value="0" /> <TabIndex value="0" />
<Anchor value="Top, Left, Right" /> <Anchor value="Top, Left, Right" />
<Size value="{Width=312, Height=45}" /> <Size value="{Width=312, Height=23}" />
<Location value="{X=16, Y=15}" /> <Location value="{X=16, Y=20}" />
<Text value="${res:AddIns.HtmlHelp2.Options.ShowTocPictures}" /> <Text value="${res:AddIns.HtmlHelp2.Options.ShowTocPictures}" />
</System.Windows.Forms.CheckBox> </System.Windows.Forms.CheckBox>
</Controls> </Controls>

4
src/AddIns/Misc/HtmlHelp2/Project/Resources/context.html

@ -3,7 +3,7 @@
<title>Dynamic Help</title> <title>Dynamic Help</title>
<STYLE><!-- <STYLE><!--
.ctxbody { body {
overflow-y: auto; overflow-y: auto;
margin: 5px 5px 5px 5px; margin: 5px 5px 5px 5px;
font-family: Tahoma; font-family: Tahoma;
@ -44,5 +44,5 @@
--></script> --></script>
</head> </head>
<body class="ctxbody"></body> <body></body>
</html> </html>

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

@ -41,7 +41,7 @@ namespace HtmlHelp2
private StringCollection dynamicHelpTerms = new StringCollection(); private StringCollection dynamicHelpTerms = new StringCollection();
private Point lastPoint = Point.Empty; private Point lastPoint = Point.Empty;
private string debugPreElement = String.Empty; private string debugPreElement = String.Empty;
private bool enableDebugInfo = false; private bool enableDebugInfo = HtmlHelp2Environment.Config.DynamicHelpDebugInfos;
public override Control Control public override Control Control
{ {
@ -57,25 +57,25 @@ namespace HtmlHelp2
{ {
dynamicHelpBrowser = new HtmlHelp2DynamicHelpBrowserControl(); dynamicHelpBrowser = new HtmlHelp2DynamicHelpBrowserControl();
dynamicHelpBrowser.LoadDynamicHelpPage(); dynamicHelpBrowser.LoadDynamicHelpPage();
// while (!dynamicHelpBrowser.BrowserIsReady) {}
// dynamicHelpBrowser.BuildANothing();
ParserService.ParserUpdateStepFinished += UpdateTick; ParserService.ParserUpdateStepFinished += UpdateTick;
PropertyPad.SelectedObjectChanged += new EventHandler(this.FormsDesignerSelectedObjectChanged); PropertyPad.SelectedObjectChanged += new EventHandler(this.FormsDesignerSelectedObjectChanged);
PropertyPad.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(this.FormsDesignerSelectedGridItemChanged); PropertyPad.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(this.FormsDesignerSelectedGridItemChanged);
ProjectService.SolutionClosed += new EventHandler(this.SolutionClosed); ProjectService.SolutionClosed += new EventHandler(this.SolutionClosed);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
} }
#region Dynamic Help Calls #region Dynamic Help Calls
private void BuildDynamicHelpList() private void BuildDynamicHelpList()
{ {
if (this.dynamicHelpTerms.Count == 0) return; try
{
dynamicHelpBrowser.RemoveAllChildren(); dynamicHelpBrowser.RemoveAllChildren();
this.debugPreElement = string.Empty;
this.debugPreElement = String.Empty;
bool helpResults = false; bool helpResults = false;
Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.WaitCursor;
foreach (string currentHelpTerm in this.dynamicHelpTerms) foreach (string currentHelpTerm in this.dynamicHelpTerms)
{ {
if (!currentHelpTerm.StartsWith("!")) if (!currentHelpTerm.StartsWith("!"))
@ -87,36 +87,45 @@ namespace HtmlHelp2
{ {
if (currentHelpTerm.StartsWith("!")) if (currentHelpTerm.StartsWith("!"))
{ {
helpResults = (this.CallDynamicHelp(currentHelpTerm.Substring(1), true) || helpResults); helpResults = (this.CallDynamicHelp(currentHelpTerm.Substring(1)) || helpResults);
} }
} }
if (!helpResults)
Cursor.Current = Cursors.Default;
// debug info
if (this.enableDebugInfo)
{ {
dynamicHelpBrowser.BuildANothing(); this.debugPreElement +=
string.Format("<br>Current project language: {0}", SharpDevLanguage.GetPatchedLanguage());
dynamicHelpBrowser.CreateDebugPre(this.debugPreElement);
}
}
catch (Exception ex)
{
LoggingService.Error("Help 2.0: Dynamic Help Call Exception; " + ex.ToString());
}
} }
Cursor.Current = Cursors.Default;
this.debugPreElement += String.Format("<br>Current project language: {0}", private bool CallDynamicHelp(string searchTerm)
SharpDevLanguage.GetPatchedLanguage()); {
if (this.enableDebugInfo) dynamicHelpBrowser.CreateDebugPre(this.debugPreElement); return this.CallDynamicHelp(searchTerm, true);
} }
private bool CallDynamicHelp(string searchTerm, bool keywordSearch) private bool CallDynamicHelp(string searchTerm, bool keywordSearch)
{ {
if (!HtmlHelp2Environment.IsReady || HtmlHelp2Environment.DynamicHelpIsBusy) return false; if (!HtmlHelp2Environment.IsReady || HtmlHelp2Environment.DynamicHelpIsBusy)
bool result = false;
IHxTopicList topics = null;
try
{ {
topics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchTerm); return false;
result = (topics != null && topics.Count > 0);
this.debugPreElement += String.Format("{0} ({1}): {2} {3}<br>",
searchTerm, (keywordSearch)?"Kwd":"DH",
topics.Count.ToString(), (topics.Count == 1)?"topic":"topics");
} }
catch {}
IHxTopicList topics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchTerm);
bool result = (topics != null && topics.Count > 0);
// debug info
this.debugPreElement +=
string.Format("{0} ({1}): {2} {3}<br>", searchTerm, (keywordSearch)?"Kwd":"DH",
topics.Count, (topics.Count==1)?"topic":"topics");
if (result) if (result)
{ {
@ -245,7 +254,6 @@ namespace HtmlHelp2
private void SolutionClosed(object sender, EventArgs e) private void SolutionClosed(object sender, EventArgs e)
{ {
dynamicHelpBrowser.RemoveAllChildren(); dynamicHelpBrowser.RemoveAllChildren();
dynamicHelpBrowser.BuildANothing();
} }
#region StringCollection & Sorting #region StringCollection & Sorting
@ -267,25 +275,18 @@ namespace HtmlHelp2
private List<IHxTopic> SortTopics(IHxTopicList topics) private List<IHxTopic> SortTopics(IHxTopicList topics)
{ {
List<IHxTopic> result = new List<IHxTopic>(); if (topics == null || topics.Count == 0)
try
{
if (topics != null && topics.Count > 0)
{ {
return null;
}
List<IHxTopic> result = new List<IHxTopic>();
foreach (IHxTopic topic in topics) foreach (IHxTopic topic in topics)
{ {
if (!result.Contains(topic)) result.Add(topic); if (!result.Contains(topic)) result.Add(topic);
} }
TopicComparer topicComparer = new TopicComparer(); TopicComparer topicComparer = new TopicComparer();
result.Sort(topicComparer); result.Sort(topicComparer);
}
}
catch(Exception ex)
{
LoggingService.Error("Help 2.0: error while rebuild topics; " + ex.ToString());
}
return result; return result;
} }
@ -313,6 +314,11 @@ namespace HtmlHelp2
} }
} }
#endregion #endregion
private void NamespaceReloaded(object sender, EventArgs e)
{
this.enableDebugInfo = HtmlHelp2Environment.Config.DynamicHelpDebugInfos;
}
} }
public class HtmlHelp2DynamicHelpBrowserControl : UserControl public class HtmlHelp2DynamicHelpBrowserControl : UserControl
@ -330,7 +336,7 @@ namespace HtmlHelp2
{ {
for (int i = 0; i < toolbarButtons.Length; i++) for (int i = 0; i < toolbarButtons.Length; i++)
{ {
dynamicHelpToolbar.Items[i].ToolTipText = StringParser.Parse(toolbarButtons[i]); dynamicHelpToolbar.Items[i].Text = StringParser.Parse(toolbarButtons[i]);
} }
} }
@ -361,13 +367,15 @@ namespace HtmlHelp2
for (int i = 0; i < toolbarButtons.Length; i++) for (int i = 0; i < toolbarButtons.Length; i++)
{ {
ToolStripButton button = new ToolStripButton(); ToolStripButton button = new ToolStripButton();
button.Text = StringParser.Parse(toolbarButtons[i]); button.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
button.ImageIndex = i; button.ImageIndex = i;
button.Click += new EventHandler(this.ToolStripButtonClicked); button.Click += new EventHandler(this.ToolStripButtonClicked);
dynamicHelpToolbar.Items.Add(button); dynamicHelpToolbar.Items.Add(button);
} }
this.RedrawContent();
dynamicHelpToolbar.ImageList = new ImageList(); dynamicHelpToolbar.ImageList = new ImageList();
dynamicHelpToolbar.ImageList.ColorDepth = ColorDepth.Depth32Bit; dynamicHelpToolbar.ImageList.ColorDepth = ColorDepth.Depth32Bit;
dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Toc.png")); dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Toc.png"));
@ -382,16 +390,18 @@ namespace HtmlHelp2
public void LoadDynamicHelpPage() public void LoadDynamicHelpPage()
{ {
if (!HtmlHelp2Environment.IsReady) return; if (!HtmlHelp2Environment.IsReady)
string url = String.Format("res://{0}/context", Assembly.GetExecutingAssembly().Location); {
return;
}
string url = String.Format("res://{0}/context", Assembly.GetExecutingAssembly().Location);
axWebBrowser.Navigate(url); axWebBrowser.Navigate(url);
} }
private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{ {
this.RemoveAllChildren(); this.RemoveAllChildren();
this.BuildANothing();
} }
private void ToolStripButtonClicked(object sender, EventArgs e) private void ToolStripButtonClicked(object sender, EventArgs e)
@ -425,31 +435,27 @@ namespace HtmlHelp2
#region WebBrowser Scripting #region WebBrowser Scripting
public void BuildNewChild(string sectionName, string topicName, string topicUrl) public void BuildNewChild(string sectionName, string topicName, string topicUrl)
{ {
try HtmlElementCollection children =
{ axWebBrowser.Document.Body.GetElementsByTagName("span");
HtmlElementCollection children = axWebBrowser.Document.Body.GetElementsByTagName("span"); foreach (HtmlElement child in children)
if (children.Count > 0)
{
foreach (HtmlElement elem in children)
{ {
if (elem.GetAttribute("className") == "section") if (child.GetAttribute("className") == "section")
{ {
HtmlElement sectionBlock = elem.FirstChild.NextSibling; HtmlElement sectionBlock = child.FirstChild.NextSibling;
HtmlElement contentSpan = sectionBlock.NextSibling.NextSibling; HtmlElement contentSpan = sectionBlock.NextSibling.NextSibling;
if (sectionBlock.TagName == "B" && sectionBlock.InnerText == sectionName && if (sectionBlock.TagName == "B" &&
contentSpan.TagName == "SPAN" && contentSpan.GetAttribute("className") == "content") sectionBlock.InnerText == sectionName &&
contentSpan.TagName == "SPAN" &&
contentSpan.GetAttribute("className") == "content")
{ {
if (!this.DoesLinkExist(contentSpan, topicName, topicUrl)) if (!this.DoesLinkExist(contentSpan, topicName, topicUrl))
{ {
HtmlElement newLink = this.CreateNewLink(topicUrl, topicName); HtmlElement newLink = this.CreateNewLink(topicUrl, topicName);
HtmlElement br = this.CreateABreak();
if (newLink != null) if (newLink != null)
{ {
contentSpan.AppendChild(newLink); contentSpan.AppendChild(newLink);
if (br != null) contentSpan.AppendChild(br); contentSpan.AppendChild(this.CreateABreak());
} }
} }
@ -458,47 +464,40 @@ namespace HtmlHelp2
} }
} }
try if (children.Count > 0)
{ {
axWebBrowser.Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, axWebBrowser.Document.Body.InsertAdjacentElement
this.CreateABreak()); (HtmlElementInsertionOrientation.BeforeEnd, this.CreateABreak());
}
catch {}
} }
HtmlElement linkContent = null; HtmlElement linkContent = null;
HtmlElement htmlSection = this.CreateNewSection(sectionName, out linkContent); HtmlElement htmlSection = this.CreateNewSection(sectionName, out linkContent);
if (htmlSection != null) if (htmlSection != null)
{ {
axWebBrowser.Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, axWebBrowser.Document.Body.InsertAdjacentElement
htmlSection); (HtmlElementInsertionOrientation.BeforeEnd, htmlSection);
HtmlElement newLink = this.CreateNewLink(topicUrl, topicName); HtmlElement newLink = this.CreateNewLink(topicUrl, topicName);
HtmlElement br = this.CreateABreak(); if (newLink != null)
{
if (newLink != null) linkContent.AppendChild(newLink); linkContent.AppendChild(newLink);
if (br != null) linkContent.AppendChild(br); linkContent.AppendChild(this.CreateABreak());
}
this.internalIndex++; this.internalIndex++;
} }
} }
catch (Exception ex)
{
LoggingService.Error("Help 2.0: " + ex.ToString());
}
}
private HtmlElement CreateNewSection(string sectionName, out HtmlElement linkNode) private HtmlElement CreateNewSection(string sectionName, out HtmlElement linkNode)
{ {
HtmlElement span = axWebBrowser.Document.CreateElement("SPAN"); HtmlElement span = axWebBrowser.Document.CreateElement("span");
span.SetAttribute("className", "section"); span.SetAttribute("className", "section");
span.InnerHtml = String.Format( span.InnerHtml = String.Format
"<img style=\"width:16px;height:16px;margin-right:5px\" id=\"image_{0}\" src=\"open\">" + ("<img style=\"width:16px;height:16px;margin-right:5px\" id=\"image_{0}\" src=\"open\">" +
"<b style=\"cursor:auto;\" id=\"{0}\" onclick=\"ExpandCollapse({0})\">{1}</b><br>", "<b style=\"cursor:auto;\" id=\"{0}\" onclick=\"ExpandCollapse({0})\">{1}</b><br>",
this.internalIndex, sectionName); this.internalIndex, sectionName);
linkNode = axWebBrowser.Document.CreateElement("SPAN"); linkNode = axWebBrowser.Document.CreateElement("span");
linkNode.SetAttribute("className", "content"); linkNode.SetAttribute("className", "content");
linkNode.Id = String.Format("content_{0}", this.internalIndex); linkNode.Id = String.Format("content_{0}", this.internalIndex);
span.AppendChild(linkNode); span.AppendChild(linkNode);
@ -508,7 +507,7 @@ namespace HtmlHelp2
private HtmlElement CreateNewLink(string topicUrl, string topicName) private HtmlElement CreateNewLink(string topicUrl, string topicName)
{ {
HtmlElement span = axWebBrowser.Document.CreateElement("A"); HtmlElement span = axWebBrowser.Document.CreateElement("a");
span.InnerText = topicName; span.InnerText = topicName;
span.SetAttribute("src", topicUrl); span.SetAttribute("src", topicUrl);
span.SetAttribute("className", "link"); span.SetAttribute("className", "link");
@ -522,70 +521,44 @@ namespace HtmlHelp2
private HtmlElement CreateABreak() private HtmlElement CreateABreak()
{ {
HtmlElement br = axWebBrowser.Document.CreateElement("BR"); HtmlElement br = axWebBrowser.Document.CreateElement("br");
return br; return br;
} }
public void BuildANothing()
{
try
{
HtmlElement nothing = axWebBrowser.Document.CreateElement("B");
nothing.InnerText = StringParser.Parse("${res:AddIns.HtmlHelp2.NoDataIsAvailableForDynamicHelp}");
nothing.SetAttribute("title", nothing.InnerText);
axWebBrowser.Document.Body.InnerHtml = "";
axWebBrowser.Document.Body.AppendChild(nothing);
}
catch(Exception ex)
{
LoggingService.Error(ex.Message);
}
}
private bool DoesLinkExist(HtmlElement parentNode, string topicName, string topicUrl) private bool DoesLinkExist(HtmlElement parentNode, string topicName, string topicUrl)
{ {
try HtmlElementCollection links = parentNode.GetElementsByTagName("a");
{ foreach (HtmlElement link in links)
HtmlElementCollection allLinks = parentNode.GetElementsByTagName("a");
if (allLinks.Count > 0)
{
foreach (HtmlElement link in allLinks)
{ {
if (String.Compare(topicName, link.InnerText) == 0 && if (string.Compare(topicName, link.InnerText) == 0 &&
String.Compare(topicUrl, link.GetAttribute("src")) == 0) string.Compare(topicUrl, link.GetAttribute("src")) == 0)
{ {
return true; return true;
} }
} }
}
}
catch { }
return false; return false;
} }
private void OnMouseOver(object sender, HtmlElementEventArgs e) private void OnMouseOver(object sender, HtmlElementEventArgs e)
{ {
try if (sender is HtmlElement)
{ {
StatusBarService.SetMessage(((HtmlElement)sender).GetAttribute("src")); StatusBarService.SetMessage(((HtmlElement)sender).GetAttribute("src"));
} }
catch {}
} }
private void OnMouseOut(object sender, HtmlElementEventArgs e) private void OnMouseOut(object sender, HtmlElementEventArgs e)
{ {
StatusBarService.SetMessage(""); StatusBarService.SetMessage(string.Empty);
} }
private void OnLinkClick(object sender, HtmlElementEventArgs e) private void OnLinkClick(object sender, HtmlElementEventArgs e)
{ {
try if (sender is HtmlElement)
{ {
string url = ((HtmlElement)sender).GetAttribute("src"); string url = ((HtmlElement)sender).GetAttribute("src");
if(url != null && url.Length > 0) ShowHelpBrowser.OpenHelpView(url); if (!string.IsNullOrEmpty(url)) ShowHelpBrowser.OpenHelpView(url);
} }
catch {}
} }
public void RemoveAllChildren() public void RemoveAllChildren()
@ -593,11 +566,11 @@ namespace HtmlHelp2
try try
{ {
this.internalIndex = 0; this.internalIndex = 0;
axWebBrowser.Document.Body.InnerHtml = ""; axWebBrowser.Document.Body.InnerHtml = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
{ {
LoggingService.Error("Help 2.0: error while removing HTML children; " + ex.ToString()); LoggingService.Error("Help 2.0: Clean-up Call Exception; " + ex.ToString());
} }
} }
#endregion #endregion
@ -605,27 +578,23 @@ namespace HtmlHelp2
#region DebugInfo #region DebugInfo
public void CreateDebugPre(string debugInformation) public void CreateDebugPre(string debugInformation)
{ {
if (debugInformation == String.Empty) return; if (!string.IsNullOrEmpty(debugInformation))
try
{ {
axWebBrowser.Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, axWebBrowser.Document.Body.InsertAdjacentElement
this.CreateABreak()); (HtmlElementInsertionOrientation.BeforeEnd, CreateABreak());
axWebBrowser.Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, axWebBrowser.Document.Body.InsertAdjacentElement
this.CreateABreak()); (HtmlElementInsertionOrientation.BeforeEnd, CreateABreak());
HtmlElement pre = axWebBrowser.Document.CreateElement("pre"); HtmlElement pre = axWebBrowser.Document.CreateElement("pre");
pre.InnerHtml = "--- Dynamic Help Debug ---<br>" + debugInformation; pre.InnerHtml = "--- Dynamic Help Debug ---<br>" + debugInformation;
axWebBrowser.Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.BeforeEnd, axWebBrowser.Document.Body.InsertAdjacentElement
pre); (HtmlElementInsertionOrientation.BeforeEnd, pre);
} }
catch {}
} }
#endregion #endregion
} }
#region TypeHandling by Robert_G
public static class TypeHandling public static class TypeHandling
{ {
public static IEnumerable<Type> FindDeclaringType(Type type, string memberName) public static IEnumerable<Type> FindDeclaringType(Type type, string memberName)
@ -644,10 +613,9 @@ namespace HtmlHelp2
yield return declaringType; yield return declaringType;
} }
// QUOTE: #region TypeHandling Class by Robert_G
// "Aber das ist wohl eher ein no-Brainer... ;-)" // QUOTE: "Aber das ist ja wohl eher ein no-Brainer... ;-)
// (Robert) #endregion
} }
} }
#endregion
} }

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

@ -114,12 +114,14 @@ namespace HtmlHelp2
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = this.isEnabled; filterCombobox.Enabled = this.isEnabled;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged);
Controls.Add(label1); Controls.Add(label1);
label1.Dock = DockStyle.Top; label1.Dock = DockStyle.Top;
label1.TextAlign = ContentAlignment.MiddleLeft; label1.TextAlign = ContentAlignment.MiddleLeft;
label1.Enabled = this.isEnabled; label1.Enabled = this.isEnabled;
label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
Panel panel2 = new Panel(); Panel panel2 = new Panel();
Controls.Add(panel2); Controls.Add(panel2);
@ -129,6 +131,7 @@ namespace HtmlHelp2
panel2.Controls.Add(searchTerm); panel2.Controls.Add(searchTerm);
searchTerm.Dock = DockStyle.Top; searchTerm.Dock = DockStyle.Top;
searchTerm.Enabled = this.isEnabled; searchTerm.Enabled = this.isEnabled;
searchTerm.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
searchTerm.TextChanged += new EventHandler(this.SearchTextChanged); searchTerm.TextChanged += new EventHandler(this.SearchTextChanged);
searchTerm.KeyPress += new KeyPressEventHandler(this.SearchKeyPress); searchTerm.KeyPress += new KeyPressEventHandler(this.SearchKeyPress);
@ -136,6 +139,7 @@ namespace HtmlHelp2
label2.Dock = DockStyle.Top; label2.Dock = DockStyle.Top;
label2.TextAlign = ContentAlignment.MiddleLeft; label2.TextAlign = ContentAlignment.MiddleLeft;
label2.Enabled = this.isEnabled; label2.Enabled = this.isEnabled;
label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent(); this.RedrawContent();
@ -153,10 +157,11 @@ namespace HtmlHelp2
indexControl = null; indexControl = null;
Controls.Clear(); Controls.Clear();
Panel nohelpPanel = new Panel(); Label nohelpLabel = new Label();
nohelpPanel.Dock = DockStyle.Fill; nohelpLabel.Dock = DockStyle.Fill;
nohelpPanel.BorderStyle = BorderStyle.Fixed3D; nohelpLabel.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}");
Controls.Add(nohelpPanel); nohelpLabel.TextAlign = ContentAlignment.MiddleCenter;
Controls.Add(nohelpLabel);
} }
public void RedrawContent() public void RedrawContent()
@ -175,14 +180,13 @@ namespace HtmlHelp2
searchTerm.SelectedIndex = 0; searchTerm.SelectedIndex = 0;
itemClicked = false; itemClicked = false;
this.ShowSelectedItemEntry(indexTerm, indexSlot); this.ShowSelectedItemEntry(indexTerm, indexSlot);
} }
private void FilterChanged(object sender, EventArgs e) private void FilterChanged(object sender, EventArgs e)
{ {
string selectedFilterName = filterCombobox.SelectedItem.ToString(); string selectedFilterName = filterCombobox.SelectedItem.ToString();
if (selectedFilterName != null && selectedFilterName.Length > 0) if (!string.IsNullOrEmpty(selectedFilterName))
{ {
Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.WaitCursor;
this.SetIndex(selectedFilterName); this.SetIndex(selectedFilterName);

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

@ -60,6 +60,7 @@ namespace HtmlHelp2
listView.MultiSelect = false; listView.MultiSelect = false;
listView.HideSelection = false; listView.HideSelection = false;
listView.Enabled = HtmlHelp2Environment.IsReady; listView.Enabled = HtmlHelp2Environment.IsReady;
listView.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
ListViewResize(this,null); ListViewResize(this,null);
listView.Resize += new EventHandler(ListViewResize); listView.Resize += new EventHandler(ListViewResize);

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

@ -91,6 +91,7 @@ namespace HtmlHelp2
panel3.Controls.Add(searchButton); panel3.Controls.Add(searchButton);
searchButton.Enabled = false; searchButton.Enabled = false;
searchButton.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
searchButton.Click += new EventHandler(SearchButtonClick); searchButton.Click += new EventHandler(SearchButtonClick);
panel3.Controls.Add(titlesOnly); panel3.Controls.Add(titlesOnly);
panel3.Controls.Add(enableStemming); panel3.Controls.Add(enableStemming);
@ -102,28 +103,33 @@ namespace HtmlHelp2
titlesOnly.Top = searchButton.Top + searchButton.Height + 10; titlesOnly.Top = searchButton.Top + searchButton.Height + 10;
titlesOnly.TextAlign = ContentAlignment.MiddleLeft; titlesOnly.TextAlign = ContentAlignment.MiddleLeft;
titlesOnly.Enabled = HtmlHelp2Environment.IsReady; titlesOnly.Enabled = HtmlHelp2Environment.IsReady;
titlesOnly.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
enableStemming.Width = pw; enableStemming.Width = pw;
enableStemming.Top = titlesOnly.Top + titlesOnly.Height - 4; enableStemming.Top = titlesOnly.Top + titlesOnly.Height - 4;
enableStemming.TextAlign = ContentAlignment.MiddleLeft; enableStemming.TextAlign = ContentAlignment.MiddleLeft;
enableStemming.Enabled = HtmlHelp2Environment.IsReady; enableStemming.Enabled = HtmlHelp2Environment.IsReady;
enableStemming.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
reuseMatches.Width = pw; reuseMatches.Width = pw;
reuseMatches.Top = enableStemming.Top + enableStemming.Height - 4; reuseMatches.Top = enableStemming.Top + enableStemming.Height - 4;
reuseMatches.Enabled = false; reuseMatches.Enabled = false;
reuseMatches.TextAlign = ContentAlignment.MiddleLeft; reuseMatches.TextAlign = ContentAlignment.MiddleLeft;
reuseMatches.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
hiliteTopics.Width = pw; hiliteTopics.Width = pw;
hiliteTopics.Top = reuseMatches.Top + reuseMatches.Height - 4; hiliteTopics.Top = reuseMatches.Top + reuseMatches.Height - 4;
hiliteTopics.TextAlign = ContentAlignment.MiddleLeft; hiliteTopics.TextAlign = ContentAlignment.MiddleLeft;
hiliteTopics.Enabled = HtmlHelp2Environment.IsReady; hiliteTopics.Enabled = HtmlHelp2Environment.IsReady;
hiliteTopics.Checked = true; hiliteTopics.Checked = true;
hiliteTopics.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
useCurrentLang.Width = pw; useCurrentLang.Width = pw;
useCurrentLang.Top = hiliteTopics.Top + hiliteTopics.Height; useCurrentLang.Top = hiliteTopics.Top + hiliteTopics.Height;
useCurrentLang.TextAlign = ContentAlignment.MiddleLeft; useCurrentLang.TextAlign = ContentAlignment.MiddleLeft;
useCurrentLang.Enabled = HtmlHelp2Environment.IsReady; useCurrentLang.Enabled = HtmlHelp2Environment.IsReady;
useCurrentLang.Visible = ProjectService.CurrentProject != null; useCurrentLang.Visible = ProjectService.CurrentProject != null;
useCurrentLang.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
panel3.Dock = DockStyle.Fill; panel3.Dock = DockStyle.Fill;
@ -137,6 +143,7 @@ namespace HtmlHelp2
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = HtmlHelp2Environment.IsReady; filterCombobox.Enabled = HtmlHelp2Environment.IsReady;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged); filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged);
if (HtmlHelp2Environment.IsReady) if (HtmlHelp2Environment.IsReady)
@ -151,6 +158,7 @@ namespace HtmlHelp2
label1.Dock = DockStyle.Top; label1.Dock = DockStyle.Top;
label1.TextAlign = ContentAlignment.MiddleLeft; label1.TextAlign = ContentAlignment.MiddleLeft;
label1.Enabled = HtmlHelp2Environment.IsReady; label1.Enabled = HtmlHelp2Environment.IsReady;
label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
// SearchTerm Combobox // SearchTerm Combobox
Panel panel2 = new Panel(); Panel panel2 = new Panel();
@ -162,11 +170,13 @@ namespace HtmlHelp2
searchTerm.TextChanged += new EventHandler(SearchTextChanged); searchTerm.TextChanged += new EventHandler(SearchTextChanged);
searchTerm.KeyPress += new KeyPressEventHandler(KeyPressed); searchTerm.KeyPress += new KeyPressEventHandler(KeyPressed);
searchTerm.Enabled = HtmlHelp2Environment.IsReady; searchTerm.Enabled = HtmlHelp2Environment.IsReady;
searchTerm.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
mainPanel.Controls.Add(label2); mainPanel.Controls.Add(label2);
label2.Dock = DockStyle.Top; label2.Dock = DockStyle.Top;
label2.TextAlign = ContentAlignment.MiddleLeft; label2.TextAlign = ContentAlignment.MiddleLeft;
label2.Enabled = HtmlHelp2Environment.IsReady; label2.Enabled = HtmlHelp2Environment.IsReady;
label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent(); this.RedrawContent();
@ -177,7 +187,7 @@ namespace HtmlHelp2
private void FilterChanged(object sender, EventArgs e) private void FilterChanged(object sender, EventArgs e)
{ {
string selectedFilterName = filterCombobox.SelectedItem.ToString(); string selectedFilterName = filterCombobox.SelectedItem.ToString();
if (selectedFilterName.Length > 0) if (!string.IsNullOrEmpty(selectedFilterName))
{ {
selectedQuery = HtmlHelp2Environment.FindFilterQuery(selectedFilterName); selectedQuery = HtmlHelp2Environment.FindFilterQuery(selectedFilterName);
} }
@ -210,7 +220,7 @@ namespace HtmlHelp2
private void SearchButtonClick(object sender, EventArgs e) private void SearchButtonClick(object sender, EventArgs e)
{ {
if (searchTerm.Text.Length > 0) if (!string.IsNullOrEmpty(searchTerm.Text))
{ {
this.AddTermToList(searchTerm.Text); this.AddTermToList(searchTerm.Text);
this.PerformFTS(searchTerm.Text); this.PerformFTS(searchTerm.Text);
@ -219,7 +229,7 @@ namespace HtmlHelp2
private void SearchTextChanged(object sender, EventArgs e) private void SearchTextChanged(object sender, EventArgs e)
{ {
searchButton.Enabled = (searchTerm.Text.Length > 0); searchButton.Enabled = (!string.IsNullOrEmpty(searchTerm.Text));
} }
private void KeyPressed(object sender, KeyPressEventArgs e) private void KeyPressed(object sender, KeyPressEventArgs e)
@ -250,7 +260,10 @@ namespace HtmlHelp2
private void PerformFTS(string searchWord, bool useDynamicHelp) private void PerformFTS(string searchWord, bool useDynamicHelp)
{ {
if (!HtmlHelp2Environment.IsReady || searchIsBusy) return; if (!HtmlHelp2Environment.IsReady || string.IsNullOrEmpty(searchWord) || searchIsBusy)
{
return;
}
HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance; HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;
@ -331,7 +344,10 @@ namespace HtmlHelp2
public bool PerformF1FTS(string keyword, bool useDynamicHelp) public bool PerformF1FTS(string keyword, bool useDynamicHelp)
{ {
if (!HtmlHelp2Environment.IsReady || searchIsBusy) return false; if (!HtmlHelp2Environment.IsReady || string.IsNullOrEmpty(keyword) || searchIsBusy)
{
return false;
}
this.PerformFTS(keyword, useDynamicHelp); this.PerformFTS(keyword, useDynamicHelp);

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

@ -67,6 +67,7 @@ namespace HtmlHelp2
listView.Alignment = ListViewAlignment.Left; listView.Alignment = ListViewAlignment.Left;
listView.View = View.Details; listView.View = View.Details;
listView.Dock = DockStyle.Fill; listView.Dock = DockStyle.Fill;
listView.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
ListViewResize(this,null); ListViewResize(this,null);
listView.Resize += new EventHandler(ListViewResize); listView.Resize += new EventHandler(ListViewResize);

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

@ -167,12 +167,14 @@ namespace HtmlHelp2
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = this.isEnabled; filterCombobox.Enabled = this.isEnabled;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged);
Controls.Add(label1); Controls.Add(label1);
label1.Dock = DockStyle.Top; label1.Dock = DockStyle.Top;
label1.TextAlign = ContentAlignment.MiddleLeft; label1.TextAlign = ContentAlignment.MiddleLeft;
label1.Enabled = this.isEnabled; label1.Enabled = this.isEnabled;
label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent(); this.RedrawContent();
if (this.isEnabled) if (this.isEnabled)
@ -293,7 +295,7 @@ namespace HtmlHelp2
private void CallHelp(string topicUrl, bool syncToc) private void CallHelp(string topicUrl, bool syncToc)
{ {
if (topicUrl.Length > 0) if (!string.IsNullOrEmpty(topicUrl))
{ {
if (syncToc) this.SynchronizeToc(topicUrl); if (syncToc) this.SynchronizeToc(topicUrl);
ShowHelpBrowser.OpenHelpView(topicUrl); ShowHelpBrowser.OpenHelpView(topicUrl);

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

@ -44,13 +44,5 @@ namespace HtmlHelp2.ControlsValidation
return false; return false;
} }
} }
public Help2ControlsValidation()
{
}
static Help2ControlsValidation()
{
}
} }
} }

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

@ -15,65 +15,59 @@ namespace HtmlHelp2.RegistryWalker
public sealed class Help2RegistryWalker public sealed class Help2RegistryWalker
{ {
private static HxRegNamespacePropId NamespaceDescription = public static void BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection)
HxRegNamespacePropId.HxRegNamespaceDescription;
public Help2RegistryWalker()
{ {
} if (help2Collections == null)
static Help2RegistryWalker()
{ {
return;
} }
public static void BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection)
{
if (help2Collections == null) return;
help2Collections.Items.Clear(); help2Collections.Items.Clear();
help2Collections.BeginUpdate(); help2Collections.BeginUpdate();
try try
{ {
string currentDescription = ""; string currentDescription = string.Empty;
HxRegistryWalker regWalker = new HxRegistryWalker(); HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = regWalker.get_RegisteredNamespaceList(""); IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in namespaces) foreach (IHxRegNamespace currentNamespace in namespaces)
{ {
help2Collections.Items.Add((string)currentNamespace.GetProperty(NamespaceDescription)); help2Collections.Items.Add
((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription));
if (selectedHelp2Collection != "" && if (!string.IsNullOrEmpty(selectedHelp2Collection) &&
String.Compare(selectedHelp2Collection, currentNamespace.Name) == 0) string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
{ {
currentDescription = currentDescription =
(string)currentNamespace.GetProperty(NamespaceDescription); (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
} }
} }
if (currentDescription != "") if (!string.IsNullOrEmpty(currentDescription))
help2Collections.SelectedIndex = help2Collections.Items.IndexOf(currentDescription); help2Collections.SelectedIndex = help2Collections.Items.IndexOf(currentDescription);
else else
help2Collections.SelectedIndex = 0; help2Collections.SelectedIndex = 0;
} }
catch(Exception ex) catch(Exception ex)
{ {
LoggingService.Error("Help 2.0: cannot build namespaces list for Options dialog", ex); LoggingService.Error("Help 2.0: Cannot build namespaces list;", ex);
} }
help2Collections.EndUpdate(); help2Collections.EndUpdate();
} }
public static string GetNamespaceName(string namespaceDescription) public static string GetNamespaceName(string description)
{ {
try try
{ {
HxRegistryWalker regWalker = new HxRegistryWalker(); HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = regWalker.get_RegisteredNamespaceList(""); IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in namespaces) foreach (IHxRegNamespace currentNamespace in namespaces)
{ {
string currentNamespaceName = (string)currentNamespace.GetProperty(NamespaceDescription); string currentDescription =
if (String.Compare(namespaceDescription, currentNamespaceName) == 0) (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
if (string.Compare(currentDescription, description) == 0)
{ {
return currentNamespace.Name; return currentNamespace.Name;
} }
@ -83,52 +77,55 @@ namespace HtmlHelp2.RegistryWalker
{ {
LoggingService.Error("Help 2.0: cannot find selected namespace name"); LoggingService.Error("Help 2.0: cannot find selected namespace name");
} }
return ""; return string.Empty;
} }
public static string GetFirstNamespace(string namespaceName) public static string GetFirstNamespace(string name)
{ {
try try
{ {
HxRegistryWalker regWalker = new HxRegistryWalker(); HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList namespaces = regWalker.get_RegisteredNamespaceList(""); IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in namespaces) foreach (IHxRegNamespace currentNamespace in namespaces)
{ {
if (String.Compare(namespaceName, currentNamespace.Name) == 0) if (string.Compare(currentNamespace.Name, name) == 0)
{ {
return namespaceName; return name;
} }
} }
return namespaces.ItemAt(1).Name; return namespaces.ItemAt(1).Name;
} }
catch catch
{ {
return ""; return string.Empty;
} }
} }
public static string GetFirstMatchingNamespaceName(string matchingNamespaceName) public static string GetFirstMatchingNamespaceName(string matchingName)
{
if (!string.IsNullOrEmpty(matchingName))
{ {
if (matchingNamespaceName == "") return "";
try try
{ {
HxRegistryWalker regWalker = new HxRegistryWalker(); HxRegistryWalkerClass registryWalker = new HxRegistryWalkerClass();
IHxRegNamespaceList nl = regWalker.get_RegisteredNamespaceList(""); IHxRegNamespaceList namespaces = registryWalker.get_RegisteredNamespaceList("");
foreach (IHxRegNamespace currentNamespace in nl) foreach (IHxRegNamespace currentNamespace in namespaces)
{ {
if (PathMatchSpec(currentNamespace.Name, matchingNamespaceName)) if (PathMatchSpec(currentNamespace.Name, matchingName))
{ {
return currentNamespace.Name; return currentNamespace.Name;
} }
} }
} }
catch {} catch
{
// I don't care about an exception here ;-)
}
}
return ""; return string.Empty;
} }
#region PatchMatchSpec@Win32API #region PatchMatchSpec@Win32API

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

@ -14,13 +14,11 @@ namespace HtmlHelp2.OptionsPanel
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using HtmlHelp2.Environment; using HtmlHelp2.Environment;
using HtmlHelp2.RegistryWalker; using HtmlHelp2.RegistryWalker;
using MSHelpServices;
public class HtmlHelp2OptionsPanel : AbstractOptionPanel public class HtmlHelp2OptionsPanel : AbstractOptionPanel
{ {
@ -31,8 +29,6 @@ namespace HtmlHelp2.OptionsPanel
public override void LoadPanelContents() public override void LoadPanelContents()
{ {
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("HtmlHelp2.Resources.HtmlHelp2Options.xfrm")); SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("HtmlHelp2.Resources.HtmlHelp2Options.xfrm"));
// ControlDictionary["reregisterButton"].Click += ReregisterButtonClick;
// ControlDictionary["reregisterButton"].Visible = false;
this.InitializeComponents(); this.InitializeComponents();
} }
@ -79,29 +75,6 @@ namespace HtmlHelp2.OptionsPanel
HtmlHelp2Environment.Config.TocPictures = tocPictures.Checked; HtmlHelp2Environment.Config.TocPictures = tocPictures.Checked;
HtmlHelp2Environment.SaveConfiguration(); HtmlHelp2Environment.SaveConfiguration();
} }
#region ReRegister
// void ReregisterButtonClick(object sender, EventArgs e)
// {
// System.Threading.ThreadPool.QueueUserWorkItem(DoReregister);
// }
//
// void DoReregister(object state)
// {
// try
// {
// ProcessStartInfo info = new ProcessStartInfo("cmd", "/c call echo Unregistering... & unregister.bat & echo. & echo Registering... & call register.bat & pause");
// info.WorkingDirectory = Path.Combine(FileUtility.ApplicationRootPath, "bin\\setup\\help");
// Process p = Process.Start(info);
// p.WaitForExit(45000);
// WorkbenchSingleton.SafeThreadAsyncCall(typeof(HtmlHelp2Environment), "ReloadNamespace");
// }
// catch (Exception ex)
// {
// MessageService.ShowError(ex);
// }
// }
#endregion
} }
[XmlRoot("help2environment")] [XmlRoot("help2environment")]
@ -109,6 +82,7 @@ namespace HtmlHelp2.OptionsPanel
{ {
private string selectedCollection = string.Empty; private string selectedCollection = string.Empty;
private bool tocPictures = true; private bool tocPictures = true;
private bool dynamicHelpDebugInfo = false;
[XmlElement("collection")] [XmlElement("collection")]
public string SelectedCollection public string SelectedCollection
@ -123,5 +97,12 @@ namespace HtmlHelp2.OptionsPanel
get { return tocPictures; } get { return tocPictures; }
set { tocPictures = value; } set { tocPictures = value; }
} }
[XmlElement("dhdebuginfos")]
public bool DynamicHelpDebugInfos
{
get { return this.dynamicHelpDebugInfo; }
set { this.dynamicHelpDebugInfo = value; }
}
} }
} }

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

@ -99,25 +99,6 @@ namespace HtmlHelp2.Environment
{ {
DefaultNamespaceName = config.SelectedCollection; DefaultNamespaceName = config.SelectedCollection;
} }
// try
// {
// XmlDocument xmldoc = new XmlDocument();
// xmldoc.Load(Path.Combine(PropertyService.ConfigDirectory, help2EnvironmentFile));
//
// XmlNode node = xmldoc.SelectSingleNode("/help2environment/collection");
// if (node != null) {
// if (!string.IsNullOrEmpty(node.InnerText)) {
// DefaultNamespaceName = node.InnerText;
// }
// }
//
// LoggingService.Info("Help 2.0: using last configuration");
// }
// catch
// {
// LoggingService.Info("Help 2.0: using default configuration");
// }
} }
public static void ReloadNamespace() public static void ReloadNamespace()
@ -130,10 +111,12 @@ namespace HtmlHelp2.Environment
private static void InitializeNamespace(string namespaceName) private static void InitializeNamespace(string namespaceName)
{ {
if(namespaceName == null || namespaceName == "") if (string.IsNullOrEmpty(namespaceName))
{
return; return;
}
if(session != null) session = null; session = null;
HtmlHelp2Dialog initDialog = new HtmlHelp2Dialog(); HtmlHelp2Dialog initDialog = new HtmlHelp2Dialog();
try try
@ -143,8 +126,8 @@ namespace HtmlHelp2.Environment
initDialog.Show(); initDialog.Show();
Application.DoEvents(); Application.DoEvents();
currentSelectedFilterQuery = ""; currentSelectedFilterQuery = string.Empty;
currentSelectedFilterName = ""; currentSelectedFilterName = string.Empty;
session = new HxSession(); session = new HxSession();
session.Initialize(String.Format("ms-help://{0}", namespaceName), 0); session.Initialize(String.Format("ms-help://{0}", namespaceName), 0);
@ -169,12 +152,14 @@ namespace HtmlHelp2.Environment
private static void ReloadFTSSystem() private static void ReloadFTSSystem()
{ {
fulltextSearch = (IHxQuery)session.GetNavigationInterface("!DefaultFullTextSearch", currentSelectedFilterQuery, ref QueryGuid); fulltextSearch = (IHxQuery)session.GetNavigationInterface
("!DefaultFullTextSearch", currentSelectedFilterQuery, ref QueryGuid);
} }
private static void ReloadDynamicHelpSystem() private static void ReloadDynamicHelpSystem()
{ {
dynamicHelp = (IHxIndex)session.GetNavigationInterface("!DefaultContextWindowIndex", currentSelectedFilterQuery, ref IndexGuid); dynamicHelp = (IHxIndex)session.GetNavigationInterface
("!DefaultContextWindowIndex", currentSelectedFilterQuery, ref IndexGuid);
} }
private static void ReloadDefaultPages() private static void ReloadDefaultPages()
@ -185,34 +170,59 @@ namespace HtmlHelp2.Environment
private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue) private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue)
{ {
string resultString = ""; string result = string.Empty;
try try
{ {
IHxIndex namedUrlIndex = (IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex", IHxIndex namedUrlIndex =
"", (IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex", "", ref IndexGuid);
ref IndexGuid);
IHxTopicList topics = null;
topics = namedUrlIndex.GetTopicsFromString(pageName, 0); IHxTopicList topics = namedUrlIndex.GetTopicsFromString(pageName, 0);
if (topics.Count == 0 && !string.IsNullOrEmpty(alternatePageName))
if(topics.Count == 0 && (alternatePageName != null && alternatePageName != ""))
{ {
topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0); topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0);
} }
if (topics.Count > 0) if (topics.Count > 0)
resultString = topics.ItemAt(1).URL; result = topics.ItemAt(1).URL;
if (resultString == null || resultString.Length == 0) if (string.IsNullOrEmpty(result))
resultString = defaultValue; result = defaultValue;
return resultString; return result;
} }
catch catch
{ {
return defaultValue; return defaultValue;
} }
// string resultString = "";
//
// try
// {
// IHxIndex namedUrlIndex = (IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex",
// "",
// ref IndexGuid);
// IHxTopicList topics = null;
//
// topics = namedUrlIndex.GetTopicsFromString(pageName, 0);
//
// if(topics.Count == 0 && (alternatePageName != null && alternatePageName != ""))
// {
// topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0);
// }
//
// if(topics.Count > 0)
// resultString = topics.ItemAt(1).URL;
//
// if (resultString == null || resultString.Length == 0)
// resultString = defaultValue;
//
// return resultString;
// }
// catch
// {
// return defaultValue;
// }
} }
public static IHxHierarchy GetTocHierarchy(string filterQuery) public static IHxHierarchy GetTocHierarchy(string filterQuery)
@ -238,20 +248,30 @@ namespace HtmlHelp2.Environment
{ {
foreach (IHxRegFilter filter in namespaceFilters) foreach (IHxRegFilter filter in namespaceFilters)
{ {
string filterName = (string)filter.GetProperty(HxRegFilterPropId.HxRegFilterName); string filterName =
(string)filter.GetProperty(HxRegFilterPropId.HxRegFilterName);
filterCombobox.Items.Add(filterName); filterCombobox.Items.Add(filterName);
if(currentSelectedFilterName == "") currentSelectedFilterName = filterName;
if (string.IsNullOrEmpty(currentSelectedFilterName))
{
currentSelectedFilterName = filterName;
}
} }
if (namespaceFilters.Count == 0) if (namespaceFilters.Count == 0)
filterCombobox.Items.Add(StringParser.Parse("${res:AddIns.HtmlHelp2.DefaultEmptyFilter}")); {
filterCombobox.Items.Add
(StringParser.Parse("${res:AddIns.HtmlHelp2.DefaultEmptyFilter}"));
}
if(currentSelectedFilterName == "") filterCombobox.SelectedIndex = 0; if (string.IsNullOrEmpty(currentSelectedFilterName))
else filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(currentSelectedFilterName); filterCombobox.SelectedIndex = 0;
else
filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(currentSelectedFilterName);
} }
catch(Exception ex) catch(Exception ex)
{ {
LoggingService.Error("Help 2.0: cannot build filters; " + ex.Message); LoggingService.Error("Help 2.0: Cannot build filters; " + ex.Message);
} }
filterCombobox.EndUpdate(); filterCombobox.EndUpdate();
@ -259,26 +279,47 @@ namespace HtmlHelp2.Environment
public static string FindFilterQuery(string filterName) public static string FindFilterQuery(string filterName)
{ {
if(String.Compare(filterName, currentSelectedFilterName) == 0) if (string.Compare(filterName, currentSelectedFilterName) == 0)
{
return currentSelectedFilterQuery; return currentSelectedFilterQuery;
}
try try
{ {
IHxRegFilter filter = namespaceFilters.FindFilter(filterName); IHxRegFilter filter = namespaceFilters.FindFilter(filterName);
currentSelectedFilterQuery = (string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery);
currentSelectedFilterName = filterName; currentSelectedFilterName = filterName;
currentSelectedFilterQuery =
(string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery);
OnFilterQueryChanged(EventArgs.Empty); OnFilterQueryChanged(EventArgs.Empty);
ReloadFTSSystem(); ReloadFTSSystem();
ReloadDynamicHelpSystem(); ReloadDynamicHelpSystem();
ReloadDefaultPages(); ReloadDefaultPages();
return currentSelectedFilterQuery; return currentSelectedFilterQuery;
} }
catch catch
{ {
return ""; return string.Empty;
} }
// try
// {
// IHxRegFilter filter = namespaceFilters.FindFilter(filterName);
// currentSelectedFilterQuery = (string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery);
// currentSelectedFilterName = filterName;
//
// OnFilterQueryChanged(EventArgs.Empty);
//
// ReloadFTSSystem();
// ReloadDynamicHelpSystem();
// ReloadDefaultPages();
// return currentSelectedFilterQuery;
// }
// catch
// {
// return "";
// }
} }
public static IHxTopicList GetMatchingTopicsForDynamicHelp(string searchTerm) public static IHxTopicList GetMatchingTopicsForDynamicHelp(string searchTerm)

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

@ -24,7 +24,7 @@ namespace HtmlHelp2.ResourcesHelperClass
public static Bitmap GetBitmap(string resourceName) public static Bitmap GetBitmap(string resourceName)
{ {
Assembly assembly = typeof(ResourcesHelper).Assembly; Assembly assembly = typeof(ResourcesHelper).Assembly;
string fullName = String.Format("HtmlHelp2.Resources.{0}", resourceName); string fullName = string.Format("HtmlHelp2.Resources.{0}", resourceName);
return new Bitmap(assembly.GetManifestResourceStream(fullName)); return new Bitmap(assembly.GetManifestResourceStream(fullName));
} }

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

@ -23,10 +23,6 @@ namespace HtmlHelp2.SharpDevLanguageClass
languages.Add("VBNet", "VB"); languages.Add("VBNet", "VB");
} }
SharpDevLanguage()
{
}
private static int DevLangCounter(IHxTopic topic) private static int DevLangCounter(IHxTopic topic)
{ {
try try

Loading…
Cancel
Save