diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.Designer.cs b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.Designer.cs index f8a11655..71a5b3a0 100644 --- a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.Designer.cs +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.Designer.cs @@ -28,12 +28,30 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tv = new System.Windows.Forms.TreeView(); + this.mnuContextTreeView = new AwesomeControls.CommandBars.CBContextMenu(this.components); + this.mnuContextTreeViewAdd = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewAddNewItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewAddExistingItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewSep1 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuContextTreeViewExclude = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewSep2 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuContextTreeViewCut = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewCopy = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewPaste = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewDelete = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewRename = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuContextTreeViewSep3 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuContextTreeViewProperties = new System.Windows.Forms.ToolStripMenuItem(); this.lv = new System.Windows.Forms.ListView(); + this.imlSmallIcons = new System.Windows.Forms.ImageList(this.components); + this.imlLargeIcons = new System.Windows.Forms.ImageList(this.components); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); + this.mnuContextTreeView.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -56,12 +74,111 @@ // // tv // + this.tv.ContextMenuStrip = this.mnuContextTreeView; 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(205, 306); this.tv.TabIndex = 0; this.tv.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterSelect); + this.tv.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tv_MouseDown); + // + // mnuContextTreeView + // + this.mnuContextTreeView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuContextTreeViewAdd, + this.mnuContextTreeViewSep1, + this.mnuContextTreeViewExclude, + this.mnuContextTreeViewSep2, + this.mnuContextTreeViewCut, + this.mnuContextTreeViewCopy, + this.mnuContextTreeViewPaste, + this.mnuContextTreeViewDelete, + this.mnuContextTreeViewRename, + this.mnuContextTreeViewSep3, + this.mnuContextTreeViewProperties}); + this.mnuContextTreeView.Name = "mnuContextTreeView"; + this.mnuContextTreeView.Size = new System.Drawing.Size(190, 198); + this.mnuContextTreeView.Opening += new System.ComponentModel.CancelEventHandler(this.mnuContextTreeView_Opening); + // + // mnuContextTreeViewAdd + // + this.mnuContextTreeViewAdd.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuContextTreeViewAddNewItem, + this.mnuContextTreeViewAddExistingItem}); + this.mnuContextTreeViewAdd.Name = "mnuContextTreeViewAdd"; + this.mnuContextTreeViewAdd.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewAdd.Text = "A&dd"; + // + // mnuContextTreeViewAddNewItem + // + this.mnuContextTreeViewAddNewItem.Name = "mnuContextTreeViewAddNewItem"; + this.mnuContextTreeViewAddNewItem.Size = new System.Drawing.Size(152, 22); + this.mnuContextTreeViewAddNewItem.Text = "Ne&w Item..."; + // + // mnuContextTreeViewAddExistingItem + // + this.mnuContextTreeViewAddExistingItem.Name = "mnuContextTreeViewAddExistingItem"; + this.mnuContextTreeViewAddExistingItem.Size = new System.Drawing.Size(152, 22); + this.mnuContextTreeViewAddExistingItem.Text = "Existin&g Item..."; + // + // mnuContextTreeViewSep1 + // + this.mnuContextTreeViewSep1.Name = "mnuContextTreeViewSep1"; + this.mnuContextTreeViewSep1.Size = new System.Drawing.Size(186, 6); + // + // mnuContextTreeViewExclude + // + this.mnuContextTreeViewExclude.Name = "mnuContextTreeViewExclude"; + this.mnuContextTreeViewExclude.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewExclude.Text = "Exclude From Pro&ject"; + // + // mnuContextTreeViewSep2 + // + this.mnuContextTreeViewSep2.Name = "mnuContextTreeViewSep2"; + this.mnuContextTreeViewSep2.Size = new System.Drawing.Size(186, 6); + // + // mnuContextTreeViewCut + // + this.mnuContextTreeViewCut.Name = "mnuContextTreeViewCut"; + this.mnuContextTreeViewCut.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewCut.Text = "Cu&t"; + // + // mnuContextTreeViewCopy + // + this.mnuContextTreeViewCopy.Name = "mnuContextTreeViewCopy"; + this.mnuContextTreeViewCopy.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewCopy.Text = "&Copy"; + // + // mnuContextTreeViewPaste + // + this.mnuContextTreeViewPaste.Name = "mnuContextTreeViewPaste"; + this.mnuContextTreeViewPaste.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewPaste.Text = "&Paste"; + // + // mnuContextTreeViewDelete + // + this.mnuContextTreeViewDelete.Name = "mnuContextTreeViewDelete"; + this.mnuContextTreeViewDelete.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewDelete.Text = "&Delete"; + // + // mnuContextTreeViewRename + // + this.mnuContextTreeViewRename.Name = "mnuContextTreeViewRename"; + this.mnuContextTreeViewRename.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewRename.Text = "Rena&me"; + // + // mnuContextTreeViewSep3 + // + this.mnuContextTreeViewSep3.Name = "mnuContextTreeViewSep3"; + this.mnuContextTreeViewSep3.Size = new System.Drawing.Size(186, 6); + // + // mnuContextTreeViewProperties + // + this.mnuContextTreeViewProperties.Name = "mnuContextTreeViewProperties"; + this.mnuContextTreeViewProperties.ShortcutKeyDisplayString = "Alt+Enter"; + this.mnuContextTreeViewProperties.Size = new System.Drawing.Size(189, 22); + this.mnuContextTreeViewProperties.Text = "P&roperties..."; // // lv // @@ -72,6 +189,18 @@ this.lv.TabIndex = 0; this.lv.UseCompatibleStateImageBehavior = false; // + // imlSmallIcons + // + this.imlSmallIcons.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; + this.imlSmallIcons.ImageSize = new System.Drawing.Size(16, 16); + this.imlSmallIcons.TransparentColor = System.Drawing.Color.Transparent; + // + // imlLargeIcons + // + this.imlLargeIcons.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; + this.imlLargeIcons.ImageSize = new System.Drawing.Size(32, 32); + this.imlLargeIcons.TransparentColor = System.Drawing.Color.Transparent; + // // StoryEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -82,6 +211,7 @@ this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.ResumeLayout(false); + this.mnuContextTreeView.ResumeLayout(false); this.ResumeLayout(false); } @@ -91,5 +221,21 @@ private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.TreeView tv; private System.Windows.Forms.ListView lv; + private System.Windows.Forms.ImageList imlSmallIcons; + private System.Windows.Forms.ImageList imlLargeIcons; + private AwesomeControls.CommandBars.CBContextMenu mnuContextTreeView; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewAdd; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewAddNewItem; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewAddExistingItem; + private System.Windows.Forms.ToolStripSeparator mnuContextTreeViewSep1; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewProperties; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewCut; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewCopy; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewPaste; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewDelete; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewRename; + private System.Windows.Forms.ToolStripSeparator mnuContextTreeViewSep3; + private System.Windows.Forms.ToolStripMenuItem mnuContextTreeViewExclude; + private System.Windows.Forms.ToolStripSeparator mnuContextTreeViewSep2; } } diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.cs b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.cs index 6076e163..9170ad59 100644 --- a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.cs +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.cs @@ -14,6 +14,7 @@ namespace UniversalEditor.Editors public StoryEditor() { InitializeComponent(); + IconMethods.PopulateSystemIcons(ref imlSmallIcons); } protected override void OnObjectModelChanged(EventArgs e) @@ -24,23 +25,30 @@ namespace UniversalEditor.Editors tv.Nodes.Clear(); - TreeNode tnUniverse = tv.Nodes.Add("tnUniverse", "Universe", "generic-folder-closed"); - - TreeNode tnCharacters = tnUniverse.Nodes.Add("tnCharacters", "Characters", "generic-folder-closed"); - foreach (Character chara in story.Characters) + #region Universe { - TreeNode tn = new TreeNode(); - tn.Text = chara.Name; - tn.ImageKey = "character"; - tnCharacters.Nodes.Add(tn); + TreeNode tnUniverse = tv.Nodes.Add("tnUniverse", "Universe", "generic-folder-closed"); + + TreeNode tnCharacters = tnUniverse.Nodes.Add("tnCharacters", "Characters", "generic-folder-closed"); + foreach (Character chara in story.Characters) + { + TreeNode tn = new TreeNode(); + tn.Text = chara.Name.ToString(); + tn.ImageKey = "character"; + tnCharacters.Nodes.Add(tn); + } + + tnUniverse.Nodes.Add("tnDevices", "Devices", "generic-folder-closed"); + tnUniverse.Nodes.Add("tnLocations", "Locations", "generic-folder-closed"); + tnUniverse.Nodes.Add("tnOrganizations", "Organizations", "generic-folder-closed"); + tnUniverse.Nodes.Add("tnVehicles", "Vehicles", "generic-folder-closed"); } - - tnUniverse.Nodes.Add("tnDevices", "Devices", "generic-folder-closed"); - tnUniverse.Nodes.Add("tnLocations", "Locations", "generic-folder-closed"); - tnUniverse.Nodes.Add("tnOrganizations", "Organizations", "generic-folder-closed"); - tnUniverse.Nodes.Add("tnVehicles", "Vehicles", "generic-folder-closed"); - - tv.Nodes.Add("tnBooks", "Books", "generic-folder-closed"); + #endregion + #region Books + { + tv.Nodes.Add("tnBooks", "Books", "generic-folder-closed"); + } + #endregion tv.ExpandAll(); } @@ -49,5 +57,22 @@ namespace UniversalEditor.Editors { } + + private void mnuContextTreeView_Opening(object sender, CancelEventArgs e) + { + if (tv.SelectedNode.Tag is Chapter) + { + + } + } + + private void tv_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == System.Windows.Forms.MouseButtons.Right) + { + TreeNode tn = tv.HitTest(e.Location).Node; + if (tn != null) tv.SelectedNode = tn; + } + } } } diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.resx b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.resx index 7080a7d1..42816932 100644 --- a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.resx +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/Editors/StoryEditor.resx @@ -117,4 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 256, 8 + + + 15, 8 + + + 135, 8 + + + 38 + \ No newline at end of file diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/IconMethods.cs b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/IconMethods.cs new file mode 100644 index 00000000..563d35da --- /dev/null +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/IconMethods.cs @@ -0,0 +1,250 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; +using System.IO; + +internal static class IconMethods +{ + public enum IconSize + { + Large, + Small + } + private static class Internal + { + #region Old ExtractAssociatedIcon + public static HandleRef NullHandleRef = default(HandleRef); + [DllImport("shell32.dll", EntryPoint = "ExtractAssociatedIcon", CharSet = CharSet.Auto)] + public static extern IntPtr IntExtractAssociatedIcon(HandleRef hInst, StringBuilder iconPath, ref int index); + public static IntPtr ExtractAssociatedIcon(HandleRef hInst, StringBuilder iconPath, ref int index) + { + return IntExtractAssociatedIcon(hInst, iconPath, ref index); + } + #endregion + #region New ExtractIconEx + [DllImport("shell32.dll", EntryPoint = "ExtractIconEx")] + public static extern uint ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phiconLarge, IntPtr[] phiconSmall, uint nIcons); + + #endregion + } + + #region Old ExtractAssociatedIcon + private static Icon __ExtractAssociatedIcon(string filePath, int index) + { + Uri uri = null; + if ((filePath == null)) + { + throw new ArgumentException("Argument cannot be null.", "filePath"); + } + try + { + uri = new Uri(filePath); + } + catch (UriFormatException) + { + filePath = Path.GetFullPath(filePath); + uri = new Uri(filePath); + } + //If uri.IsUnc Then + // Throw New ArgumentException("File path cannot be a UNC path.", "filePath") + //End If + if (uri.IsFile | uri.IsUnc) + { + if (!File.Exists(filePath)) + { + throw new FileNotFoundException(filePath); + } + System.Text.StringBuilder iconPath = new System.Text.StringBuilder(260); + iconPath.Append(filePath); + IntPtr handle = Internal.ExtractAssociatedIcon(Internal.NullHandleRef, iconPath, ref index); + if ((handle != IntPtr.Zero)) + { + return Icon.FromHandle(handle); + } + } + return null; + } + #endregion + #region New ExtractIconEx + private static Icon __EIEExtractAssociatedIcon(string filePath, int index, IconSize size) + { + IntPtr[] phiconLarge = new IntPtr[] { IntPtr.Zero }; + IntPtr[] phiconSmall = new IntPtr[] { IntPtr.Zero }; + + Internal.ExtractIconEx(filePath, index, phiconLarge, phiconSmall, 1); + + switch (size) + { + case IconSize.Large: + try + { + return Icon.FromHandle(phiconLarge[0]); + } + catch (ArgumentException) + { + return null; + } + case IconSize.Small: + try + { + return Icon.FromHandle(phiconSmall[0]); + } + catch (ArgumentException) + { + return null; + } + } + return null; + } + #endregion + + public static Icon ExtractFileTypeIcon(string filePath) + { + string ext = System.IO.Path.GetExtension(filePath); + + string iconPath = String.Empty; + int iconIndex = 0; + + switch (System.Environment.OSVersion.Platform) + { + case PlatformID.MacOSX: + { + break; + } + case PlatformID.Unix: + { + break; + } + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + { + // TODO: Implement something that uses along the lines of MIME info + // specification + + /* + http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html + + + + + MS Word Files + + + + */ + + Microsoft.Win32.RegistryKey rkExt = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); + + string className = rkExt.GetValue(String.Empty, String.Empty).ToString(); + Microsoft.Win32.RegistryKey rkClass = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(className); + if (rkClass != null) + { + Microsoft.Win32.RegistryKey rkDefaultIcon = rkClass.OpenSubKey("DefaultIcon"); + if (rkDefaultIcon != null) + { + string defaultIconPath = rkDefaultIcon.GetValue(String.Empty, String.Empty).ToString(); + int splitIndex = defaultIconPath.LastIndexOf(','); + + string defaultIconFileName = defaultIconPath.Substring(0, splitIndex); + string defaultIconIndex = defaultIconPath.Substring(splitIndex + 1); + + Int32.TryParse(defaultIconIndex, out iconIndex); + if (defaultIconFileName.StartsWith("\"")) + { + defaultIconFileName = defaultIconFileName.Substring(1); + } + if (defaultIconFileName.EndsWith("\"")) + { + defaultIconFileName = defaultIconFileName.Substring(0, defaultIconFileName.Length - 1); + } + + iconPath = defaultIconFileName; + } + } + break; + } + } + + + Icon icon = ExtractAssociatedIcon(iconPath, iconIndex); + return icon; + } + + public static Icon ExtractAssociatedIcon(string filePath, int index = 0) + { + return ExtractAssociatedIcon(filePath, index, IconSize.Large); + } + public static Icon ExtractAssociatedIcon(string filePath, int index, IconSize size) + { + Icon icon = null; + switch (System.Environment.OSVersion.Platform) + { + case PlatformID.MacOSX: + // TODO: Mac OS X support? + break; + case PlatformID.Unix: + break; + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + icon = __EIEExtractAssociatedIcon(filePath, index, size); + break; + case PlatformID.Xbox: + break; + } + return icon; + } + + + public static void PopulateSystemIcons(ref System.Windows.Forms.ImageList iml) + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.MacOSX: + break; + case PlatformID.Unix: + break; + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + { + if (iml.ImageSize.Width == 16 && iml.ImageSize.Height == 16) + { + Icon iconFile = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconSize.Small); + iml.Images.Add("generic-file", iconFile); + Icon iconDocument = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconSize.Small); + iml.Images.Add("generic-document", iconDocument); + Icon iconApplication = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconSize.Small); + iml.Images.Add("generic-application", iconApplication); + Icon iconFolderClosed = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconSize.Small); + iml.Images.Add("generic-folder-closed", iconFolderClosed); + Icon iconFolderOpen = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconSize.Small); + iml.Images.Add("generic-folder-open", iconFolderOpen); + } + else + { + Icon iconFile = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 0, IconSize.Large); + iml.Images.Add("generic-file", iconFile); + Icon iconDocument = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 1, IconSize.Large); + iml.Images.Add("generic-document", iconDocument); + Icon iconApplication = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 2, IconSize.Large); + iml.Images.Add("generic-application", iconApplication); + Icon iconFolderClosed = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 3, IconSize.Large); + iml.Images.Add("generic-folder-closed", iconFolderClosed); + Icon iconFolderOpen = ExtractAssociatedIcon(Environment.GetFolderPath(Environment.SpecialFolder.System) + System.IO.Path.DirectorySeparatorChar + "shell32.dll", 4, IconSize.Large); + iml.Images.Add("generic-folder-open", iconFolderOpen); + } + return; + } + } + // throw new PlatformNotSupportedException(); + } +} \ No newline at end of file diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms.csproj b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms.csproj index 30d57cb9..f659d2af 100644 --- a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms.csproj +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms/UniversalEditor.Plugins.StoryWriter.UserInterface.WindowsForms.csproj @@ -31,8 +31,13 @@ 4 + + False + ..\..\..\..\..\..\AwesomeControls\bin\Debug\AwesomeControls.dll + + @@ -43,6 +48,7 @@ StoryEditor.cs + diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Author.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Author.cs new file mode 100644 index 00000000..0817ca27 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Author.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + public class Author : ICloneable + { + public class AuthorCollection + : System.Collections.ObjectModel.Collection + { + + } + + private PersonalName mvarName = null; + public PersonalName Name { get { return mvarName; } set { mvarName = value; } } + + public object Clone() + { + Author clone = new Author(); + if (mvarName != null) + { + clone.Name = (mvarName.Clone() as PersonalName); + } + return clone; + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Book.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Book.cs index 1653f74e..4b8b7ce8 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Book.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Book.cs @@ -5,7 +5,7 @@ using System.Text; namespace UniversalEditor.ObjectModels.StoryWriter.Story { - public class Book + public class Book : ICloneable { public class BookCollection : System.Collections.ObjectModel.Collection @@ -13,7 +13,28 @@ namespace UniversalEditor.ObjectModels.StoryWriter.Story } + private string mvarTitle = String.Empty; + public string Title { get { return mvarTitle; } set { mvarTitle = value; } } + + private Author.AuthorCollection mvarAuthors = new Author.AuthorCollection(); + public Author.AuthorCollection Authors { get { return mvarAuthors; } } + private Chapter.ChapterCollection mvarChapters = new Chapter.ChapterCollection(); public Chapter.ChapterCollection Chapters { get { return mvarChapters; } } + + public object Clone() + { + Book clone = new Book(); + clone.Title = (mvarTitle.Clone() as string); + foreach (Author author in mvarAuthors) + { + clone.Authors.Add(author); + } + foreach (Chapter chapter in mvarChapters) + { + clone.Chapters.Add(chapter.Clone() as Chapter); + } + return clone; + } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Chapter.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Chapter.cs index 28a87e13..916c1676 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Chapter.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Chapter.cs @@ -5,7 +5,7 @@ using System.Text; namespace UniversalEditor.ObjectModels.StoryWriter.Story { - public class Chapter + public class Chapter : ICloneable { public class ChapterCollection @@ -13,5 +13,25 @@ namespace UniversalEditor.ObjectModels.StoryWriter.Story { } + + private Guid mvarID = Guid.Empty; + public Guid ID { get { return mvarID; } set { mvarID = value; } } + + private string mvarTitle = String.Empty; + public string Title { get { return mvarTitle; } set { mvarTitle = value; } } + + private Section.SectionCollection mvarSections = new Section.SectionCollection(); + public Section.SectionCollection Sections { get { return mvarSections; } } + + public object Clone() + { + Chapter clone = new Chapter(); + clone.Title = (mvarTitle.Clone() as string); + foreach (Section section in mvarSections) + { + clone.Sections.Add(section.Clone() as Section); + } + return clone; + } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Character.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Character.cs index bc4c7a32..208f8b61 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Character.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Character.cs @@ -5,7 +5,7 @@ using System.Text; namespace UniversalEditor.ObjectModels.StoryWriter.Story { - public class Character + public class Character : ICloneable { public class CharacterCollection : System.Collections.ObjectModel.Collection @@ -13,60 +13,21 @@ namespace UniversalEditor.ObjectModels.StoryWriter.Story } - private string mvarGivenName = String.Empty; - public string GivenName { get { return mvarGivenName; } set { mvarGivenName = value; } } - - private string mvarMiddleName = String.Empty; - public string MiddleName { get { return mvarMiddleName; } set { mvarMiddleName = value; } } - - private string mvarFamilyName = String.Empty; - public string FamilyName { get { return mvarFamilyName; } set { mvarFamilyName = value; } } + private PersonalName mvarName = null; + public PersonalName Name { get { return mvarName; } set { mvarName = value; } } private Gender mvarGender = null; public Gender Gender { get { return mvarGender; } set { mvarGender = value; } } - public string Name + public object Clone() { - get + Character clone = new Character(); + if (mvarName != null) { - StringBuilder sb = new StringBuilder(); - sb.Append(mvarGivenName); - if (!String.IsNullOrEmpty(mvarMiddleName)) - { - sb.Append(" "); - sb.Append(mvarMiddleName); - } - if (!String.IsNullOrEmpty(mvarFamilyName)) - { - sb.Append(" "); - sb.Append(mvarFamilyName); - } - return sb.ToString(); - } - set - { - mvarGivenName = String.Empty; - mvarMiddleName = String.Empty; - mvarFamilyName = String.Empty; - - string[] values = value.Split(new char[] { ' ' }, 3); - if (values.Length > 0) - { - mvarGivenName = values[0]; - if (values.Length > 1) - { - if (values.Length > 2) - { - mvarMiddleName = values[1]; - mvarFamilyName = values[2]; - } - else - { - mvarFamilyName = values[1]; - } - } - } + clone.Name = (mvarName.Clone() as PersonalName); } + clone.Gender = mvarGender; + return clone; } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/ContentItem.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/ContentItem.cs new file mode 100644 index 00000000..7230e0b0 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/ContentItem.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + public abstract class ContentItem + { + protected abstract string RenderContent(); + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalName.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalName.cs new file mode 100644 index 00000000..1888afb6 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalName.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + public class PersonalName : ICloneable + { + private string mvarGivenName = String.Empty; + public string GivenName { get { return mvarGivenName; } set { mvarGivenName = value; } } + + private System.Collections.Specialized.StringCollection mvarMiddleNames = new System.Collections.Specialized.StringCollection(); + public System.Collections.Specialized.StringCollection MiddleNames { get { return mvarMiddleNames; } } + + private string mvarFamilyName = String.Empty; + public string FamilyName { get { return mvarFamilyName; } set { mvarFamilyName = value; } } + + private string mvarNickname = String.Empty; + public string Nickname { get { return mvarNickname; } set { mvarNickname = value; } } + + public PersonalName() + { + } + public PersonalName(string fullName) + { + Name = fullName; + } + public PersonalName(string givenName, string familyName) : this(givenName, String.Empty, familyName) + { + } + public PersonalName(string givenName, string middleName, string familyName) + { + mvarGivenName = givenName; + string[] mn = middleName.Split(new char[] { ' ' }); + foreach (string m in mn) + { + if (!String.IsNullOrEmpty(m)) mvarMiddleNames.Add(m); + } + mvarFamilyName = familyName; + } + + public string Name + { + get + { + StringBuilder sb = new StringBuilder(); + sb.Append(mvarGivenName); + foreach (string s in mvarMiddleNames) + { + sb.Append(" "); + sb.Append(s); + } + if (!String.IsNullOrEmpty(mvarFamilyName)) + { + sb.Append(" "); + sb.Append(mvarFamilyName); + } + return sb.ToString(); + } + set + { + string[] values = value.Split(new char[] { ' ' }); + StringBuilder sb = new StringBuilder(); + if (values.Length > 0) + { + sb.Append(values[0]); + if (values.Length > 2) + { + for (int i = 1; i < values.Length - 1; i++) + { + mvarMiddleNames.Add(values[i]); + } + } + if (values.Length > 1) + { + sb.Append(" "); + sb.Append(values[values.Length - 1]); + } + } + } + } + + public object Clone() + { + PersonalName clone = new PersonalName(); + clone.GivenName = (mvarGivenName.Clone() as string); + foreach (string s in mvarMiddleNames) + { + clone.MiddleNames.Add(s.Clone() as string); + } + clone.FamilyName = (mvarFamilyName.Clone() as string); + return clone; + } + + public override string ToString() + { + return Name; + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalNameReference.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalNameReference.cs new file mode 100644 index 00000000..e267a9a0 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/PersonalNameReference.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + public class PersonalNameReference : ContentItem + { + private PersonalName mvarValue = null; + public PersonalName Value { get { return mvarValue; } } + + private string mvarFormat = "{GivenName}"; + public string Format { get { return mvarFormat; } set { mvarFormat = value; } } + + protected override string RenderContent() + { + if (mvarValue == null) throw new NullReferenceException("Value cannot be null"); + return FormatString(mvarFormat, mvarValue); + } + + private static string FormatString(string format, PersonalName value) + { + string retval = format; + retval = retval.Replace("{GivenName}", value.GivenName); + retval = retval.Replace("{FamilyName}", value.FamilyName); + for (int i = 0; i < value.MiddleNames.Count; i++) + { + retval = retval.Replace("{MiddleName:" + i.ToString() + "}", value.MiddleNames[i]); + } + retval = retval.Replace("{Nickname}", value.Nickname); + return retval; + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Section.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Section.cs new file mode 100644 index 00000000..48231a5f --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Section.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + /// + /// Represents a section or a scene in a . + /// + public class Section : ICloneable + { + public class SectionCollection + : System.Collections.ObjectModel.Collection
+ { + + } + + private Guid mvarID = Guid.Empty; + public Guid ID { get { return mvarID; } set { mvarID = value; } } + + private string mvarTitle = String.Empty; + public string Title { get { return mvarTitle; } set { mvarTitle = value; } } + + public object Clone() + { + Section clone = new Section(); + clone.Title = (mvarTitle.Clone() as string); + return clone; + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/StoryObjectModel.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/StoryObjectModel.cs index 2702d256..007130c4 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/StoryObjectModel.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/StoryObjectModel.cs @@ -4,11 +4,19 @@ using System.Text; namespace UniversalEditor.ObjectModels.StoryWriter.Story { - public class StoryObjectModel + public class StoryObjectModel : ObjectModel { + private Universe mvarUniverse = new Universe(); + /// + /// The this story is set in. A Universe is a collection of characters and + /// other entities referenced in a story. + /// + public Universe Universe { get { return mvarUniverse; } } + private Character.CharacterCollection mvarCharacters = new Character.CharacterCollection(); /// - /// All the characters available to draw from within this story. + /// Characters introduced for this story only. Characters that can be used across stories should + /// be added to a . /// public Character.CharacterCollection Characters { get { return mvarCharacters; } } @@ -17,5 +25,24 @@ namespace UniversalEditor.ObjectModels.StoryWriter.Story /// The books collected in this story. /// public Book.BookCollection Books { get { return mvarBooks; } } + + public override void Clear() + { + mvarCharacters.Clear(); + mvarBooks.Clear(); + } + + public override void CopyTo(ObjectModel where) + { + StoryObjectModel clone = (where as StoryObjectModel); + foreach (Character chara in mvarCharacters) + { + clone.Characters.Add(chara.Clone() as Character); + } + foreach (Book book in mvarBooks) + { + clone.Books.Add(book.Clone() as Book); + } + } } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Universe.cs b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Universe.cs new file mode 100644 index 00000000..f93de4de --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/ObjectModels/StoryWriter/Story/Universe.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UniversalEditor.ObjectModels.StoryWriter.Story +{ + /// + /// Represents a universe, a collection of related elements in a particular story. + /// + public class Universe + { + private Character.CharacterCollection mvarCharacters = new Character.CharacterCollection(); + public Character.CharacterCollection Characters { get { return mvarCharacters; } } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/UniversalEditor.Plugins.StoryWriter.csproj b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/UniversalEditor.Plugins.StoryWriter.csproj index 7f93ed02..a89ae7fd 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/UniversalEditor.Plugins.StoryWriter.csproj +++ b/CSharp/Plugins/UniversalEditor.Plugins.StoryWriter/UniversalEditor.Plugins.StoryWriter.csproj @@ -36,11 +36,17 @@ + + + + + +