diff --git a/UI++Editor/Controllers/XMLToClassModel.cs b/UI++Editor/Controllers/XMLToClassModel.cs index 0faa74d..dd7ec4a 100644 --- a/UI++Editor/Controllers/XMLToClassModel.cs +++ b/UI++Editor/Controllers/XMLToClassModel.cs @@ -16,10 +16,31 @@ 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(); + // 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 +51,9 @@ public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path) { uipp.AlwaysOnTop = true; } - uipp.Color = uippNode.GetAttribute("Color"); + + uipp.Color = ColorConverter(uippNode.GetAttribute("Color")); + if (!string.IsNullOrEmpty(uippNode.GetAttribute("DialogSidebar"))) { uipp.DialogSidebar = Convert.ToBoolean(uippNode.GetAttribute("DialogSidebar")); @@ -246,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); @@ -617,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)) 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")] 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