Browse Source

Help 2.0: rewritten code for the controls to support empty/broken collections without getting errors

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1526 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mathias Simmack 20 years ago
parent
commit
974286edc4
  1. 10
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs
  2. 112
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs
  3. 1
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexResultsPad.cs
  4. 52
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs
  5. 1
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs
  6. 150
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs
  7. 17
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs
  8. 29
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs
  9. 47
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs

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

@ -114,7 +114,7 @@ namespace HtmlHelp2
private bool CallDynamicHelp(string searchTerm, bool keywordSearch) private bool CallDynamicHelp(string searchTerm, bool keywordSearch)
{ {
if (!HtmlHelp2Environment.IsReady || HtmlHelp2Environment.DynamicHelpIsBusy) if (!HtmlHelp2Environment.SessionIsInitialized || HtmlHelp2Environment.DynamicHelpIsBusy)
{ {
return false; return false;
} }
@ -363,7 +363,6 @@ namespace HtmlHelp2
dynamicHelpToolbar.AllowItemReorder = false; dynamicHelpToolbar.AllowItemReorder = false;
dynamicHelpToolbar.ShowItemToolTips = false; dynamicHelpToolbar.ShowItemToolTips = false;
dynamicHelpToolbar.GripStyle = ToolStripGripStyle.Hidden; dynamicHelpToolbar.GripStyle = ToolStripGripStyle.Hidden;
dynamicHelpToolbar.Enabled = HtmlHelp2Environment.IsReady;
for (int i = 0; i < toolbarButtons.Length; i++) for (int i = 0; i < toolbarButtons.Length; i++)
{ {
ToolStripButton button = new ToolStripButton(); ToolStripButton button = new ToolStripButton();
@ -382,7 +381,7 @@ namespace HtmlHelp2
dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Index.png")); dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Index.png"));
dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Search.png")); dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Search.png"));
if (HtmlHelp2Environment.IsReady) if (HtmlHelp2Environment.SessionIsInitialized)
{ {
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded); HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
} }
@ -390,11 +389,6 @@ namespace HtmlHelp2
public void LoadDynamicHelpPage() public void LoadDynamicHelpPage()
{ {
if (!HtmlHelp2Environment.IsReady)
{
return;
}
string url = String.Format("res://{0}/context", Assembly.GetExecutingAssembly().Location); string url = String.Format("res://{0}/context", Assembly.GetExecutingAssembly().Location);
axWebBrowser.Navigate(url); axWebBrowser.Navigate(url);
} }

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

@ -61,9 +61,10 @@ namespace HtmlHelp2
ComboBox searchTerm = new ComboBox(); ComboBox searchTerm = new ComboBox();
Label label1 = new Label(); Label label1 = new Label();
Label label2 = new Label(); Label label2 = new Label();
Label infoLabel = new Label();
bool indexControlFailed = false;
bool itemClicked = false; bool itemClicked = false;
bool isEnabled = false;
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
@ -75,10 +76,47 @@ namespace HtmlHelp2
public MsHelp2IndexControl() public MsHelp2IndexControl()
{ {
this.isEnabled = (HtmlHelp2Environment.IsReady && this.InitializeComponents();
Help2ControlsValidation.IsIndexControlRegistered); this.UpdateControls();
HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
}
private void UpdateControls()
{
filterCombobox.Enabled =
(HtmlHelp2Environment.SessionIsInitialized && !this.indexControlFailed);
searchTerm.Enabled =
(HtmlHelp2Environment.SessionIsInitialized && !this.indexControlFailed);
infoLabel.Visible = false;
if (this.isEnabled) if (this.indexControlFailed)
{
this.ShowInfoMessage
(StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}"));
}
else if (!HtmlHelp2Environment.SessionIsInitialized)
{
if (indexControl != null) indexControl.Visible = false;
this.ShowInfoMessage
("${res:AddIns.HtmlHelp2.HelpCollectionMayBeEmpty}");
}
else
{
indexControl.Visible = true;
this.LoadIndex();
}
}
private void InitializeComponents()
{
infoLabel.Dock = DockStyle.Fill;
infoLabel.Visible = false;
infoLabel.TextAlign = ContentAlignment.MiddleCenter;
Controls.Add(infoLabel);
if (Help2ControlsValidation.IsIndexControlRegistered)
{ {
try try
{ {
@ -93,17 +131,18 @@ namespace HtmlHelp2
indexControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle; indexControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle;
indexControl.FontSource = HxFontSourceConstant.HxFontExternal; indexControl.FontSource = HxFontSourceConstant.HxFontExternal;
} }
catch (System.Runtime.InteropServices.COMException ex)
{
LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString());
this.indexControlFailed = true;
}
catch (Exception ex) catch (Exception ex)
{ {
LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString()); LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString());
this.FakeHelpControl(); this.indexControlFailed = true;
} }
} }
else
{
this.FakeHelpControl();
}
Panel panel1 = new Panel(); Panel panel1 = new Panel();
Controls.Add(panel1); Controls.Add(panel1);
panel1.Dock = DockStyle.Top; panel1.Dock = DockStyle.Top;
@ -113,14 +152,13 @@ namespace HtmlHelp2
filterCombobox.Dock = DockStyle.Top; filterCombobox.Dock = DockStyle.Top;
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = this.isEnabled; filterCombobox.Enabled = false;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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();
@ -130,7 +168,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 = false;
searchTerm.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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);
@ -138,30 +176,20 @@ namespace HtmlHelp2
Controls.Add(label2); Controls.Add(label2);
label2.Dock = DockStyle.Top; label2.Dock = DockStyle.Top;
label2.TextAlign = ContentAlignment.MiddleLeft; label2.TextAlign = ContentAlignment.MiddleLeft;
label2.Enabled = this.isEnabled;
label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent(); this.RedrawContent();
if (this.isEnabled) this.indexControlFailed = (this.indexControlFailed || indexControl == null);
{
HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
this.LoadIndex();
}
} }
private void FakeHelpControl() private void ShowInfoMessage(string infoText)
{ {
if (indexControl != null) indexControl.Dispose(); filterCombobox.Items.Clear();
indexControl = null; searchTerm.Items.Clear();
searchTerm.Text = string.Empty;
Controls.Clear(); infoLabel.Text = infoText;
Label nohelpLabel = new Label(); infoLabel.Visible = true;
nohelpLabel.Dock = DockStyle.Fill;
nohelpLabel.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}");
nohelpLabel.TextAlign = ContentAlignment.MiddleCenter;
Controls.Add(nohelpLabel);
} }
public void RedrawContent() public void RedrawContent()
@ -223,8 +251,7 @@ namespace HtmlHelp2
private void LoadIndex() private void LoadIndex()
{ {
this.SetIndex(HtmlHelp2Environment.CurrentFilterName); if (this.SetIndex(HtmlHelp2Environment.CurrentFilterName))
if (this.isEnabled)
{ {
searchTerm.Text = string.Empty; searchTerm.Text = string.Empty;
searchTerm.Items.Clear(); searchTerm.Items.Clear();
@ -234,24 +261,18 @@ namespace HtmlHelp2
} }
} }
private void SetIndex(string filterName) private bool SetIndex(string filterName)
{ {
if (!this.isEnabled) return;
try try
{ {
indexControl.IndexData = indexControl.IndexData =
HtmlHelp2Environment.GetIndex(HtmlHelp2Environment.FindFilterQuery(filterName)); HtmlHelp2Environment.GetIndex(HtmlHelp2Environment.FindFilterQuery(filterName));
return true;
} }
catch catch
{ {
this.isEnabled = false;
indexControl.Enabled = false;
indexControl.BackColor = SystemColors.ButtonFace;
filterCombobox.Enabled = false;
searchTerm.Enabled = false;
label1.Enabled = false;
label2.Enabled = false;
LoggingService.Error("Help 2.0: cannot connect to IHxIndex interface (Index)"); LoggingService.Error("Help 2.0: cannot connect to IHxIndex interface (Index)");
return false;
} }
} }
@ -325,13 +346,8 @@ namespace HtmlHelp2
private void NamespaceReloaded(object sender, EventArgs e) private void NamespaceReloaded(object sender, EventArgs e)
{ {
this.LoadIndex(); this.UpdateControls();
} }
#endregion #endregion
public bool IsEnabled
{
get { return this.isEnabled; }
}
} }
} }

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

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

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

@ -79,6 +79,27 @@ namespace HtmlHelp2
public HtmlHelp2SearchPad() public HtmlHelp2SearchPad()
{ {
this.InitializeComponents(); this.InitializeComponents();
this.UpdateControls();
HtmlHelp2Environment.FilterQueryChanged += new EventHandler(FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(NamespaceReloaded);
ProjectService.SolutionLoaded += this.SolutionLoaded;
ProjectService.SolutionClosed += this.SolutionUnloaded;
}
private void UpdateControls()
{
titlesOnly.Enabled = HtmlHelp2Environment.SessionIsInitialized;
enableStemming.Enabled = HtmlHelp2Environment.SessionIsInitialized;
hiliteTopics.Enabled = HtmlHelp2Environment.SessionIsInitialized;
useCurrentLang.Enabled = HtmlHelp2Environment.SessionIsInitialized;
filterCombobox.Enabled = HtmlHelp2Environment.SessionIsInitialized;
searchTerm.Enabled = HtmlHelp2Environment.SessionIsInitialized;
searchTerm.Text = string.Empty;
searchTerm.Items.Clear();
filterCombobox.Items.Clear();
} }
private void InitializeComponents() private void InitializeComponents()
@ -102,13 +123,11 @@ namespace HtmlHelp2
titlesOnly.Width = pw; titlesOnly.Width = pw;
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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); enableStemming.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
reuseMatches.Width = pw; reuseMatches.Width = pw;
@ -120,14 +139,12 @@ namespace HtmlHelp2
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.Checked = true; hiliteTopics.Checked = true;
hiliteTopics.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.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))); useCurrentLang.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -142,22 +159,18 @@ namespace HtmlHelp2
filterCombobox.Dock = DockStyle.Top; filterCombobox.Dock = DockStyle.Top;
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = HtmlHelp2Environment.IsReady;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.SessionIsInitialized)
{ {
HtmlHelp2Environment.BuildFilterList(filterCombobox); HtmlHelp2Environment.BuildFilterList(filterCombobox);
HtmlHelp2Environment.FilterQueryChanged += new EventHandler(FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(NamespaceReloaded);
} }
// Filter label // Filter label
mainPanel.Controls.Add(label1); mainPanel.Controls.Add(label1);
label1.Dock = DockStyle.Top; label1.Dock = DockStyle.Top;
label1.TextAlign = ContentAlignment.MiddleLeft; label1.TextAlign = ContentAlignment.MiddleLeft;
label1.Enabled = HtmlHelp2Environment.IsReady;
label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
// SearchTerm Combobox // SearchTerm Combobox
@ -169,19 +182,15 @@ namespace HtmlHelp2
searchTerm.Dock = DockStyle.Top; searchTerm.Dock = DockStyle.Top;
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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RedrawContent(); this.RedrawContent();
ProjectService.SolutionLoaded += this.SolutionLoaded;
ProjectService.SolutionClosed += this.SolutionUnloaded;
} }
private void FilterChanged(object sender, EventArgs e) private void FilterChanged(object sender, EventArgs e)
@ -210,11 +219,14 @@ namespace HtmlHelp2
private void NamespaceReloaded(object sender, EventArgs e) private void NamespaceReloaded(object sender, EventArgs e)
{ {
searchTerm.Text = ""; this.UpdateControls();
searchTerm.Items.Clear();
filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged); if (HtmlHelp2Environment.SessionIsInitialized)
HtmlHelp2Environment.BuildFilterList(filterCombobox); {
filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged); filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged);
HtmlHelp2Environment.BuildFilterList(filterCombobox);
filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged);
}
} }
#endregion #endregion
@ -260,7 +272,7 @@ namespace HtmlHelp2
private void PerformFTS(string searchWord, bool useDynamicHelp) private void PerformFTS(string searchWord, bool useDynamicHelp)
{ {
if (!HtmlHelp2Environment.IsReady || string.IsNullOrEmpty(searchWord) || searchIsBusy) if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(searchWord) || searchIsBusy)
{ {
return; return;
} }
@ -344,7 +356,7 @@ namespace HtmlHelp2
public bool PerformF1FTS(string keyword, bool useDynamicHelp) public bool PerformF1FTS(string keyword, bool useDynamicHelp)
{ {
if (!HtmlHelp2Environment.IsReady || string.IsNullOrEmpty(keyword) || searchIsBusy) if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(keyword) || searchIsBusy)
{ {
return false; return false;
} }

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

@ -63,7 +63,6 @@ namespace HtmlHelp2
listView.FullRowSelect = true; listView.FullRowSelect = true;
listView.AutoArrange = true; listView.AutoArrange = true;
listView.Enabled = HtmlHelp2Environment.IsReady;
listView.Alignment = ListViewAlignment.Left; listView.Alignment = ListViewAlignment.Left;
listView.View = View.Details; listView.View = View.Details;
listView.Dock = DockStyle.Fill; listView.Dock = DockStyle.Fill;

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

@ -97,10 +97,11 @@ namespace HtmlHelp2
AxHxTocCtrl tocControl = null; AxHxTocCtrl tocControl = null;
ComboBox filterCombobox = new ComboBox(); ComboBox filterCombobox = new ComboBox();
Label label1 = new Label(); Label label1 = new Label();
Label infoLabel = new Label();
ContextMenuStrip printContextMenu = new ContextMenuStrip(); ContextMenuStrip printContextMenu = new ContextMenuStrip();
ToolStripMenuItem printTopic = new ToolStripMenuItem(); ToolStripMenuItem printTopic = new ToolStripMenuItem();
ToolStripMenuItem printTopicAndSubTopics = new ToolStripMenuItem(); ToolStripMenuItem printTopicAndSubTopics = new ToolStripMenuItem();
bool isEnabled = false; bool tocControlFailed = false;
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
@ -113,9 +114,45 @@ namespace HtmlHelp2
public MsHelp2TocControl() public MsHelp2TocControl()
{ {
this.isEnabled = (HtmlHelp2Environment.IsReady && Help2ControlsValidation.IsTocControlRegistered); this.InitializeComponents();
this.UpdateControl();
if (this.isEnabled) HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
}
private void UpdateControl()
{
filterCombobox.Enabled =
(HtmlHelp2Environment.SessionIsInitialized && !this.tocControlFailed);
infoLabel.Visible = false;
if (this.tocControlFailed)
{
this.ShowInfoMessage
(StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}"));
}
else if (!HtmlHelp2Environment.SessionIsInitialized)
{
if (tocControl != null) tocControl.Visible = false;
this.ShowInfoMessage
("${res:AddIns.HtmlHelp2.HelpCollectionMayBeEmpty}");
}
else
{
tocControl.Visible = true;
this.LoadToc();
}
}
private void InitializeComponents()
{
infoLabel.Dock = DockStyle.Fill;
infoLabel.Visible = false;
infoLabel.TextAlign = ContentAlignment.MiddleCenter;
Controls.Add(infoLabel);
if (Help2ControlsValidation.IsTocControlRegistered)
{ {
try try
{ {
@ -129,34 +166,35 @@ namespace HtmlHelp2
tocControl.EndInit(); tocControl.EndInit();
Controls.Add(tocControl); Controls.Add(tocControl);
tocControl.CreateControl(); tocControl.CreateControl();
tocControl.Visible = false;
tocControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle; tocControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle;
tocControl.FontSource = HxFontSourceConstant.HxFontExternal; tocControl.FontSource = HxFontSourceConstant.HxFontExternal;
tocControl.TreeStyle = tocControl.TreeStyle =
(HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText; (HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText;
printTopic.Image = ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Print.bmp"); printTopic.Image = ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Print.bmp");
printTopic.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; printTopic.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
printTopic.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintTopic}"); printTopic.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintTopic}");
printTopic.Click += new EventHandler(this.PrintTopic); printTopic.Click += new EventHandler(this.PrintTopic);
printContextMenu.Items.Add(printTopic); printContextMenu.Items.Add(printTopic);
printTopicAndSubTopics.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintSubtopics}"); printTopicAndSubTopics.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintSubtopics}");
printTopicAndSubTopics.Click += new EventHandler(this.PrintTopicAndSubTopics); printTopicAndSubTopics.Click += new EventHandler(this.PrintTopicAndSubTopics);
printContextMenu.Items.Add(printTopicAndSubTopics); printContextMenu.Items.Add(printTopicAndSubTopics);
} }
catch (System.Runtime.InteropServices.COMException cEx)
{
LoggingService.Error("Help 2.0: TOC control failed: " + cEx.ToString());
this.tocControlFailed = true;
}
catch(Exception ex) catch(Exception ex)
{ {
LoggingService.Error("Help 2.0: TOC control failed; " + ex.ToString()); LoggingService.Error("Help 2.0: TOC control failed; " + ex.ToString());
this.isEnabled = false; this.tocControlFailed = true;
this.FakeHelpControl();
} }
} }
else
{
this.FakeHelpControl();
}
Panel panel1 = new Panel(); Panel panel1 = new Panel();
Controls.Add(panel1); Controls.Add(panel1);
panel1.Dock = DockStyle.Top; panel1.Dock = DockStyle.Top;
@ -166,36 +204,24 @@ namespace HtmlHelp2
filterCombobox.Dock = DockStyle.Top; filterCombobox.Dock = DockStyle.Top;
filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
filterCombobox.Sorted = true; filterCombobox.Sorted = true;
filterCombobox.Enabled = this.isEnabled; filterCombobox.Enabled = false;
filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 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) this.tocControlFailed = (this.tocControlFailed || tocControl == null);
{
HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged);
HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded);
this.LoadToc();
}
} }
private void FakeHelpControl() private void ShowInfoMessage(string infoText)
{ {
if (tocControl != null) tocControl.Dispose(); filterCombobox.Items.Clear();
tocControl = null; infoLabel.Text = infoText;
infoLabel.Visible = true;
Controls.Clear();
Label nohelpLabel = new Label();
nohelpLabel.Dock = DockStyle.Fill;
nohelpLabel.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}");
nohelpLabel.TextAlign = ContentAlignment.MiddleCenter;
Controls.Add(nohelpLabel);
} }
public void RedrawContent() public void RedrawContent()
@ -244,7 +270,6 @@ namespace HtmlHelp2
tocControl.Hierarchy.PrintNode(0, tocControl.Selection, PrintOptions.HxHierarchy_PrintNode_Option_Children); tocControl.Hierarchy.PrintNode(0, tocControl.Selection, PrintOptions.HxHierarchy_PrintNode_Option_Children);
} }
} }
#endregion #endregion
private void FilterChanged(object sender, EventArgs e) private void FilterChanged(object sender, EventArgs e)
@ -260,8 +285,7 @@ namespace HtmlHelp2
private void LoadToc() private void LoadToc()
{ {
this.SetToc(HtmlHelp2Environment.CurrentFilterName); if (this.SetToc(HtmlHelp2Environment.CurrentFilterName))
if (this.isEnabled)
{ {
filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged); filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged);
HtmlHelp2Environment.BuildFilterList(filterCombobox); HtmlHelp2Environment.BuildFilterList(filterCombobox);
@ -269,22 +293,18 @@ namespace HtmlHelp2
} }
} }
private void SetToc(string filterName) private bool SetToc(string filterName)
{ {
if (!this.isEnabled) return;
try try
{ {
tocControl.Hierarchy = tocControl.Hierarchy =
HtmlHelp2Environment.GetTocHierarchy(HtmlHelp2Environment.FindFilterQuery(filterName)); HtmlHelp2Environment.GetTocHierarchy(HtmlHelp2Environment.FindFilterQuery(filterName));
return true;
} }
catch catch
{ {
this.isEnabled = false; LoggingService.Error("Help 2.0: Cannot connect to the IHxHierarchy interface.");
tocControl.Enabled = false; return false;
tocControl.BackColor = SystemColors.ButtonFace;
filterCombobox.Enabled = false;
label1.Enabled = false;
LoggingService.Error("Help 2.0: cannot connect to IHxHierarchy interface (Contents)");
} }
} }
@ -320,8 +340,8 @@ namespace HtmlHelp2
private void NamespaceReloaded(object sender, EventArgs e) private void NamespaceReloaded(object sender, EventArgs e)
{ {
this.LoadToc(); this.UpdateControl();
tocControl.TreeStyle = tocControl.TreeStyle =
(HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText; (HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText;
} }
@ -330,7 +350,6 @@ namespace HtmlHelp2
#region Published Help 2.0 Commands #region Published Help 2.0 Commands
public void SynchronizeToc(string topicUrl) public void SynchronizeToc(string topicUrl)
{ {
if (!this.isEnabled) return;
try try
{ {
tocControl.Synchronize(topicUrl); tocControl.Synchronize(topicUrl);
@ -343,15 +362,23 @@ namespace HtmlHelp2
public void GetNextFromNode() public void GetNextFromNode()
{ {
if (!this.isEnabled) return; try
int currentNode = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection); {
string topicUrl = tocControl.Hierarchy.GetURL(currentNode); int currentNode = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection);
this.CallHelp(topicUrl, true); string topicUrl = tocControl.Hierarchy.GetURL(currentNode);
this.CallHelp(topicUrl, true);
}
catch (System.Runtime.InteropServices.COMException)
{
}
catch
{
}
} }
public void GetNextFromUrl(string url) public void GetNextFromUrl(string url)
{ {
if (!this.isEnabled || url == null || url.Length == 0) return; if (url == null || url.Length == 0) return;
try try
{ {
int currentNode = tocControl.Hierarchy.GetNextFromUrl(url); int currentNode = tocControl.Hierarchy.GetNextFromUrl(url);
@ -369,15 +396,23 @@ namespace HtmlHelp2
public void GetPrevFromNode() public void GetPrevFromNode()
{ {
if (!this.isEnabled) return; try
int currentNode = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection); {
string topicUrl = tocControl.Hierarchy.GetURL(currentNode); int currentNode = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection);
this.CallHelp(topicUrl, true); string topicUrl = tocControl.Hierarchy.GetURL(currentNode);
this.CallHelp(topicUrl, true);
}
catch (System.Runtime.InteropServices.COMException)
{
}
catch
{
}
} }
public void GetPrevFromUrl(string url) public void GetPrevFromUrl(string url)
{ {
if (!this.isEnabled || url == null || url.Length == 0) return; if (url == null || url.Length == 0) return;
try try
{ {
int currentNode = tocControl.Hierarchy.GetPrevFromUrl(url); int currentNode = tocControl.Hierarchy.GetPrevFromUrl(url);
@ -424,11 +459,6 @@ namespace HtmlHelp2
} }
} }
} }
public bool IsEnabled
{
get { return this.isEnabled; }
}
#endregion #endregion
} }
} }

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

@ -15,14 +15,15 @@ namespace HtmlHelp2.RegistryWalker
public sealed class Help2RegistryWalker public sealed class Help2RegistryWalker
{ {
public static void BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection) public static bool BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection)
{ {
if (help2Collections == null) if (help2Collections == null)
{ {
return; return false;
} }
help2Collections.Items.Clear(); help2Collections.Items.Clear();
help2Collections.BeginUpdate(); help2Collections.BeginUpdate();
bool result = true;
try try
{ {
@ -36,7 +37,7 @@ namespace HtmlHelp2.RegistryWalker
((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription)); ((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription));
if (!string.IsNullOrEmpty(selectedHelp2Collection) && if (!string.IsNullOrEmpty(selectedHelp2Collection) &&
string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0) string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0)
{ {
currentDescription = currentDescription =
(string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription); (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription);
@ -48,12 +49,16 @@ namespace HtmlHelp2.RegistryWalker
else else
help2Collections.SelectedIndex = 0; help2Collections.SelectedIndex = 0;
} }
catch(Exception ex) catch
{
result = false;
}
finally
{ {
LoggingService.Error("Help 2.0: Cannot build namespaces list;", ex); help2Collections.EndUpdate();
} }
help2Collections.EndUpdate(); return result;
} }
public static string GetNamespaceName(string description) public static string GetNamespaceName(string description)

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

@ -24,11 +24,12 @@ namespace HtmlHelp2.OptionsPanel
{ {
ComboBox help2Collections = null; ComboBox help2Collections = null;
CheckBox tocPictures = null; CheckBox tocPictures = null;
string selectedHelp2Collection = HtmlHelp2Environment.DefaultNamespaceName; string selectedHelp2Collection = string.Empty;
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"));
this.InitializeComponents(); this.InitializeComponents();
} }
@ -41,22 +42,18 @@ namespace HtmlHelp2.OptionsPanel
private void InitializeComponents() private void InitializeComponents()
{ {
try selectedHelp2Collection = HtmlHelp2Environment.CurrentSelectedNamespace;
{
help2Collections = (ComboBox)ControlDictionary["help2Collections"];
help2Collections.Enabled = HtmlHelp2Environment.IsReady;
help2Collections.SelectedIndexChanged += new EventHandler(this.NamespaceNameChanged);
selectedHelp2Collection = HtmlHelp2Environment.CurrentSelectedNamespace;
tocPictures = (CheckBox)ControlDictionary["tocPictures"]; help2Collections = (ComboBox)ControlDictionary["help2Collections"];
tocPictures.Enabled = HtmlHelp2Environment.IsReady; help2Collections.SelectedIndexChanged += new EventHandler(this.NamespaceNameChanged);
tocPictures.Checked = HtmlHelp2Environment.Config.TocPictures;
tocPictures = (CheckBox)ControlDictionary["tocPictures"];
Help2RegistryWalker.BuildNamespacesList(help2Collections, selectedHelp2Collection); tocPictures.Checked = HtmlHelp2Environment.Config.TocPictures;
}
catch(Exception ex) if (!Help2RegistryWalker.BuildNamespacesList(help2Collections, selectedHelp2Collection))
{ {
LoggingService.Error("Help 2.0: Cannot initialize options panel; " + ex.Message); help2Collections.Enabled = false;
tocPictures.Enabled = false;
} }
} }

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

@ -45,7 +45,7 @@ namespace HtmlHelp2.Environment
} }
#region Properties #region Properties
public static bool IsReady public static bool SessionIsInitialized
{ {
get { return session != null; } get { return session != null; }
} }
@ -195,34 +195,6 @@ namespace HtmlHelp2.Environment
{ {
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)
@ -303,23 +275,6 @@ namespace HtmlHelp2.Environment
{ {
return string.Empty; 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)

Loading…
Cancel
Save