Copied MCML text rendering sample; Run compile in separate thread

This commit is contained in:
Joshua Askharoun
2021-04-03 20:19:43 -05:00
parent 77ba8a55bc
commit bbe7c5cedc
3 changed files with 71 additions and 2 deletions
+11 -2
View File
@@ -5,6 +5,7 @@ using System;
using System.Collections; using System.Collections;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@@ -32,6 +33,14 @@ namespace ZuneUIXTools
} }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) 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()
{ {
MarkupSystem.Startup(true); MarkupSystem.Startup(true);
ErrorManager.OnErrors += (IList errors) => { ErrorManager.OnErrors += (IList errors) => {
@@ -50,7 +59,7 @@ namespace ZuneUIXTools
}; };
string testDir = @"D:\Repos\yoshiask\ZuneUIXTools\test\"; string testDir = @"D:\Repos\yoshiask\ZuneUIXTools\test\";
string testName = "testA"; string testName = "text";
string sourceFile = System.IO.Path.Combine(testDir, testName) + ".uix"; string sourceFile = System.IO.Path.Combine(testDir, testName) + ".uix";
string compiledFile = System.IO.Path.Combine(testDir, testName) + ".uib"; string compiledFile = System.IO.Path.Combine(testDir, testName) + ".uib";
@@ -68,7 +77,7 @@ namespace ZuneUIXTools
Microsoft.Iris.Application.Initialize(); Microsoft.Iris.Application.Initialize();
Microsoft.Iris.Application.Window.SetBackgroundColor(new WindowColor(80, 0, 0)); Microsoft.Iris.Application.Window.SetBackgroundColor(new WindowColor(80, 0, 0));
Microsoft.Iris.Application.Window.RequestLoad("file://" + compiledFile + "#UIRootTest"); Microsoft.Iris.Application.Window.RequestLoad("file://" + compiledFile + "#TextDisplay");
Microsoft.Iris.Application.Run(); Microsoft.Iris.Application.Run();
} }
} }
BIN
View File
Binary file not shown.
+60
View File
@@ -0,0 +1,60 @@
<UIX xmlns="http://schemas.microsoft.com/2007/uix"
xmlns:me="Me">
<UI Name="TextDisplay">
<!-- This UI displays the other UIs. -->
<Locals>
<Font Name="SmallFont" Font="Bahnschrift,10" />
<Font Name="BigFont" FontName="JetBrains Mono" FontSize="18" FontStyle="Bold,Italic"/>
</Locals>
<Content>
<Panel>
<Layout>
<FlowLayout Orientation="Vertical" Spacing="50,0" />
</Layout>
<Children>
<me:TextSettings/>
<me:UsingMargins/>
<me:UsingColorfillWithText/>
</Children>
</Panel>
</Content>
</UI>
<UI Name="TextSettings">
<!-- This UI provides an example for the MaximumLines and WordWrap settings. -->
<Content>
<Panel Layout="VerticalFlow" MaximumSize="140,0">
<Children>
<Text HighlightColor="Gold" Font="{me:BigFont}" MaximumLines="3" WordWrap="true" Content="This large text will wrap. This sentence won't be displayed because it exceeds the 3 line maximum." />
</Children>
</Panel>
</Content>
</UI>
<UI Name="UsingMargins">
<!-- This UI provides an example of using margins to create space between text items. -->
<Content>
<Panel Layout="VerticalFlow">
<Children>
<Text Color="Aquamarine" Font="{me:SmallFont}" Content="You can use margins to create space between text items:" />
<Text Margins="0,20,0,0" Color="SkyBlue" Font="{me:SmallFont}" Content="This sentence has a top margin of 20 pixels." />
</Children>
</Panel>
</Content>
</UI>
<UI Name="UsingColorfillWithText">
<!-- This UI provides an example of placing text inside a ColorFill view item. -->
<Content>
<Panel Layout="VerticalFlow" MinimumSize="500,40">
<Children>
<Text LineAlignment="Center" Color="Maroon" Font="{me:SmallFont}" Content="This text is placed in a ColorFill view item." />
</Children>
</Panel>
</Content>
</UI>
</UIX>