diff --git a/CSharpMath.Avalonia.Example/App.xaml b/CSharpMath.Avalonia.Example/App.xaml
index da74be9e..291e7c7a 100644
--- a/CSharpMath.Avalonia.Example/App.xaml
+++ b/CSharpMath.Avalonia.Example/App.xaml
@@ -4,10 +4,8 @@
-
-
+
-
diff --git a/CSharpMath.Avalonia.Example/CSharpMath.Avalonia.Example.csproj b/CSharpMath.Avalonia.Example/CSharpMath.Avalonia.Example.csproj
index c07fd7f9..231aabdc 100644
--- a/CSharpMath.Avalonia.Example/CSharpMath.Avalonia.Example.csproj
+++ b/CSharpMath.Avalonia.Example/CSharpMath.Avalonia.Example.csproj
@@ -9,20 +9,9 @@
-
+
+
-
-
- MathButtonPage.xaml
-
-
- MathViewPage.xaml
-
-
- TextViewPage.xaml
-
-
-
\ No newline at end of file
diff --git a/CSharpMath.Avalonia.Example/MainView.xaml b/CSharpMath.Avalonia.Example/MainView.xaml
index 84a0795e..ec6c3023 100644
--- a/CSharpMath.Avalonia.Example/MainView.xaml
+++ b/CSharpMath.Avalonia.Example/MainView.xaml
@@ -1,40 +1,44 @@
-
-
-
-
-
-
-
-
- Light
- Dark
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CSharpMath.Avalonia.Example/MainView.xaml.cs b/CSharpMath.Avalonia.Example/MainView.xaml.cs
index e36f75e9..76dea828 100644
--- a/CSharpMath.Avalonia.Example/MainView.xaml.cs
+++ b/CSharpMath.Avalonia.Example/MainView.xaml.cs
@@ -1,3 +1,4 @@
+using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.Styling;
@@ -7,21 +8,11 @@ public class MainView : UserControl {
public MainView() {
InitializeComponent();
- var light = AvaloniaXamlLoader.Parse(@"");
- var dark = AvaloniaXamlLoader.Parse(@"");
- var themes = this.Find("Themes");
- themes.SelectionChanged += (sender, e) => {
- switch (themes.SelectedIndex) {
- case 0:
- Styles[0] = light;
- break;
- case 1:
- Styles[0] = dark;
- break;
- }
- };
-
- Styles.Add(light);
+ var light = AvaloniaXamlLoader.Parse(@"");
+ var dark = AvaloniaXamlLoader.Parse(@"");
+ var themes = this.Find("lightThemeRbn");
+ themes.Checked += (sender, e) => Application.Current.Styles[0] = light;
+ themes.Unchecked += (sender, e) => Application.Current.Styles[0] = dark;
}
private void InitializeComponent() {
diff --git a/CSharpMath.Avalonia.Example/SideBar.xaml b/CSharpMath.Avalonia.Example/SideBar.xaml
deleted file mode 100644
index 8592bf16..00000000
--- a/CSharpMath.Avalonia.Example/SideBar.xaml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- Tag
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CSharpMath.Avalonia/CSharpMath.Avalonia.csproj b/CSharpMath.Avalonia/CSharpMath.Avalonia.csproj
index d1d500d3..f972c905 100644
--- a/CSharpMath.Avalonia/CSharpMath.Avalonia.csproj
+++ b/CSharpMath.Avalonia/CSharpMath.Avalonia.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/CSharpMath.Rendering.Tests/CSharpMath.Rendering.Tests.csproj b/CSharpMath.Rendering.Tests/CSharpMath.Rendering.Tests.csproj
index ffd0db32..94db3561 100644
--- a/CSharpMath.Rendering.Tests/CSharpMath.Rendering.Tests.csproj
+++ b/CSharpMath.Rendering.Tests/CSharpMath.Rendering.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/CSharpMath.Rendering.Tests/TestRendering.cs b/CSharpMath.Rendering.Tests/TestRendering.cs
index f3c6a1d0..2456232a 100644
--- a/CSharpMath.Rendering.Tests/TestRendering.cs
+++ b/CSharpMath.Rendering.Tests/TestRendering.cs
@@ -108,6 +108,10 @@ protected void Run(
// Prevent black background behind black rendered output in File Explorer preview
painter.HighlightColor = painter.UnwrapColor(System.Drawing.Color.FromArgb(0xF0, 0xF0, 0xF0));
+ if (painter.FontSize is PainterConstants.DefaultFontSize)
+ // We want a large and clear output so we increase the font size
+ // If we really want to test PainterConstants.DefaultFontSize = 14, choose e.g. 14.001 instead
+ painter.FontSize = 50;
painter.LaTeX = latex;
var actualFile = new FileInfo(System.IO.Path.Combine(folder, inFile + "." + frontEnd + ".png"));
diff --git a/CSharpMath.Rendering/FrontEnd/Painter.cs b/CSharpMath.Rendering/FrontEnd/Painter.cs
index 551b2725..24876bea 100644
--- a/CSharpMath.Rendering/FrontEnd/Painter.cs
+++ b/CSharpMath.Rendering/FrontEnd/Painter.cs
@@ -13,7 +13,7 @@ namespace CSharpMath.Rendering.FrontEnd {
using BackEnd;
public static class PainterConstants {
- public const float DefaultFontSize = 50f;
+ public const float DefaultFontSize = 14;
}
public abstract class Painter : ICSharpMathAPI where TContent : class {
public const float DefaultFontSize = PainterConstants.DefaultFontSize;
diff --git a/CSharpMath.Xaml.Tests.NuGet/Test.cs b/CSharpMath.Xaml.Tests.NuGet/Test.cs
index 1c971586..39608402 100644
--- a/CSharpMath.Xaml.Tests.NuGet/Test.cs
+++ b/CSharpMath.Xaml.Tests.NuGet/Test.cs
@@ -1,4 +1,4 @@
-namespace CSharpMath.Xaml.Tests.NuGet {
+namespace CSharpMath.Xaml.Tests.NuGet {
using Avalonia;
using SkiaSharp;
using Forms;
@@ -11,9 +11,9 @@ public void TestImage() {
Xamarin.Forms.Device.PlatformServices = new Xamarin.Forms.Core.UnitTests.MockPlatformServices();
using (var forms = System.IO.File.OpenWrite(File(nameof(Forms))))
- new Forms.MathView { LaTeX = "1" }.Painter.DrawAsStream()?.CopyTo(forms);
+ new Forms.MathView { LaTeX = "1", FontSize = 50 }.Painter.DrawAsStream()?.CopyTo(forms);
using (var avalonia = System.IO.File.OpenWrite(File(nameof(Avalonia))))
- new Avalonia.MathView { LaTeX = "1" }.Painter.DrawAsPng(avalonia);
+ new Avalonia.MathView { LaTeX = "1", FontSize = 50 }.Painter.DrawAsPng(avalonia);
using (var forms = System.IO.File.OpenRead(File(nameof(Forms))))
Xunit.Assert.Contains(forms.Length, new[] { 344L, 797 }); // 797 on Mac, 344 on Ubuntu
diff --git a/CSharpMath.Xaml/Views.cs b/CSharpMath.Xaml/Views.cs
index 152fd3b3..8c9fe04a 100644
--- a/CSharpMath.Xaml/Views.cs
+++ b/CSharpMath.Xaml/Views.cs
@@ -39,9 +39,12 @@ public static XProperty CreateProperty(
Action? updateOtherProperty = null)
where TThis : BaseView {
var defaultValue = defaultValueGet(staticPainter);
- void PropertyChanged(TThis @this, object newValue) {
- propertySet(@this.Painter, (TValue)newValue);
- updateOtherProperty?.Invoke(@this, (TValue)newValue);
+ void PropertyChanged(TThis @this, object? newValue) {
+ // We need to support nullable classes and structs, so we cannot forbid null here
+ // So this use of the null-forgiving operator should be blamed on non-generic PropertyChanged handlers
+ var @new = (TValue)newValue!;
+ propertySet(@this.Painter, @new);
+ updateOtherProperty?.Invoke(@this, @new);
if (affectsMeasure) @this.InvalidateMeasure();
// Redraw immediately! No deferred drawing
#if Avalonia
@@ -54,10 +57,9 @@ void PropertyChanged(TThis @this, object newValue) {
public BaseView() {
// Respect built-in styles
Styles.Add(new global::Avalonia.Styling.Style(global::Avalonia.Styling.Selectors.Is>) {
- Setters = new[]
+ Setters =
{
- new global::Avalonia.Styling.Setter(TextColorProperty, new global::Avalonia.Markup.Xaml.MarkupExtensions.DynamicResourceExtension("ThemeForegroundColor")),
- new global::Avalonia.Styling.Setter(FontSizeProperty, new global::Avalonia.Markup.Xaml.MarkupExtensions.DynamicResourceExtension("FontSizeNormal"))
+ new global::Avalonia.Styling.Setter(TextColorProperty, new global::Avalonia.Markup.Xaml.MarkupExtensions.DynamicResourceExtension("SystemBaseHighColor"))
}
});
}