Merge branch 'master' of github.com:alcexhim/UniversalEditor

This commit is contained in:
Michael Becker 2015-10-12 22:53:32 -04:00
commit 5eedc053df
11 changed files with 458 additions and 5 deletions

View File

@ -183,12 +183,14 @@ namespace UniversalEditor.Engines.WindowsForms
// AwesomeControls.Theming.BuiltinThemes.OfficeXPTheme theme = new AwesomeControls.Theming.BuiltinThemes.OfficeXPTheme();
// AwesomeControls.Theming.BuiltinThemes.SlickTheme theme = new AwesomeControls.Theming.BuiltinThemes.SlickTheme();
// Office 2000 = {105843D0-2F26-4CB7-86AB-10A449815C19}
// Office 2007 = {4D86F538-E277-4E6F-9CAC-60F82D49A19D}
// VS2012-Dark = {25134C94-B1EB-4C38-9B5B-A2E29FC57AE1}
// VS2012-Light = {54CE64B1-2DE3-4147-B499-03F0934AFD37}
// VS2012-Blue = {898A65FC-8D08-46F1-BB94-2BF666AC996E}
AwesomeControls.Theming.Theme theme = AwesomeControls.Theming.Theme.GetByID(new Guid("{54CE64B1-2DE3-4147-B499-03F0934AFD37}"));
// AwesomeControls.Theming.Theme theme = AwesomeControls.Theming.Theme.GetByID(new Guid("{54CE64B1-2DE3-4147-B499-03F0934AFD37}"));
AwesomeControls.Theming.Theme theme = AwesomeControls.Theming.Theme.GetByID(new Guid("{105843D0-2F26-4CB7-86AB-10A449815C19}"));
if (theme != null) AwesomeControls.Theming.Theme.CurrentTheme = theme;
// AwesomeControls.Theming.Theme.CurrentTheme.Properties["UseAllCapsMenus"] = false;

View File

@ -0,0 +1,59 @@
namespace UniversalEditor.Editors.Help
{
partial class TableOfContentsEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tv = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// tv
//
this.tv.Dock = System.Windows.Forms.DockStyle.Fill;
this.tv.Location = new System.Drawing.Point(0, 0);
this.tv.Name = "tv";
this.tv.Size = new System.Drawing.Size(388, 319);
this.tv.TabIndex = 0;
this.tv.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterCollapse);
this.tv.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterExpand);
//
// TableOfContentsEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tv);
this.Name = "TableOfContentsEditor";
this.Size = new System.Drawing.Size(388, 319);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TreeView tv;
}
}

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UniversalEditor.ObjectModels.Help.TableOfContents;
using UniversalEditor.UserInterface.WindowsForms;
namespace UniversalEditor.Editors.Help
{
public partial class TableOfContentsEditor : Editor
{
public TableOfContentsEditor()
{
InitializeComponent();
tv.ImageList = SmallImageList;
}
protected override void OnObjectModelChanged(EventArgs e)
{
base.OnObjectModelChanged(e);
tv.Nodes.Clear();
TableOfContentsObjectModel toc = (ObjectModel as TableOfContentsObjectModel);
if (toc == null) return;
foreach (TOCNode node in toc.Nodes)
{
LoadTOCNode(node, null);
}
}
private void LoadTOCNode(TOCNode node, TreeNode parentTreeNode)
{
TreeNode treeNode = new TreeNode();
treeNode.Text = node.Title;
treeNode.Tag = node;
treeNode.ImageKey = "generic-book-closed";
treeNode.SelectedImageKey = "generic-book-closed";
foreach (TOCNode node1 in node.Nodes)
{
LoadTOCNode(node1, treeNode);
}
if (parentTreeNode == null)
{
tv.Nodes.Add(treeNode);
}
else
{
parentTreeNode.Nodes.Add(treeNode);
}
}
private void tv_AfterCollapse(object sender, TreeViewEventArgs e)
{
if (e.Node == null) return;
if (e.Node.ImageKey == "generic-book-open")
{
e.Node.ImageKey = "generic-book-closed";
}
}
private void tv_AfterExpand(object sender, TreeViewEventArgs e)
{
if (e.Node == null) return;
if (e.Node.ImageKey == "generic-book-closed")
{
e.Node.ImageKey = "generic-book-open";
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -104,6 +104,12 @@
<Compile Include="Editors\FormattedTextEditor.Designer.cs">
<DependentUpon>FormattedTextEditor.cs</DependentUpon>
</Compile>
<Compile Include="Editors\Help\TableOfContentsEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Editors\Help\TableOfContentsEditor.Designer.cs">
<DependentUpon>TableOfContentsEditor.cs</DependentUpon>
</Compile>
<Compile Include="Editors\MarkupEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -203,6 +209,9 @@
<EmbeddedResource Include="Editors\FormattedTextEditor.resx">
<DependentUpon>FormattedTextEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editors\Help\TableOfContentsEditor.resx">
<DependentUpon>TableOfContentsEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editors\MarkupEditor.resx">
<DependentUpon>MarkupEditor.cs</DependentUpon>
</EmbeddedResource>

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.ObjectModels.Help.TableOfContents
{
public class TOCNode
{
public class TOCNodeCollection
: System.Collections.ObjectModel.Collection<TOCNode>
{
}
private string mvarLocation = String.Empty;
/// <summary>
/// The location of the Help topic pointed to by this <see cref="TOCNode" />.
/// </summary>
public string Location { get { return mvarLocation; } set { mvarLocation = value; } }
private string mvarTitle = String.Empty;
/// <summary>
/// The title of the Help topic pointed to by this <see cref="TOCNode" />.
/// </summary>
public string Title { get { return mvarTitle; } set { mvarTitle = value; } }
private TOCNode.TOCNodeCollection mvarNodes = new TOCNode.TOCNodeCollection();
public TOCNode.TOCNodeCollection Nodes { get { return mvarNodes; } }
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.ObjectModels.Help.TableOfContents
{
public class TableOfContentsObjectModel : ObjectModel
{
private static ObjectModelReference _omr = null;
protected override ObjectModelReference MakeReferenceInternal()
{
if (_omr == null)
{
_omr = base.MakeReferenceInternal();
_omr.Title = "Table of Contents";
_omr.Path = new string[] { "Help", "Table of Contents" };
}
return _omr;
}
private TOCNode.TOCNodeCollection mvarNodes = new TOCNode.TOCNodeCollection();
public TOCNode.TOCNodeCollection Nodes { get { return mvarNodes; } }
public override void Clear()
{
mvarNodes.Clear();
}
public override void CopyTo(ObjectModel where)
{
TableOfContentsObjectModel clone = (where as TableOfContentsObjectModel);
if (where == null) throw new ObjectModelNotSupportedException();
foreach (TOCNode node in mvarNodes)
{
clone.Nodes.Add(node);
}
}
}
}

View File

@ -105,6 +105,8 @@
<Compile Include="ObjectModels\FileSystem\IFileSystemContainer.cs" />
<Compile Include="ObjectModels\FileSystem\IFileSystemObject.cs" />
<Compile Include="ObjectModels\FileSystem\IFileSystemObjectType.cs" />
<Compile Include="ObjectModels\Help\TableOfContents\TableOfContentsObjectModel.cs" />
<Compile Include="ObjectModels\Help\TableOfContents\TOCNode.cs" />
<Compile Include="ObjectModels\Markup\MarkupAttribute.cs" />
<Compile Include="ObjectModels\Markup\MarkupCommentElement.cs" />
<Compile Include="ObjectModels\Markup\MarkupContainerElement.cs" />

View File

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversalEditor.DataFormats.Markup.XML;
using UniversalEditor.ObjectModels.Help.TableOfContents;
using UniversalEditor.ObjectModels.Markup;
namespace UniversalEditor.DataFormats.Help.TableOfContents.V3
{
public class H1TDataFormat : XMLDataFormat
{
private static DataFormatReference _dfr = null;
protected override DataFormatReference MakeReferenceInternal()
{
if (_dfr == null)
{
_dfr = new DataFormatReference(GetType());
_dfr.Capabilities.Add(typeof(TableOfContentsObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
protected override void BeforeLoadInternal(Stack<ObjectModel> objectModels)
{
base.BeforeLoadInternal(objectModels);
objectModels.Push(new MarkupObjectModel());
}
protected override void AfterLoadInternal(Stack<ObjectModel> objectModels)
{
base.AfterLoadInternal(objectModels);
MarkupObjectModel mom = (objectModels.Pop() as MarkupObjectModel);
TableOfContentsObjectModel toc = (objectModels.Pop() as TableOfContentsObjectModel);
if (toc == null) throw new ObjectModelNotSupportedException();
MarkupTagElement tagHelpTOC = (mom.Elements["HelpTOC"] as MarkupTagElement);
if (tagHelpTOC == null) throw new InvalidDataFormatException("File does not begin with top-level 'HelpTOC' element");
foreach (MarkupElement elNode in tagHelpTOC.Elements)
{
MarkupTagElement tagNode = (elNode as MarkupTagElement);
if (tagNode == null) continue;
if (tagNode.FullName != "HelpTOCNode") continue;
LoadHelpTOCNode(tagNode, toc.Nodes);
}
}
protected override void BeforeSaveInternal(Stack<ObjectModel> objectModels)
{
base.BeforeSaveInternal(objectModels);
TableOfContentsObjectModel toc = (objectModels.Pop() as TableOfContentsObjectModel);
if (toc == null) throw new ObjectModelNotSupportedException();
MarkupObjectModel mom = new MarkupObjectModel();
MarkupTagElement tagHelpTOC = new MarkupTagElement();
tagHelpTOC.FullName = "HelpTOC";
foreach (TOCNode node in toc.Nodes)
{
SaveHelpTOCNode(node, tagHelpTOC);
}
mom.Elements.Add(tagHelpTOC);
objectModels.Push(mom);
}
private void LoadHelpTOCNode(MarkupTagElement tag, TOCNode.TOCNodeCollection coll)
{
TOCNode node = new TOCNode();
MarkupAttribute attUrl = tag.Attributes["Url"];
if (attUrl != null) node.Location = attUrl.Value;
MarkupAttribute attTitle = tag.Attributes["Title"];
if (attTitle != null) node.Location = attTitle.Value;
foreach (MarkupElement el1 in tag.Elements)
{
MarkupTagElement tag1 = (el1 as MarkupTagElement);
if (tag1 == null) continue;
if (tag1.FullName != "HelpTOCNode") continue;
LoadHelpTOCNode(tag1, node.Nodes);
}
coll.Add(node);
}
private void SaveHelpTOCNode(TOCNode node, MarkupTagElement tag)
{
MarkupTagElement tag1 = new MarkupTagElement();
tag1.FullName = "HelpTOCNode";
tag1.Attributes.Add("Url", node.Location);
tag1.Attributes.Add("Title", node.Title);
foreach (TOCNode node1 in node.Nodes)
{
SaveHelpTOCNode(node1, tag1);
}
tag.Elements.Add(tag1);
}
}
}

View File

@ -60,6 +60,7 @@
<Compile Include="DataFormats\FileSystem\Microsoft\WindowsImage\WIMResourceHeaderDiskFlags.cs" />
<Compile Include="DataFormats\FileSystem\Microsoft\WindowsImage\WIMResourceHeaderDiskShort.cs" />
<Compile Include="DataFormats\FileSystem\Microsoft\WindowsImage\WIMStreamEntry.cs" />
<Compile Include="DataFormats\Help\TableOfContents\V3\H1TDataFormat.cs" />
<Compile Include="DataFormats\Shortcut\Microsoft\LNKDataFlags.cs" />
<Compile Include="DataFormats\Shortcut\Microsoft\LNKDataFormat.cs" />
<Compile Include="DataFormats\Shortcut\Microsoft\LNKFileAttributeFlags.cs" />

View File

@ -52,9 +52,6 @@
<Compile Include="DataFormats\NewWorldComputing\Save\Heroes4SaveDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\NewWorldComputing\Heroes3SNDDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\NewWorldComputing\Heroes3VIDDataFormat.cs" />
<Compile Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\BINContainerType.cs" />
<Compile Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\BINDataFormat.cs" />
<Compile Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\BINObjectType.cs" />
<Compile Include="HoMM2Palette.cs" />
<Compile Include="ObjectModels\NWCSceneLayout\NWCSceneLayoutObjectModel.cs" />
<Compile Include="ObjectModels\NewWorldComputing\Campaign\CampaignObjectModel.cs" />
@ -106,7 +103,9 @@
<ItemGroup>
<Compile Include="ObjectModels\NewWorldComputing\Map\MapLoseCondition.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.