Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions UI++Editor/Controllers/XMLToClassModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand All @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions UI++Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
8 changes: 7 additions & 1 deletion UI++Editor/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}