From 8b6d51c13c56b448a3190b93b3032dce493da221 Mon Sep 17 00:00:00 2001 From: Nathan ziehnert Date: Tue, 21 Jul 2020 14:29:27 -0600 Subject: [PATCH 1/4] Strip comments from Imported XML Fix color import for uipp element - need to fix for other elements with color. --- UI++Editor/Controllers/XMLToClassModel.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/UI++Editor/Controllers/XMLToClassModel.cs b/UI++Editor/Controllers/XMLToClassModel.cs index 0faa74d..aeb2e9b 100644 --- a/UI++Editor/Controllers/XMLToClassModel.cs +++ b/UI++Editor/Controllers/XMLToClassModel.cs @@ -20,6 +20,13 @@ public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path) { UIpp uipp = new UIpp(); + // Strip Comments + XmlNodeList allComments = xmlDoc.SelectNodes("//comment()"); + foreach(XmlNode c in allComments) + { + c.ParentNode.RemoveChild(c); + } + // Set Attributes XmlElement uippNode = xmlDoc.DocumentElement; if (!string.IsNullOrEmpty(uippNode.GetAttribute("AlwaysOnTop"))) @@ -30,7 +37,16 @@ public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path) { uipp.AlwaysOnTop = true; } - uipp.Color = uippNode.GetAttribute("Color"); + + if (uippNode.GetAttribute("Color").StartsWith("#")) + { + uipp.Color = uippNode.GetAttribute("Color"); + } + else if(!string.IsNullOrEmpty(uippNode.GetAttribute("Color"))) + { + uipp.Color = "#" + uippNode.GetAttribute("Color"); + } + if (!string.IsNullOrEmpty(uippNode.GetAttribute("DialogSidebar"))) { uipp.DialogSidebar = Convert.ToBoolean(uippNode.GetAttribute("DialogSidebar")); From 22bd89fccd97f993e343f64623798b6d474d3a15 Mon Sep 17 00:00:00 2001 From: Nathan ziehnert Date: Tue, 21 Jul 2020 22:07:39 -0600 Subject: [PATCH 2/4] Fixed color import on all elements with a color --- UI++Editor/Controllers/XMLToClassModel.cs | 33 ++++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/UI++Editor/Controllers/XMLToClassModel.cs b/UI++Editor/Controllers/XMLToClassModel.cs index aeb2e9b..dd7ec4a 100644 --- a/UI++Editor/Controllers/XMLToClassModel.cs +++ b/UI++Editor/Controllers/XMLToClassModel.cs @@ -16,6 +16,20 @@ namespace UI__Editor.Controllers { public static class XMLToClassModel { + private static string ColorConverter(string s) + { + if(s.StartsWith("#")) + { return s; } + else if (!string.IsNullOrEmpty(s)) + { + return "#" + s; + } + else + { + return s; + } + } + public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path) { UIpp uipp = new UIpp(); @@ -37,16 +51,9 @@ public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path) { uipp.AlwaysOnTop = true; } - - if (uippNode.GetAttribute("Color").StartsWith("#")) - { - uipp.Color = uippNode.GetAttribute("Color"); - } - else if(!string.IsNullOrEmpty(uippNode.GetAttribute("Color"))) - { - uipp.Color = "#" + uippNode.GetAttribute("Color"); - } - + + uipp.Color = ColorConverter(uippNode.GetAttribute("Color")); + if (!string.IsNullOrEmpty(uippNode.GetAttribute("DialogSidebar"))) { uipp.DialogSidebar = Convert.ToBoolean(uippNode.GetAttribute("DialogSidebar")); @@ -262,9 +269,9 @@ private static IElement NewAction(XmlNode xmlNode, IElement parent = null) Image = importNode.GetAttribute("Image") }; if (!string.IsNullOrEmpty(importNode.GetAttribute("BackgroundColor"))) - infoFullScreen.BackgroundColor = importNode.GetAttribute("BackgroundColor"); + infoFullScreen.BackgroundColor = ColorConverter(importNode.GetAttribute("BackgroundColor")); if (!string.IsNullOrEmpty(importNode.GetAttribute("TextColor"))) - infoFullScreen.TextColor = importNode.GetAttribute("TextColor"); + infoFullScreen.TextColor = ColorConverter(importNode.GetAttribute("TextColor")); if (!string.IsNullOrEmpty(importNode.InnerXml)) { infoFullScreen.Content = CDATARemover(importNode.InnerXml); @@ -633,7 +640,7 @@ private static IElement NewAction(XmlNode xmlNode, IElement parent = null) Condition = importNode.GetAttribute("Condition") }; if (!string.IsNullOrEmpty(importNode.GetAttribute("Color"))) - inputInfo.Color = importNode.GetAttribute("Color"); + inputInfo.Color = ColorConverter(importNode.GetAttribute("Color")); if (int.TryParse(importNode.GetAttribute("DropDownSize"), out int inputInfoNumberOfLines)) inputInfo.NumberOfLines = inputInfoNumberOfLines; if (!string.IsNullOrEmpty(importNode.InnerXml)) From a949cfc7d409fd2ff2220a89da82f8697bc7314b Mon Sep 17 00:00:00 2001 From: Nathan ziehnert Date: Tue, 21 Jul 2020 22:32:48 -0600 Subject: [PATCH 3/4] Set default quote char in XML output to single quote --- UI++Editor/ViewModels/MainWindowViewModel.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UI++Editor/ViewModels/MainWindowViewModel.cs b/UI++Editor/ViewModels/MainWindowViewModel.cs index 6159b03..c53a4e4 100644 --- a/UI++Editor/ViewModels/MainWindowViewModel.cs +++ b/UI++Editor/ViewModels/MainWindowViewModel.cs @@ -182,7 +182,13 @@ private void SaveXML(string path) XmlNode importNode = xml.ImportNode(rootNode, true); xml.AppendChild(importNode); // add UIpp xml.InsertBefore(dec, importNode); // add the declaration - xml.Save(path); + using (XmlTextWriter xmlWriter = new XmlTextWriter(path, System.Text.Encoding.UTF8)) + { + xmlWriter.QuoteChar = '\''; + xmlWriter.Formatting = Formatting.Indented; + xml.Save(xmlWriter); + } + // xml.Save(path); } } } \ No newline at end of file From d99441df3f5f70ce8cf6778f9a5a258deb21db2f Mon Sep 17 00:00:00 2001 From: Nathan ziehnert Date: Tue, 21 Jul 2020 22:33:51 -0600 Subject: [PATCH 4/4] Increment version to 0.1.1.0-alpha --- UI++Editor/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI++Editor/Properties/AssemblyInfo.cs b/UI++Editor/Properties/AssemblyInfo.cs index 109970d..813c6cf 100644 --- a/UI++Editor/Properties/AssemblyInfo.cs +++ b/UI++Editor/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")]