diff --git a/ZuneUIXTools/Images/BuildSolution_16x.png b/ZuneUIXTools/Images/BuildSolution_16x.png
new file mode 100644
index 0000000..0f289bc
Binary files /dev/null and b/ZuneUIXTools/Images/BuildSolution_16x.png differ
diff --git a/ZuneUIXTools/Images/OpenProject_16x.png b/ZuneUIXTools/Images/OpenProject_16x.png
new file mode 100644
index 0000000..f85e98d
Binary files /dev/null and b/ZuneUIXTools/Images/OpenProject_16x.png differ
diff --git a/ZuneUIXTools/Images/SaveAs_16x.png b/ZuneUIXTools/Images/SaveAs_16x.png
new file mode 100644
index 0000000..5ddedbb
Binary files /dev/null and b/ZuneUIXTools/Images/SaveAs_16x.png differ
diff --git a/ZuneUIXTools/Images/Save_16x.png b/ZuneUIXTools/Images/Save_16x.png
new file mode 100644
index 0000000..34a3c5b
Binary files /dev/null and b/ZuneUIXTools/Images/Save_16x.png differ
diff --git a/ZuneUIXTools/Images/StartWithoutDebug_16x.png b/ZuneUIXTools/Images/StartWithoutDebug_16x.png
new file mode 100644
index 0000000..939f115
Binary files /dev/null and b/ZuneUIXTools/Images/StartWithoutDebug_16x.png differ
diff --git a/ZuneUIXTools/Images/ZuneShell.ico b/ZuneUIXTools/Images/ZuneShell.ico
new file mode 100644
index 0000000..d1c9729
Binary files /dev/null and b/ZuneUIXTools/Images/ZuneShell.ico differ
diff --git a/ZuneUIXTools/MainWindow.xaml b/ZuneUIXTools/MainWindow.xaml
index cc56aec..c6b2090 100644
--- a/ZuneUIXTools/MainWindow.xaml
+++ b/ZuneUIXTools/MainWindow.xaml
@@ -4,9 +4,46 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ZuneUIXTools"
+ xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
+ Title="Zune UIX Tools" Height="450" Width="800">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZuneUIXTools/MainWindow.xaml.cs b/ZuneUIXTools/MainWindow.xaml.cs
index 1e27331..cbbaec4 100644
--- a/ZuneUIXTools/MainWindow.xaml.cs
+++ b/ZuneUIXTools/MainWindow.xaml.cs
@@ -1,8 +1,13 @@
-using Microsoft.Iris;
+using ICSharpCode.AvalonEdit.Document;
+using ICSharpCode.AvalonEdit.Highlighting;
+using ICSharpCode.AvalonEdit.Highlighting.Xshd;
+using ICSharpCode.AvalonEdit.Rendering;
+using Microsoft.Iris;
using Microsoft.Iris.Markup;
using Microsoft.Iris.Session;
using System;
using System.Collections;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@@ -11,6 +16,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
+using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@@ -25,6 +31,9 @@ namespace ZuneUIXTools
///
public partial class MainWindow : Window
{
+ public string DocumentPath { get; set; }
+ public string UIRoot { get; set; }
+
public MainWindow()
{
InitializeComponent();
@@ -34,51 +43,111 @@ namespace ZuneUIXTools
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
- Thread newWindowThread = new Thread(new ThreadStart(TestCompile));
- newWindowThread.SetApartmentState(ApartmentState.STA);
- newWindowThread.IsBackground = true;
- newWindowThread.Start();
+
}
- private void TestCompile()
+ private void BuildAndRun()
{
MarkupSystem.Startup(true);
ErrorManager.OnErrors += (IList errors) => {
foreach (object obj in errors)
{
- var err = obj as ErrorRecord;
- if (err == null) continue;
+ if (!(obj is ErrorRecord err)) continue;
#if DEBUG
System.Diagnostics.Debug.WriteLine(err.Message);
- System.Diagnostics.Debugger.Break();
+ //System.Diagnostics.Debugger.Break();
#else
Console.WriteLine(err.Message);
#endif
+
+ Dispatcher.Invoke(() =>
+ {
+ ErrorPanel.Children.Add(new TextBlock
+ {
+ Text = $"Ln {err.Line}, Col {err.Column}: {err.Message}",
+ Margin = new Thickness(0, 0, 0, 4)
+ });
+
+ // Highlight the error in the code editor
+ int offset = textEditor.Document.GetOffset(err.Line, err.Column);
+ textEditor.SelectionStart = offset;
+ //textEditor.SelectionLength = err.
+ //var anchor = textEditor.Document.CreateAnchor(offset);
+ //textEditor.Document.GetLineByOffset(offset)
+ });
}
};
- string testDir = @"D:\Repos\yoshiask\ZuneUIXTools\test\";
- string testName = "text";
- string sourceFile = System.IO.Path.Combine(testDir, testName) + ".uix";
- string compiledFile = System.IO.Path.Combine(testDir, testName) + ".uib";
-
+ string compiledFile = System.IO.Path.ChangeExtension(DocumentPath, "uib");
bool isSuccess = MarkupCompiler.Compile(
new[]
{
new CompilerInput()
{
- SourceFileName = sourceFile,
+ SourceFileName = DocumentPath,
OutputFileName = compiledFile
}
},
new CompilerInput()
);
- Microsoft.Iris.Application.Initialize();
- Microsoft.Iris.Application.Window.SetBackgroundColor(new WindowColor(80, 0, 0));
- Microsoft.Iris.Application.Window.RequestLoad("file://" + compiledFile + "#TextDisplay");
- Microsoft.Iris.Application.Run();
+ try
+ {
+ Microsoft.Iris.Application.Initialize();
+ }
+ catch { }
+
+ try
+ {
+ Microsoft.Iris.Application.Window.SetBackgroundColor(new WindowColor(0xE6, 0xE6, 0xE6));
+ Microsoft.Iris.Application.Window.RequestLoad("file://" + compiledFile + (string.IsNullOrEmpty(UIRoot) ? string.Empty : "#" + UIRoot));
+ Microsoft.Iris.Application.Run();
+ }
+ catch (Exception ex)
+ {
+ Dispatcher.Invoke(() =>
+ ErrorPanel.Children.Add(new TextBlock
+ {
+ Text = $"Load Failed: {ex.Message}",
+ Margin = new Thickness(0, 0, 0, 4)
+ })
+ );
+ }
+
+ //Microsoft.Iris.Application.Window.
+ //Microsoft.Iris.Application.Shutdown();
+
+ // This code is run AFTER the Iris window is closed
+ }
+
+ private void Build_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrEmpty(DocumentPath))
+ return;
+
+ // Save changes before running
+ textEditor.Save(DocumentPath);
+ // Set UI root
+ UIRoot = UIRootBox.Text;
+
+ Thread newWindowThread = new Thread(new ThreadStart(BuildAndRun));
+ newWindowThread.SetApartmentState(ApartmentState.STA);
+ newWindowThread.IsBackground = true;
+ newWindowThread.Start();
+ }
+
+ private void Open_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog
+ {
+ Filter = "Microsoft Iris UI (*.uix)|*.uix|XML files (*.xml)|*.xml"
+ };
+ if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
+ return;
+
+ DocumentPath = openFileDialog.FileName;
+ textEditor.Load(DocumentPath);
}
}
}
diff --git a/ZuneUIXTools/ZuneUIXTools.csproj b/ZuneUIXTools/ZuneUIXTools.csproj
index cb2561a..d7e134f 100644
--- a/ZuneUIXTools/ZuneUIXTools.csproj
+++ b/ZuneUIXTools/ZuneUIXTools.csproj
@@ -6,6 +6,16 @@
true
+
+
+ PreserveNewest
+
+
+
+
+
+
+
diff --git a/test/testA.uib b/test/testA.uib
index 58e8671..b1e18b8 100644
Binary files a/test/testA.uib and b/test/testA.uib differ
diff --git a/test/testA.uix b/test/testA.uix
index 9fcb1fa..e030945 100644
--- a/test/testA.uix
+++ b/test/testA.uix
@@ -1,10 +1,17 @@
-
+
-
+
Howdy from Microsoft.Iris!
- white
+
+
+
+
+ This is some blue text
+
+
+
\ No newline at end of file