diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/App.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/App.xaml
index 4b71a154..fc78e5fd 100644
--- a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/App.xaml
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/App.xaml
@@ -2,6 +2,5 @@
x:Class="CSharpMath.Uno.Example.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="using:CSharpMath.Uno.Example">
-
-
+ xmlns:local="using:CSharpMath.Uno.Example"
+ RequestedTheme="Light" />
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/CSharpMath.Uno.Example.Shared.projitems b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/CSharpMath.Uno.Example.Shared.projitems
index 9c8113b2..3361c086 100644
--- a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/CSharpMath.Uno.Example.Shared.projitems
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/CSharpMath.Uno.Example.Shared.projitems
@@ -18,20 +18,49 @@
App.xaml
+
+ ClockPage.xaml
+
MainPage.xaml
+
+
+ MoreExamplesPage.xaml
+
+
+ TextPage.xaml
+
+
+ TryPage.xaml
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml
new file mode 100644
index 00000000..8abcc606
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml.cs
new file mode 100644
index 00000000..39a6528d
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/ClockPage.xaml.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using CSharpMath.SkiaSharp;
+using SkiaSharp;
+using SkiaSharp.Views.UWP;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using static System.Math;
+
+namespace CSharpMath.Uno.Example.Shared {
+ public sealed partial class ClockPage : Page {
+ private readonly DispatcherTimer _timer;
+
+ public ClockPage() {
+ this.InitializeComponent();
+ _timer = new DispatcherTimer();
+ _timer.Interval = TimeSpan.FromMilliseconds(200);
+ _timer.Tick += (s, e) => {
+ canvasView.Invalidate();
+ };
+ this.Loaded += ClockPage_Loaded;
+ this.Unloaded += ClockPage_Unloaded;
+ }
+
+ private void ClockPage_Loaded(object sender, RoutedEventArgs e) {
+ _timer.Start();
+ }
+
+ private void ClockPage_Unloaded(object sender, RoutedEventArgs e) {
+ _timer.Stop();
+ }
+
+ readonly SKPaint blackFillPaint = new SKPaint {
+ Style = SKPaintStyle.Fill,
+ Color = SKColors.Black
+ };
+ readonly SKPaint whiteFillPaint = new SKPaint {
+ Style = SKPaintStyle.Fill,
+ Color = SKColors.White
+ };
+ readonly SKPaint whiteStrokePaint = new SKPaint {
+ Style = SKPaintStyle.Stroke,
+ Color = SKColors.White,
+ StrokeCap = SKStrokeCap.Round,
+ IsAntialias = true
+ };
+ readonly SKPaint redStrokePaint = new SKPaint {
+ Style = SKPaintStyle.Stroke,
+ Color = SKColors.Red,
+ StrokeCap = SKStrokeCap.Round,
+ IsAntialias = true
+ };
+ readonly string[] labels = {
+ // Four 4s make 1 to 12 using different operations
+ @"$\frac{44+4}{4}$",
+ @"$\frac{44}{44}$",
+ @"$\frac{4}{4}+\frac{4}{4}$",
+ @"$\frac{4+4+4}{4}$",
+ @"$4+\frac{4-4}{4}$",
+ @"$4+4^{4-4}$",
+ @"$4+\frac{4+4}{4}$",
+ @"$\frac{44}{4}-4$",
+ @"$\sqrt{4}^{4-\frac{4}{4}}$",
+ @"$\:\:(4-\frac{4}{4})^{\sqrt{4}}$",
+ @"$\frac{44-4}{4}$",
+ @"$\frac{4!}{\sqrt{4}}-\frac{4}{4}$"
+ };
+ private void CanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) {
+ var canvas = e.Surface.Canvas;
+ canvas.Clear(SKColors.CornflowerBlue);
+ canvas.Translate(e.Info.Width / 2, e.Info.Height / 2);
+ canvas.Scale(e.Info.Width / 210f);
+ canvas.DrawCircle(0, 0, 100, blackFillPaint);
+ var painter = new TextPainter { FontSize = 8, TextColor = SKColors.White };
+ for (int i = 0; i < 60; i++) {
+ // Dots
+ canvas.Save();
+ canvas.RotateDegrees(6 * i);
+ canvas.DrawCircle(0, -90, i % 5 == 0 ? 4 : 2, whiteFillPaint);
+ canvas.Restore();
+ // Maths
+ if (i % 5 == 0) {
+ painter.LaTeX = labels[i / 5];
+ if (!(painter.Measure(e.Info.Width) is { } measure))
+ throw new Structures.InvalidCodePathException("Invalid LaTeX");
+ var θ = (90 - 6 * i) / 180f * PI;
+ var sinθ = (float)Sin(θ);
+ var cosθ = (float)Cos(θ);
+ painter.Draw(canvas,
+ new System.Drawing.PointF(75 * cosθ - (float)measure.Width / 2,
+ -75 * sinθ - (float)measure.Height / 2),
+ float.PositiveInfinity);
+ }
+ }
+ var dateTime = DateTime.Now;
+ // H
+ canvas.Save();
+ canvas.RotateDegrees(30 * dateTime.Hour + dateTime.Minute / 2f);
+ whiteStrokePaint.StrokeWidth = 12;
+ canvas.DrawLine(0, 0, 0, -50, whiteStrokePaint);
+ canvas.Restore();
+ // M
+ canvas.Save();
+ canvas.RotateDegrees(6 * dateTime.Minute + dateTime.Second / 10f);
+ whiteStrokePaint.StrokeWidth = 6;
+ canvas.DrawLine(0, 0, 0, -65, whiteStrokePaint);
+ canvas.Restore();
+ // S
+ canvas.Save();
+ canvas.RotateDegrees(6f * (dateTime.Second + dateTime.Millisecond / 1000f));
+ redStrokePaint.StrokeWidth = 2;
+ canvas.DrawLine(0, 0, 0, -75, redStrokePaint);
+ canvas.Restore();
+ }
+ }
+}
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml
index cee3864e..1910ac21 100644
--- a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml
@@ -5,13 +5,21 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CSharpMath.Uno.Example"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:shared="using:CSharpMath.Uno.Example.Shared"
xmlns:skia="using:SkiaSharp.Views.UWP"
mc:Ignorable="d">
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml.cs
index 5fcaf307..b79a0d47 100644
--- a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml.cs
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MainPage.xaml.cs
@@ -24,103 +24,8 @@ namespace CSharpMath.Uno.Example {
/// An empty page that can be used on its own or navigated to within a Frame.
///
public sealed partial class MainPage : Page {
- private readonly DispatcherTimer _timer;
-
public MainPage() {
- this.InitializeComponent();
- _timer = new DispatcherTimer();
- _timer.Interval = TimeSpan.FromMilliseconds(200);
- _timer.Tick += (s, e) => {
- canvasView.Invalidate();
- };
- }
-
- protected override void OnNavigatedTo(NavigationEventArgs e) {
- base.OnNavigatedTo(e);
- _timer.Start();
- }
-
- readonly SKPaint blackFillPaint = new SKPaint {
- Style = SKPaintStyle.Fill,
- Color = SKColors.Black
- };
- readonly SKPaint whiteFillPaint = new SKPaint {
- Style = SKPaintStyle.Fill,
- Color = SKColors.White
- };
- readonly SKPaint whiteStrokePaint = new SKPaint {
- Style = SKPaintStyle.Stroke,
- Color = SKColors.White,
- StrokeCap = SKStrokeCap.Round,
- IsAntialias = true
- };
- readonly SKPaint redStrokePaint = new SKPaint {
- Style = SKPaintStyle.Stroke,
- Color = SKColors.Red,
- StrokeCap = SKStrokeCap.Round,
- IsAntialias = true
- };
- readonly string[] labels = {
- // Four 4s make 1 to 12 using different operations
- @"$\frac{44+4}{4}$",
- @"$\frac{44}{44}$",
- @"$\frac{4}{4}+\frac{4}{4}$",
- @"$\frac{4+4+4}{4}$",
- @"$4+\frac{4-4}{4}$",
- @"$4+4^{4-4}$",
- @"$4+\frac{4+4}{4}$",
- @"$\frac{44}{4}-4$",
- @"$\sqrt{4}^{4-\frac{4}{4}}$",
- @"$\:\:(4-\frac{4}{4})^{\sqrt{4}}$",
- @"$\frac{44-4}{4}$",
- @"$\frac{4!}{\sqrt{4}}-\frac{4}{4}$"
- };
- private void CanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) {
- var canvas = e.Surface.Canvas;
- canvas.Clear(SKColors.CornflowerBlue);
- canvas.Translate(e.Info.Width / 2, e.Info.Height / 2);
- canvas.Scale(e.Info.Width / 210f);
- canvas.DrawCircle(0, 0, 100, blackFillPaint);
- var painter = new TextPainter { FontSize = 8, TextColor = SKColors.White };
- for (int i = 0; i < 60; i++) {
- // Dots
- canvas.Save();
- canvas.RotateDegrees(6 * i);
- canvas.DrawCircle(0, -90, i % 5 == 0 ? 4 : 2, whiteFillPaint);
- canvas.Restore();
- // Maths
- if (i % 5 == 0) {
- painter.LaTeX = labels[i / 5];
- if (!(painter.Measure(e.Info.Width) is { } measure))
- throw new Structures.InvalidCodePathException("Invalid LaTeX");
- var θ = (90 - 6 * i) / 180f * PI;
- var sinθ = (float)Sin(θ);
- var cosθ = (float)Cos(θ);
- painter.Draw(canvas,
- new System.Drawing.PointF(75 * cosθ - (float)measure.Width / 2,
- -75 * sinθ - (float)measure.Height / 2),
- float.PositiveInfinity);
- }
- }
- var dateTime = DateTime.Now;
- // H
- canvas.Save();
- canvas.RotateDegrees(30 * dateTime.Hour + dateTime.Minute / 2f);
- whiteStrokePaint.StrokeWidth = 12;
- canvas.DrawLine(0, 0, 0, -50, whiteStrokePaint);
- canvas.Restore();
- // M
- canvas.Save();
- canvas.RotateDegrees(6 * dateTime.Minute + dateTime.Second / 10f);
- whiteStrokePaint.StrokeWidth = 6;
- canvas.DrawLine(0, 0, 0, -65, whiteStrokePaint);
- canvas.Restore();
- // S
- canvas.Save();
- canvas.RotateDegrees(6f * (dateTime.Second + dateTime.Millisecond / 1000f));
- redStrokePaint.StrokeWidth = 2;
- canvas.DrawLine(0, 0, 0, -75, redStrokePaint);
- canvas.Restore();
+ this.InitializeComponent();
}
}
}
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamples.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamples.cs
new file mode 100644
index 00000000..7de7cc60
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamples.cs
@@ -0,0 +1,492 @@
+//Do not modify this file directly. Instead, modify this at
+//CSharpMath\CSharpMath.Playground\iosMathDemo\ToFormsMoreExamples.cs and re-generate
+//this file by executing the method in that file in the CSharpMath.Utils project.
+
+using CSharpMath.Atom;
+using CSharpMath.Rendering.FrontEnd;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Windows.UI;
+using Windows.UI.Xaml.Media;
+using Color = Windows.UI.Color;
+
+namespace CSharpMath.Uno.Example {
+ [System.Diagnostics.DebuggerNonUserCode, System.Runtime.CompilerServices.CompilerGenerated]
+ public static class MoreExamples {
+ public static ReadOnlyCollection Views { get; }
+ static MoreExamples() {
+ var demoLabels = new Dictionary();
+ var labels = new Dictionary();
+
+ // Demo formulae
+
+ // Quadratic formula
+ demoLabels[0] = new MathView {
+ LaTeX = @"\text{ваш вопрос: }x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[0].FontSize = 15;
+
+ // This is first label so set the height from the top
+ demoLabels[1] = new MathView {
+ LaTeX = @"\color{#ff3399}{(a_1+a_2)^2}=a_1^2+2a_1a_2+a_2^2",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[2] = new MathView {
+ LaTeX = @"\cos(\theta + \varphi) =
+ \cos(\theta)\cos(\varphi) - \sin(\theta)\sin(\varphi)",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[3] = new MathView {
+ LaTeX = @"\frac{1}{\left(\sqrt{\phi \sqrt{5}}-\phi\right) e^{\frac25 \pi}}
+ = 1+\frac{e^{-2\pi}} {1 +\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }",
+ Height = 150,
+ FontSize = 22.5f
+ };
+ demoLabels[4] = new MathView {
+ LaTeX = @"\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^N (x_i - \mu)^2}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[5] = new MathView {
+ LaTeX = @"\neg(P\land Q) \iff (\neg P)\lor(\neg Q)",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[6] = new MathView {
+ LaTeX = @"\log_b(x) = \frac{\log_a(x)}{\log_a(b)}",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[7] = new MathView {
+ LaTeX = @"\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[8] = new MathView {
+ LaTeX = @"\int_{-\infty}^\infty \! e^{-x^2} dx = \sqrt{\pi}",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[9] = new MathView {
+ LaTeX = @"\frac 1 n \sum_{i=1}^{n}x_i \geq \sqrt[n]{\prod_{i=1}^{n}x_i}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[10] = new MathView {
+ LaTeX = @"f^{(n)}(z_0) = \frac{n!}{2\pi i}\oint_\gamma\frac{f(z)}{(z-z_0)^{n+1}}\,dz",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[11] = new MathView {
+ LaTeX = @"i\hbar\frac{\partial}{\partial t}\mathbf\Psi(\mathbf{x},t) =
+ -\frac{\hbar}{2m}\nabla^2\mathbf\Psi(\mathbf{x},t) +
+ V(\mathbf{x})\mathbf\Psi(\mathbf{x},t)",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ demoLabels[12] = new MathView {
+ LaTeX = @"\left(\sum_{k=1}^n a_k b_k \right)^2 \le \left(\sum_{k=1}^n a_k^2\right)\left(\sum_{k=1}^n b_k^2\right)",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[13] = new MathView {
+ LaTeX = @"{n \brace k} = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}(k-j)^n",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[14] = new MathView {
+ LaTeX = @"f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\xi",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[15] = new MathView {
+ LaTeX = @"\begin{gather}
+ \dot{x} = \sigma(y-x) \\
+ \dot{y} = \rho x - y - xz \\
+ \dot{z} = -\beta z + xy
+ \end{gather}",
+ Height = 131.25,
+ FontSize = 22.5f
+ };
+ demoLabels[16] = new MathView {
+ LaTeX = @"\vec \bf V_1 \times \vec \bf V_2 = \begin{vmatrix}
+ \hat \imath &\hat \jmath &\hat k \\
+ \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
+ \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
+ \end{vmatrix}",
+ Height = 131.25,
+ FontSize = 22.5f
+ };
+ demoLabels[17] = new MathView {
+ LaTeX = @"\begin{eqalign}
+ \nabla \cdot \vec{\bf{E}} & = \frac {\rho} {\varepsilon_0} \\
+ \nabla \cdot \vec{\bf{B}} & = 0 \\
+ \nabla \times \vec{\bf{E}} &= - \frac{\partial\vec{\bf{B}}}{\partial t} \\
+ \nabla \times \vec{\bf{B}} & = \mu_0\vec{\bf{J}} + \mu_0\varepsilon_0 \frac{\partial\vec{\bf{E}}}{\partial t}
+ \end{eqalign}",
+ Height = 262.5,
+ FontSize = 22.5f
+ };
+ demoLabels[18] = new MathView {
+ LaTeX = @"\begin{pmatrix}
+ a & b\\ c & d
+ \end{pmatrix}
+ \begin{pmatrix}
+ \alpha & \beta \\ \gamma & \delta
+ \end{pmatrix} =
+ \begin{pmatrix}
+ a\alpha + b\gamma & a\beta + b \delta \\
+ c\alpha + d\gamma & c\beta + d \delta
+ \end{pmatrix}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[19] = new MathView {
+ LaTeX = @"\frak Q(\lambda,\hat{\lambda}) =
+ -\frac{1}{2} \mathbb P(O \mid \lambda ) \sum_s \sum_m \sum_t \gamma_m^{(s)} (t) +\\
+ \quad \left( \log(2 \pi ) + \log \left| \cal C_m^{(s)} \right| +
+ \left( o_t - \hat{\mu}_m^{(s)} \right) ^T \cal C_m^{(s)-1} \right)",
+ Height = 168.75,
+ FontSize = 22.5f
+ };
+ demoLabels[20] = new MathView {
+ LaTeX = @"f(x) = \begin{cases}
+ \frac{e^x}{2} & x \geq 0 \\
+ 1 & x < 0
+ \end{cases}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ demoLabels[21] = new MathView {
+ LaTeX = @"\color{#ff3333}{c}\color{#9933ff}{o}\color{#ff0080}{l}+\color{#99ff33}{\frac{\color{#ff99ff}{o}}{\color{#990099}{r}}}-\color{#33ffff}{\sqrt[\color{#3399ff}{e}]{\color{#3333ff}{d}}}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Test formulae
+ labels[0] = new MathView {
+ LaTeX = @"3+2-5 = 0",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ labels[0].Background = new SolidColorBrush(Colors.Red);
+
+ // Infix and prefix Operators
+ labels[1] = new MathView {
+ LaTeX = @"12+-3 > +14",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ labels[1].Background = new SolidColorBrush(Colors.Red);
+ labels[1].TextAlignment = TextAlignment.Center;
+
+ // Punct, parens
+ labels[2] = new MathView {
+ LaTeX = @"(-3-5=-8, -6-7=-13)",
+ Height = 75,
+ FontSize = 22.5f
+ };
+
+ // Latex commands
+ labels[3] = new MathView {
+ LaTeX = @"5\times(-2 \div 1) = -10",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ labels[3].Background = new SolidColorBrush(Colors.Red);
+ labels[3].TextAlignment = TextAlignment.Right;
+ labels[4] = new MathView {
+ LaTeX = @"-h - (5xy+2) = z",
+ Height = 75,
+ FontSize = 22.5f
+ };
+
+ // Text mode fraction
+ labels[5] = new MathView {
+ LaTeX = @"\frac12x + \frac{3\div4}2y = 25",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[5].LineStyle = LineStyle.Text;
+
+ // Display mode fraction
+ labels[6] = new MathView {
+ LaTeX = @"\frac{x+\frac{12}{5}}{y}+\frac1z = \frac{xz+y+\frac{12}{5}z}{yz}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[6].Background = new SolidColorBrush(Colors.Red);
+
+ // fraction in fraction in text mode
+ labels[7] = new MathView {
+ LaTeX = @"\frac{x+\frac{12}{5}}{y}+\frac1z = \frac{xz+y+\frac{12}{5}z}{yz}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[7].Background = new SolidColorBrush(Colors.Red);
+ labels[7].LineStyle = LineStyle.Text;
+
+ // Exponents and subscripts
+
+ // Large font
+ labels[8] = new MathView {
+ LaTeX = @"\frac{x^{2+3y}}{x^{2+4y}} = x^y \times \frac{z_1^{y+1}}{z_1^{y+1}}",
+ Height = 168.75,
+ FontSize = 22.5f
+ };
+ labels[8].FontSize = 30;
+ labels[8].TextAlignment = TextAlignment.Center;
+
+ // Small font
+ labels[9] = new MathView {
+ LaTeX = @"\frac{x^{2+3y}}{x^{2+4y}} = x^y \times \frac{z_1^{y+1}}{z_1^{y+1}}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[9].FontSize = 10;
+ labels[9].TextAlignment = TextAlignment.Center;
+
+ // Square root
+ labels[10] = new MathView {
+ LaTeX = @"5+\sqrt{2}+3",
+ Height = 75,
+ FontSize = 22.5f
+ };
+
+ // Square root inside square roots and with fractions
+ labels[11] = new MathView {
+ LaTeX = @"\sqrt{\frac{\sqrt{\frac{1}{2}} + 3}{\sqrt5^x}}+\sqrt{3x}+x^{\sqrt2}",
+ Height = 168.75,
+ FontSize = 22.5f
+ };
+
+ // General root
+ labels[12] = new MathView {
+ LaTeX = @"\sqrt[3]{24} + 3\sqrt{2}24",
+ Height = 75,
+ FontSize = 22.5f
+ };
+
+ // Fractions and formulae in root
+ labels[13] = new MathView {
+ LaTeX = @"\sqrt[x+\frac{3}{4}]{\frac{2}{4}+1}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Non-symbol operators with no limits
+ labels[14] = new MathView {
+ LaTeX = @"\sin^2(\theta)=\log_3^2(\pi)",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Non-symbol operators with limits
+ labels[15] = new MathView {
+ LaTeX = @"\lim_{x\to\infty}\frac{e^2}{1-x}=\limsup_{\sigma}5",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Symbol operators with limits
+ labels[16] = new MathView {
+ LaTeX = @"\sum_{n=1}^{\infty}\frac{1+n}{1-n}=\bigcup_{A\in\Im}C\cup B",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Symbol operators with limits text style
+ labels[17] = new MathView {
+ LaTeX = @"\sum_{n=1}^{\infty}\frac{1+n}{1-n}=\bigcup_{A\in\Im}C\cup B",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[17].LineStyle = LineStyle.Text;
+
+ // Non-symbol operators with limits text style
+ labels[18] = new MathView {
+ LaTeX = @"\lim_{x\to\infty}\frac{e^2}{1-x}=\limsup_{\sigma}5",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[18].LineStyle = LineStyle.Text;
+
+ // Symbol operators with no limits
+ labels[19] = new MathView {
+ LaTeX = @"\int_{0}^{\infty}e^x \,dx=\oint_0^{\Delta}5\Gamma",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Test italic correction for large ops
+ labels[20] = new MathView {
+ LaTeX = @"\int\int\int^{\infty}\int_0\int^{\infty}_0\int",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Test italic correction for superscript/subscript
+ labels[21] = new MathView {
+ LaTeX = @"U_3^2UY_3^2U_3Y^2f_1f^2ff",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+
+ // Error
+ labels[22] = new MathView {
+ LaTeX = @"\notacommand",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[23] = new MathView {
+ LaTeX = @"\sqrt{1}",
+ Height = 37.5,
+ FontSize = 22.5f
+ };
+ labels[24] = new MathView {
+ LaTeX = @"\sqrt[|]{1}",
+ Height = 37.5,
+ FontSize = 22.5f
+ };
+ labels[25] = new MathView {
+ LaTeX = @"{n \choose k}",
+ Height = 112.5,
+ FontSize = 22.5f
+ };
+ labels[26] = new MathView {
+ LaTeX = @"{n \choose k}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[26].LineStyle = LineStyle.Text;
+ labels[27] = new MathView {
+ LaTeX = @"\left({n \atop k}\right)",
+ Height = 75,
+ FontSize = 22.5f
+ };
+ labels[28] = new MathView {
+ LaTeX = @"\left({n \atop k}\right)",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[28].LineStyle = LineStyle.Text;
+ labels[29] = new MathView {
+ LaTeX = @"\underline{xyz}+\overline{abc}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[30] = new MathView {
+ LaTeX = @"\underline{\frac12}+\overline{\frac34}",
+ Height = 93.75,
+ FontSize = 22.5f
+ };
+ labels[31] = new MathView {
+ LaTeX = @"\underline{x^\overline{y}_\overline{z}+5}",
+ Height = 93.75,
+ FontSize = 22.5f
+ };
+
+ // spacing examples from the TeX book
+ labels[32] = new MathView {
+ LaTeX = @"\int\!\!\!\int_D dx\,dy",
+ Height = 93.75,
+ FontSize = 22.5f
+ };
+
+ // no spacing
+ labels[33] = new MathView {
+ LaTeX = @"\int\int_D dxdy",
+ Height = 93.75,
+ FontSize = 22.5f
+ };
+ labels[34] = new MathView {
+ LaTeX = @"y\,dx-x\,dy",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[35] = new MathView {
+ LaTeX = @"y dx - x dy",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+
+ // large spaces
+ labels[36] = new MathView {
+ LaTeX = @"hello\ from \quad the \qquad other\ side",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+
+ // Accents
+ labels[37] = new MathView {
+ LaTeX = @"\vec x \; \hat y \; \breve {x^2} \; \tilde x \tilde x^2 x^2",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[38] = new MathView {
+ LaTeX = @"\hat{xyz} \; \widehat{xyz}\; \vec{2ab}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[39] = new MathView {
+ LaTeX = @"\hat{\frac12} \; \hat{\sqrt 3}",
+ Height = 93.75,
+ FontSize = 22.5f
+ };
+
+ // large roots
+ labels[40] = new MathView {
+ LaTeX = @"\colorbox{#f0f0e0}{\sqrt{1+\colorbox{#d0c0d0}{\sqrt{1+\colorbox{#a080c0}{\sqrt{1+\colorbox{#7050a0}{\sqrt{1+\colorbox{403060}{\colorbox{#102000}{\sqrt{1+\cdots}}}}}}}}}}}",
+ Height = 150,
+ FontSize = 22.5f
+ };
+ labels[41] = new MathView {
+ LaTeX = @"\begin{bmatrix}
+ a & b\\ c & d \\ e & f \\ g & h \\ i & j
+ \end{bmatrix}",
+ Height = 225,
+ FontSize = 22.5f
+ };
+ labels[42] = new MathView {
+ LaTeX = @"x{\scriptstyle y}z",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[43] = new MathView {
+ LaTeX = @"x \mathrm x \mathbf x \mathcal X \mathfrak x \mathsf x \bm x \mathtt x \mathit \Lambda \cal g",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[44] = new MathView {
+ LaTeX = @"\mathrm{using\ mathrm}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[45] = new MathView {
+ LaTeX = @"\text{using text}",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[46] = new MathView {
+ LaTeX = @"\text{Mary has }\$500 + \$200.",
+ Height = 56.25,
+ FontSize = 22.5f
+ };
+ labels[47] = new MathView {
+ LaTeX = @"\colorbox{#888888}{\begin{pmatrix}
+ \colorbox{#ff0000}{a} & \colorbox{#00ff00}{b} \\
+ \colorbox{#00aaff}{c} & \colorbox{#f0f0f0}{d}
+ \end{pmatrix}}",
+ Height = 131.25,
+ FontSize = 22.5f
+ };
+
+ Views = demoLabels.Concat(labels).Select(p => p.Value).ToList().AsReadOnly();
+ }
+ }
+}
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml
new file mode 100644
index 00000000..898ca8e1
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml.cs
new file mode 100644
index 00000000..a65b3db4
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/MoreExamplesPage.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace CSharpMath.Uno.Example.Shared {
+ public sealed partial class MoreExamplesPage : Page {
+ public MoreExamplesPage() {
+ this.InitializeComponent();
+ foreach (var view in MoreExamples.Views) {
+ view.ErrorFontSize = view.FontSize * 0.8f;
+ Stack.Children.Add(view);
+ }
+ }
+ }
+}
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml
new file mode 100644
index 00000000..01039e6c
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml.cs
new file mode 100644
index 00000000..7cd303ee
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TextPage.xaml.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace CSharpMath.Uno.Example.Shared
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class TextPage : Page
+ {
+ public TextPage()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml
new file mode 100644
index 00000000..44045b99
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml.cs b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml.cs
new file mode 100644
index 00000000..368932b8
--- /dev/null
+++ b/CSharpMath.Uno.Example/CSharpMath.Uno.Example.Shared/TryPage.xaml.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace CSharpMath.Uno.Example.Shared {
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class TryPage : Page {
+ public float[] FontSizes = new float[] {
+ 1, 2, 4, 8, 12, 16, 20, 24, 30, 36, 48, 60, 72, 96, 108, 144, 192,
+ 288, 384, 480, 576, 666, 768, 864, 960
+ };
+ public TryPage() {
+ InitializeComponent();
+ FontSizeComboBox.SelectedItem = View.FontSize;
+ FontSizeComboBox.SelectionChanged += (sender, e) =>
+ View.FontSize = (float)FontSizeComboBox.SelectedItem;
+ Entry.TextChanged += (sender, e) => {
+ View.LaTeX = Entry.Text;
+ (Exit.Text, Exit.Foreground) =
+ (View.LaTeX, View.ErrorMessage != null ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black));
+ };
+ }
+ }
+}
diff --git a/CSharpMath.sln b/CSharpMath.sln
index 95c78684..b6d06680 100644
--- a/CSharpMath.sln
+++ b/CSharpMath.sln
@@ -106,9 +106,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Ios.Tests", "CSharpMath.Ios.Tests\CSharpMath.Ios.Tests.csproj", "{30C91103-12E5-47AE-85FE-41B0218A8997}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnoPlatform", "UnoPlatform", "{7074DA21-91A3-4F01-B527-08DDE1EA4955}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Uno", "CSharpMath.Uno\CSharpMath.Uno.csproj", "{CBFA75C9-5B10-4DF9-BC52-1559F9A664D5}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpMath.Uno", "CSharpMath.Uno\CSharpMath.Uno.csproj", "{CBFA75C9-5B10-4DF9-BC52-1559F9A664D5}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.SkiaSharp.Wasm", "CSharpMath.SkiaSharp.Wasm\CSharpMath.SkiaSharp.Wasm.csproj", "{0CE08055-BDE9-4400-87C0-F2AEFA2161F0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpMath.SkiaSharp.Wasm", "CSharpMath.SkiaSharp.Wasm\CSharpMath.SkiaSharp.Wasm.csproj", "{0CE08055-BDE9-4400-87C0-F2AEFA2161F0}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpMath.Uno.Example.Shared", "CSharpMath.Uno.Example\CSharpMath.Uno.Example.Shared\CSharpMath.Uno.Example.Shared.shproj", "{6279C845-92F8-4333-AB99-3D213163593C}"
EndProject
@@ -118,7 +118,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Uno.Example.iOS"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Uno.Example.UWP", "CSharpMath.Uno.Example\CSharpMath.Uno.Example.UWP\CSharpMath.Uno.Example.UWP.csproj", "{756C0212-8355-4B5A-8E28-FC709E4ED6C2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Uno.Example.Wasm", "CSharpMath.Uno.Example\CSharpMath.Uno.Example.Wasm\CSharpMath.Uno.Example.Wasm.csproj", "{61993DD5-15BD-4BAE-9B22-7599B9C982A6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpMath.Uno.Example.Wasm", "CSharpMath.Uno.Example\CSharpMath.Uno.Example.Wasm\CSharpMath.Uno.Example.Wasm.csproj", "{61993DD5-15BD-4BAE-9B22-7599B9C982A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpMath.Uno.Example.macOS", "CSharpMath.Uno.Example\CSharpMath.Uno.Example.macOS\CSharpMath.Uno.Example.macOS.csproj", "{779B98DA-C513-4D3C-84B8-51474004E1F9}"
EndProject
@@ -2043,6 +2043,7 @@ Global
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|ARM64.ActiveCfg = Debug|iPhone
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|iPhone.ActiveCfg = Debug|iPhone
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|iPhone.Build.0 = Debug|iPhone
+ {180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|iPhone.Deploy.0 = Debug|iPhone
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{180F0D4F-EFB8-493F-83A6-5D15A764E9F6}.Debug|x64.ActiveCfg = Debug|iPhone