Browse Source

Help 2.0: new config class used

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1515 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mathias Simmack 19 years ago
parent
commit
96471dd7c8
  1. 25
      src/AddIns/Misc/HtmlHelp2/Project/Resources/HtmlHelp2Options.xfrm
  2. 11
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs
  3. 64
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs
  4. 95
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs

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

@ -5,13 +5,13 @@
<Controls> <Controls>
<System.Windows.Forms.GroupBox> <System.Windows.Forms.GroupBox>
<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=124}" />
<TabIndex value="0" /> <TabIndex value="0" />
<Anchor value="Top, Left, Right" /> <Anchor value="Top, Left, Right" />
<Controls> <Controls>
<!-- <!-- ReRegisterButton
<System.Windows.Forms.Button> <System.Windows.Forms.Button>
<Name value="reregisterButton" /> <Name value="reregisterButton" />
<Location value="{X=73,Y=107}" /> <Location value="{X=73,Y=107}" />
@ -19,8 +19,7 @@
<Size value="{Width=204, Height=23}" /> <Size value="{Width=204, Height=23}" />
<Anchor value="Top" /> <Anchor value="Top" />
<TabIndex value="2" /> <TabIndex value="2" />
</System.Windows.Forms.Button> </System.Windows.Forms.Button> -->
-->
<System.Windows.Forms.ComboBox> <System.Windows.Forms.ComboBox>
<Name value="help2Collections" /> <Name value="help2Collections" />
<TabIndex value="1" /> <TabIndex value="1" />
@ -40,6 +39,24 @@
</System.Windows.Forms.Label> </System.Windows.Forms.Label>
</Controls> </Controls>
</System.Windows.Forms.GroupBox> </System.Windows.Forms.GroupBox>
<System.Windows.Forms.GroupBox>
<Name value="groupBox2" />
<Location value="{X=8, Y=145}" />
<Text value="${res:AddIns.HtmlHelp2.Options.AdditionOptions}" />
<Size value="{Width=344, Height=124}" />
<TabIndex value="1" />
<Anchor value="Top, Left, Right" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="tocPictures" />
<TabIndex value="0" />
<Anchor value="Top, Left, Right" />
<Size value="{Width=312, Height=45}" />
<Location value="{X=16, Y=15}" />
<Text value="${res:AddIns.HtmlHelp2.Options.ShowTocPictures}" />
</System.Windows.Forms.CheckBox>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls> </Controls>
</System.Windows.Forms.UserControl> </System.Windows.Forms.UserControl>
</Components> </Components>

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

@ -5,8 +5,6 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
//#define DExplore8Style_NoTOCPictures
namespace HtmlHelp2 namespace HtmlHelp2
{ {
using System; using System;
@ -22,6 +20,7 @@ namespace HtmlHelp2
using HtmlHelp2.ControlsValidation; using HtmlHelp2.ControlsValidation;
using HtmlHelp2.ResourcesHelperClass; using HtmlHelp2.ResourcesHelperClass;
using PrintOptions = MSHelpServices.HxHierarchy_PrintNode_Options; using PrintOptions = MSHelpServices.HxHierarchy_PrintNode_Options;
using TSC = MSHelpControls.HxTreeStyleConstant;
public class ShowTocMenuCommand : AbstractMenuCommand public class ShowTocMenuCommand : AbstractMenuCommand
@ -133,9 +132,8 @@ namespace HtmlHelp2
tocControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle; tocControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle;
tocControl.FontSource = HxFontSourceConstant.HxFontExternal; tocControl.FontSource = HxFontSourceConstant.HxFontExternal;
#if DExplore8StyleWithNoTocPictures tocControl.TreeStyle =
tocControl.TreeStyle = HxTreeStyleConstant.HxTreeStyle_TreelinesPlusMinusText; (HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText;
#endif
printTopic.Image = ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Print.bmp"); printTopic.Image = ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Print.bmp");
printTopic.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; printTopic.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
@ -321,6 +319,9 @@ namespace HtmlHelp2
private void NamespaceReloaded(object sender, EventArgs e) private void NamespaceReloaded(object sender, EventArgs e)
{ {
this.LoadToc(); this.LoadToc();
tocControl.TreeStyle =
(HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText;
} }
#endregion #endregion

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

@ -15,6 +15,7 @@ namespace HtmlHelp2.OptionsPanel
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Xml.Serialization;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using HtmlHelp2.Environment; using HtmlHelp2.Environment;
@ -23,9 +24,9 @@ namespace HtmlHelp2.OptionsPanel
public class HtmlHelp2OptionsPanel : AbstractOptionPanel public class HtmlHelp2OptionsPanel : AbstractOptionPanel
{ {
static string help2EnvironmentFile = "help2environment.xml"; ComboBox help2Collections = null;
ComboBox help2Collections = null; CheckBox tocPictures = null;
string selectedHelp2Collection = HtmlHelp2Environment.DefaultNamespaceName; string selectedHelp2Collection = HtmlHelp2Environment.DefaultNamespaceName;
public override void LoadPanelContents() public override void LoadPanelContents()
{ {
@ -46,10 +47,14 @@ namespace HtmlHelp2.OptionsPanel
{ {
try try
{ {
help2Collections = (ComboBox)ControlDictionary["help2Collections"]; help2Collections = (ComboBox)ControlDictionary["help2Collections"];
help2Collections.Enabled = HtmlHelp2Environment.IsReady; help2Collections.Enabled = HtmlHelp2Environment.IsReady;
help2Collections.SelectedIndexChanged += new EventHandler(this.NamespaceNameChanged); help2Collections.SelectedIndexChanged += new EventHandler(this.NamespaceNameChanged);
selectedHelp2Collection = HtmlHelp2Environment.CurrentSelectedNamespace; selectedHelp2Collection = HtmlHelp2Environment.CurrentSelectedNamespace;
tocPictures = (CheckBox)ControlDictionary["tocPictures"];
tocPictures.Enabled = HtmlHelp2Environment.IsReady;
tocPictures.Checked = HtmlHelp2Environment.Config.TocPictures;
Help2RegistryWalker.BuildNamespacesList(help2Collections, selectedHelp2Collection); Help2RegistryWalker.BuildNamespacesList(help2Collections, selectedHelp2Collection);
} }
@ -70,29 +75,9 @@ namespace HtmlHelp2.OptionsPanel
private void SaveHelp2Config() private void SaveHelp2Config()
{ {
if (selectedHelp2Collection.Length == 0) HtmlHelp2Environment.Config.SelectedCollection = selectedHelp2Collection;
{ HtmlHelp2Environment.Config.TocPictures = tocPictures.Checked;
return; HtmlHelp2Environment.SaveConfiguration();
}
try
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><help2environment/>");
XmlNode node = xmldoc.CreateElement("collection");
XmlCDataSection cdata = xmldoc.CreateCDataSection(selectedHelp2Collection);
node.AppendChild(cdata);
xmldoc.DocumentElement.AppendChild(node);
xmldoc.Save(Path.Combine(PropertyService.ConfigDirectory, help2EnvironmentFile));
LoggingService.Info("Help 2.0: new configuration saved");
}
catch
{
LoggingService.Error("Help 2.0: error while trying to save configuration");
}
} }
#region ReRegister #region ReRegister
@ -118,4 +103,25 @@ namespace HtmlHelp2.OptionsPanel
// } // }
#endregion #endregion
} }
[XmlRoot("help2environment")]
public class HtmlHelp2Options
{
private string selectedCollection = string.Empty;
private bool tocPictures = true;
[XmlElement("collection")]
public string SelectedCollection
{
get { return selectedCollection; }
set { selectedCollection = value; }
}
[XmlElement("tocpictures")]
public bool TocPictures
{
get { return tocPictures; }
set { tocPictures = value; }
}
}
} }

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

@ -11,14 +11,15 @@ namespace HtmlHelp2.Environment
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Xml.Serialization;
using ICSharpCode.Core; using ICSharpCode.Core;
using MSHelpServices; using MSHelpServices;
using HtmlHelp2.RegistryWalker; using HtmlHelp2.RegistryWalker;
using HtmlHelp2.HelperDialog; using HtmlHelp2.HelperDialog;
using HtmlHelp2.OptionsPanel;
public sealed class HtmlHelp2Environment public sealed class HtmlHelp2Environment
{ {
static string help2EnvironmentFile = "help2environment.xml";
static Guid TocGuid = new Guid("314111B2-A502-11D2-BBCA-00C04F8EC294"); static Guid TocGuid = new Guid("314111B2-A502-11D2-BBCA-00C04F8EC294");
static Guid IndexGuid = new Guid("314111CC-A502-11D2-BBCA-00C04F8EC294"); static Guid IndexGuid = new Guid("314111CC-A502-11D2-BBCA-00C04F8EC294");
static Guid QueryGuid = new Guid("31411193-A502-11D2-BBCA-00C04F8EC294"); static Guid QueryGuid = new Guid("31411193-A502-11D2-BBCA-00C04F8EC294");
@ -33,6 +34,8 @@ namespace HtmlHelp2.Environment
static string defaultPage = "about:blank"; static string defaultPage = "about:blank";
static string searchPage = "http://msdn.microsoft.com"; static string searchPage = "http://msdn.microsoft.com";
static bool dynamicHelpIsBusy = false; static bool dynamicHelpIsBusy = false;
static HtmlHelp2Options config = new HtmlHelp2Options();
static HtmlHelp2Environment() static HtmlHelp2Environment()
{ {
@ -81,29 +84,40 @@ namespace HtmlHelp2.Environment
{ {
get { return dynamicHelpIsBusy; } get { return dynamicHelpIsBusy; }
} }
public static HtmlHelp2Options Config
{
get { return config; }
}
#endregion #endregion
#region Namespace Functions #region Namespace Functions
private static void LoadHelp2Config() private static void LoadHelp2Config()
{ {
try LoadConfiguration();
{ if (!string.IsNullOrEmpty(config.SelectedCollection))
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"); 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()
@ -309,5 +323,52 @@ namespace HtmlHelp2.Environment
} }
} }
#endregion #endregion
#region Configuration
public static void LoadConfiguration()
{
try
{
string configFile =
Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
if(!File.Exists(configFile))
{
return;
}
XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options));
StreamReader file = new StreamReader(configFile);
config = (HtmlHelp2Options)serialize.Deserialize(file);
file.Close();
LoggingService.Info("Help 2.0: Configuration successfully loaded.");
}
catch
{
LoggingService.Error("Help 2.0: Error while trying to load configuration.");
}
}
public static void SaveConfiguration()
{
try
{
string configFile =
Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml");
XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options));
StreamWriter file = new StreamWriter(configFile);
serialize.Serialize(file, config);
file.Close();
LoggingService.Info("Help 2.0: Configuration successfully saved.");
}
catch
{
LoggingService.Error("Help 2.0: Error while trying to save configuration.");
}
}
#endregion
} }
} }

Loading…
Cancel
Save