From 7ba01e91a95ce2e5436ba15462884476bfd014c5 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Fri, 29 May 2020 18:11:24 -0400 Subject: [PATCH] add TextBox implementation to New World Computing window layout definition file --- .../NewWorldComputing/BIN/BINDataFormat.cs | 33 +++++++++++++++++++ .../NWCSceneLayout/SceneObjectGuids.cs | 1 + .../NWCSceneLayout/ScenePropertyGuids.cs | 6 ++++ 3 files changed, 40 insertions(+) diff --git a/Plugins/UniversalEditor.Plugins.NewWorldComputing/DataFormats/NWCSceneLayout/NewWorldComputing/BIN/BINDataFormat.cs b/Plugins/UniversalEditor.Plugins.NewWorldComputing/DataFormats/NWCSceneLayout/NewWorldComputing/BIN/BINDataFormat.cs index 21c8d9d8..8c070408 100644 --- a/Plugins/UniversalEditor.Plugins.NewWorldComputing/DataFormats/NWCSceneLayout/NewWorldComputing/BIN/BINDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.NewWorldComputing/DataFormats/NWCSceneLayout/NewWorldComputing/BIN/BINDataFormat.cs @@ -57,6 +57,12 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN new Property(ScenePropertyGuids.Button.BackgroundImageFileName, "Background image file name"), new Property(ScenePropertyGuids.Button.BackgroundImageIndex, "Background image index") }, Button_Render)); + NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.TextBox, "Text box", new Property[] + { + new Property(ScenePropertyGuids.TextBox.BackgroundImageFileName, "Background image file name"), + new Property(ScenePropertyGuids.TextBox.BackgroundImageIndex, "Background image index"), + new Property(ScenePropertyGuids.TextBox.Text, "Text") + }, TextBox_Render)); NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.Image, "Image", new Property[] { new Property(ScenePropertyGuids.Image.BackgroundImageFileName, "Background image file name"), @@ -96,6 +102,25 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN } } + static void TextBox_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds) + { + Property propBackgroundImage = NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage]; + if (propBackgroundImage != null) + { + PropertyValue propVal = instance.PropertyValues[propBackgroundImage]; + if (propVal != null) + { + PictureObjectModel pic = propVal.Value as PictureObjectModel; + if (pic != null) + { + e.Graphics.DrawImage(pic.ToImage(), bounds.X, bounds.Y); + } + } + } + + PropertyValue pv = instance.PropertyValues[NWCSceneLayoutLibrary.Components[SceneObjectGuids.TextBox].Properties[ScenePropertyGuids.TextBox.Text]]; + e.Graphics.DrawText(pv?.Value?.ToString(), null, bounds.Location, new MBS.Framework.UserInterface.Drawing.SolidBrush(MBS.Framework.UserInterface.SystemColors.WindowForeground)); + } static void ListBox_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds) { Property propBackgroundImage = NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage]; @@ -237,6 +262,14 @@ namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN ushort u3a = reader.ReadUInt16(); ushort u4a = reader.ReadUInt16(); } + PictureObjectModel pic = LoadICN(icnFileName, 0); + + designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.TextBox], new Rectangle(x, y, width, height), new PropertyValue[] + { + new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.TextBox].Properties[ScenePropertyGuids.TextBox.Text], text), + new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.TextBox].Properties[ScenePropertyGuids.TextBox.BackgroundImageFileName], icnFileName), + new PropertyValue(NWCSceneLayoutLibrary.Components[DesignerObjectGuids.Common].Properties[DesignerPropertyGuids.Common.BackgroundImage], pic) + })); break; } case BINComponentType.ListBox: diff --git a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/SceneObjectGuids.cs b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/SceneObjectGuids.cs index cc630c5a..83edc671 100644 --- a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/SceneObjectGuids.cs +++ b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/SceneObjectGuids.cs @@ -28,5 +28,6 @@ namespace UniversalEditor.ObjectModels.NWCSceneLayout public static Guid Label { get; } = new Guid("{061ded85-99fd-43b0-b23d-e31c904ba397}"); public static Guid DropDownList { get; } = new Guid("{0fef5a86-c4e9-47b7-9d19-3e6d4e5b8d63}"); public static Guid ListBox { get; } = new Guid("{b9eb1120-5326-46b3-81a7-741f9b19d74f}"); + public static Guid TextBox { get; } = new Guid("{b3e34d63-9be9-4477-83d2-ed0c31d7e769}"); } } diff --git a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/ScenePropertyGuids.cs b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/ScenePropertyGuids.cs index 15190352..04c642f8 100644 --- a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/ScenePropertyGuids.cs +++ b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NWCSceneLayout/ScenePropertyGuids.cs @@ -43,5 +43,11 @@ namespace UniversalEditor.ObjectModels.NWCSceneLayout public static Guid BackgroundImageFileName { get; } = new Guid("{df3a8c45-a6bf-44d3-bf46-d8569e78bc71}"); public static Guid BackgroundImageIndex { get; } = new Guid("{e4226ed5-0ffa-468a-972f-146c934b0aa2}"); } + public static class TextBox + { + public static Guid BackgroundImageFileName { get; } = new Guid("{df3a8c45-a6bf-44d3-bf46-d8569e78bc71}"); + public static Guid BackgroundImageIndex { get; } = new Guid("{e4226ed5-0ffa-468a-972f-146c934b0aa2}"); + public static Guid Text { get; } = new Guid("{e8aeb0d6-a0fd-4f96-93b4-4a955953ce03}"); + } } }