Skip to content

Commit 7440a9d

Browse files
authored
Merge pull request #8 from theznerd/0.1.1.0
0.1.1.0-alpha PR
2 parents 25de26c + d99441d commit 7440a9d

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

UI++Editor/Controllers/XMLToClassModel.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,31 @@ namespace UI__Editor.Controllers
1616
{
1717
public static class XMLToClassModel
1818
{
19+
private static string ColorConverter(string s)
20+
{
21+
if(s.StartsWith("#"))
22+
{ return s; }
23+
else if (!string.IsNullOrEmpty(s))
24+
{
25+
return "#" + s;
26+
}
27+
else
28+
{
29+
return s;
30+
}
31+
}
32+
1933
public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path)
2034
{
2135
UIpp uipp = new UIpp();
2236

37+
// Strip Comments
38+
XmlNodeList allComments = xmlDoc.SelectNodes("//comment()");
39+
foreach(XmlNode c in allComments)
40+
{
41+
c.ParentNode.RemoveChild(c);
42+
}
43+
2344
// Set Attributes
2445
XmlElement uippNode = xmlDoc.DocumentElement;
2546
if (!string.IsNullOrEmpty(uippNode.GetAttribute("AlwaysOnTop")))
@@ -30,7 +51,9 @@ public static UIpp GenerateUIpp(XmlDocument xmlDoc, string path)
3051
{
3152
uipp.AlwaysOnTop = true;
3253
}
33-
uipp.Color = uippNode.GetAttribute("Color");
54+
55+
uipp.Color = ColorConverter(uippNode.GetAttribute("Color"));
56+
3457
if (!string.IsNullOrEmpty(uippNode.GetAttribute("DialogSidebar")))
3558
{
3659
uipp.DialogSidebar = Convert.ToBoolean(uippNode.GetAttribute("DialogSidebar"));
@@ -246,9 +269,9 @@ private static IElement NewAction(XmlNode xmlNode, IElement parent = null)
246269
Image = importNode.GetAttribute("Image")
247270
};
248271
if (!string.IsNullOrEmpty(importNode.GetAttribute("BackgroundColor")))
249-
infoFullScreen.BackgroundColor = importNode.GetAttribute("BackgroundColor");
272+
infoFullScreen.BackgroundColor = ColorConverter(importNode.GetAttribute("BackgroundColor"));
250273
if (!string.IsNullOrEmpty(importNode.GetAttribute("TextColor")))
251-
infoFullScreen.TextColor = importNode.GetAttribute("TextColor");
274+
infoFullScreen.TextColor = ColorConverter(importNode.GetAttribute("TextColor"));
252275
if (!string.IsNullOrEmpty(importNode.InnerXml))
253276
{
254277
infoFullScreen.Content = CDATARemover(importNode.InnerXml);
@@ -617,7 +640,7 @@ private static IElement NewAction(XmlNode xmlNode, IElement parent = null)
617640
Condition = importNode.GetAttribute("Condition")
618641
};
619642
if (!string.IsNullOrEmpty(importNode.GetAttribute("Color")))
620-
inputInfo.Color = importNode.GetAttribute("Color");
643+
inputInfo.Color = ColorConverter(importNode.GetAttribute("Color"));
621644
if (int.TryParse(importNode.GetAttribute("DropDownSize"), out int inputInfoNumberOfLines))
622645
inputInfo.NumberOfLines = inputInfoNumberOfLines;
623646
if (!string.IsNullOrEmpty(importNode.InnerXml))

UI++Editor/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("0.1.0.0")]
55-
[assembly: AssemblyFileVersion("0.1.0.0")]
54+
[assembly: AssemblyVersion("0.1.1.0")]
55+
[assembly: AssemblyFileVersion("0.1.1.0")]

UI++Editor/ViewModels/MainWindowViewModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ private void SaveXML(string path)
182182
XmlNode importNode = xml.ImportNode(rootNode, true);
183183
xml.AppendChild(importNode); // add UIpp
184184
xml.InsertBefore(dec, importNode); // add the declaration
185-
xml.Save(path);
185+
using (XmlTextWriter xmlWriter = new XmlTextWriter(path, System.Text.Encoding.UTF8))
186+
{
187+
xmlWriter.QuoteChar = '\'';
188+
xmlWriter.Formatting = Formatting.Indented;
189+
xml.Save(xmlWriter);
190+
}
191+
// xml.Save(path);
186192
}
187193
}
188194
}

0 commit comments

Comments
 (0)