Skip to content

Commit d835e93

Browse files
jp2masaHappypig375FoggyFinder
authored
Updated Avalonia to 0.10.0-preview1 (#146)
* Updated Avalonia to 0.10.0-preview1. * Update default font size * replace ComboBox with RadioButtons to avoid crash * change VerticalContentAlignment Co-authored-by: Hadrian Tang <hadrianwttang@outlook.com> Co-authored-by: FoggyFinder <FoggyFinder@yandex.ua>
1 parent f75643d commit d835e93

File tree

11 files changed

+69
-165
lines changed

11 files changed

+69
-165
lines changed

CSharpMath.Avalonia.Example/App.xaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
<Application.Styles>
66

7-
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
8-
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
7+
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Accents/FluentLight.xaml"/>
98

10-
<StyleInclude Source="/SideBar.xaml"/>
119
<StyleInclude Source="/Styles.xaml"/>
1210

1311
</Application.Styles>

CSharpMath.Avalonia.Example/CSharpMath.Avalonia.Example.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,9 @@
99
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
1010
<AvaloniaResource Include="**\*.xaml" />
1111
<EmbeddedResource Include="..\Icon.png" Link="Icon.png" />
12-
<PackageReference Include="Avalonia.Desktop" Version="0.9.6" />
12+
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview1" />
13+
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-preview1" />
1314
<ProjectReference Include="..\CSharpMath.Avalonia\CSharpMath.Avalonia.csproj" />
1415
</ItemGroup>
1516

16-
<ItemGroup>
17-
<Compile Update="Pages\MathButtonPage.xaml.cs">
18-
<DependentUpon>MathButtonPage.xaml</DependentUpon>
19-
</Compile>
20-
<Compile Update="Pages\MathViewPage.xaml.cs">
21-
<DependentUpon>MathViewPage.xaml</DependentUpon>
22-
</Compile>
23-
<Compile Update="Pages\TextViewPage.xaml.cs">
24-
<DependentUpon>TextViewPage.xaml</DependentUpon>
25-
</Compile>
26-
</ItemGroup>
27-
2817
</Project>
Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
1-
<UserControl xmlns="https://github.com/avaloniaui"
2-
xmlns:pages="clr-namespace:CSharpMath.Avalonia.Example.Pages"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
x:Class="CSharpMath.Avalonia.Example.MainView"
5-
Background="{DynamicResource ThemeBackgroundBrush}"
6-
Foreground="{DynamicResource ThemeForegroundBrush}"
7-
FontSize="{DynamicResource FontSizeNormal}">
8-
9-
<TabControl x:Name="Sidebar"
10-
Classes="sidebar">
11-
12-
<TabControl.Tag>
13-
14-
<ComboBox x:Name="Themes"
15-
DockPanel.Dock="Bottom"
16-
SelectedIndex="0"
17-
Width="100"
18-
Margin="8">
19-
20-
<ComboBoxItem>Light</ComboBoxItem>
21-
<ComboBoxItem>Dark</ComboBoxItem>
22-
23-
</ComboBox>
24-
25-
</TabControl.Tag>
26-
27-
<TabItem Header="MathView">
28-
<pages:MathViewPage/>
29-
</TabItem>
30-
31-
<TabItem Header="TextView">
32-
<pages:TextViewPage/>
33-
</TabItem>
34-
<TabItem Header="MathButton">
35-
<pages:MathButtonPage/>
36-
</TabItem>
37-
38-
</TabControl>
1+
<UserControl
2+
x:Class="CSharpMath.Avalonia.Example.MainView"
3+
xmlns="https://github.com/avaloniaui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:pages="clr-namespace:CSharpMath.Avalonia.Example.Pages"
6+
Background="{DynamicResource ThemeBackgroundBrush}"
7+
FontSize="{DynamicResource FontSizeNormal}"
8+
Foreground="{DynamicResource ThemeForegroundBrush}">
9+
10+
<DockPanel>
11+
12+
<StackPanel
13+
HorizontalAlignment="Right"
14+
DockPanel.Dock="Bottom"
15+
Orientation="Horizontal">
16+
<RadioButton
17+
x:Name="lightThemeRbn"
18+
Margin="2,8"
19+
Padding="8,0"
20+
VerticalContentAlignment="Center"
21+
Content="Light"
22+
IsChecked="true" />
23+
<RadioButton
24+
Margin="2,8"
25+
Padding="8,0"
26+
VerticalContentAlignment="Center"
27+
Content="Dark" />
28+
</StackPanel>
29+
30+
<TabControl x:Name="Sidebar" Padding="16">
31+
<TabItem Header="MathView">
32+
<pages:MathViewPage />
33+
</TabItem>
34+
<TabItem Header="TextView">
35+
<pages:TextViewPage />
36+
</TabItem>
37+
<TabItem Header="MathButton">
38+
<pages:MathButtonPage />
39+
</TabItem>
40+
</TabControl>
41+
42+
</DockPanel>
3943

4044
</UserControl>

CSharpMath.Avalonia.Example/MainView.xaml.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Avalonia;
12
using Avalonia.Controls;
23
using Avalonia.Markup.Xaml;
34
using Avalonia.Markup.Xaml.Styling;
@@ -7,21 +8,11 @@ public class MainView : UserControl {
78
public MainView() {
89
InitializeComponent();
910

10-
var light = AvaloniaXamlLoader.Parse<StyleInclude>(@"<StyleInclude xmlns='https://github.com/avaloniaui' Source='avares://Avalonia.Themes.Default/Accents/BaseLight.xaml'/>");
11-
var dark = AvaloniaXamlLoader.Parse<StyleInclude>(@"<StyleInclude xmlns='https://github.com/avaloniaui' Source='avares://Avalonia.Themes.Default/Accents/BaseDark.xaml'/>");
12-
var themes = this.Find<ComboBox>("Themes");
13-
themes.SelectionChanged += (sender, e) => {
14-
switch (themes.SelectedIndex) {
15-
case 0:
16-
Styles[0] = light;
17-
break;
18-
case 1:
19-
Styles[0] = dark;
20-
break;
21-
}
22-
};
23-
24-
Styles.Add(light);
11+
var light = AvaloniaXamlLoader.Parse<StyleInclude>(@"<StyleInclude xmlns='https://github.com/avaloniaui' Source='avares://Avalonia.Themes.Fluent/Accents/FluentLight.xaml'/>");
12+
var dark = AvaloniaXamlLoader.Parse<StyleInclude>(@"<StyleInclude xmlns='https://github.com/avaloniaui' Source='avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml'/>");
13+
var themes = this.Find<RadioButton>("lightThemeRbn");
14+
themes.Checked += (sender, e) => Application.Current.Styles[0] = light;
15+
themes.Unchecked += (sender, e) => Application.Current.Styles[0] = dark;
2516
}
2617

2718
private void InitializeComponent() {

CSharpMath.Avalonia.Example/SideBar.xaml

Lines changed: 0 additions & 84 deletions
This file was deleted.

CSharpMath.Avalonia/CSharpMath.Avalonia.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
1212
<AvaloniaResource Include="**\*.xaml" />
13-
<PackageReference Include="Avalonia" Version="0.9.6" />
13+
<PackageReference Include="Avalonia" Version="0.10.0-preview1" />
1414
<ProjectReference Include="..\CSharpMath.Rendering\CSharpMath.Rendering.csproj" />
1515
</ItemGroup>
1616

CSharpMath.Rendering.Tests/CSharpMath.Rendering.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Compile Include="..\CSharpMath.CoreTests\_Helpers\ApproximateAssertions.cs" Link="ApproximateAssertions.cs" />
99
<ProjectReference Include="..\CSharpMath.Avalonia\CSharpMath.Avalonia.csproj" />
1010
<ProjectReference Include="..\CSharpMath.SkiaSharp\CSharpMath.SkiaSharp.csproj" />
11-
<PackageReference Include="Avalonia.Skia" Version="0.9.4" />
11+
<PackageReference Include="Avalonia.Skia" Version="0.10.0-preview1" />
1212
<PackageReference Include="xunit" Version="2.4.1" />
1313
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
1414
<PackageReference Include="Xunit.SkippableFact" Version="1.4.8" />

CSharpMath.Rendering.Tests/TestRendering.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ protected void Run<TContent>(
135135

136136
// Prevent black background behind black rendered output in File Explorer preview
137137
painter.HighlightColor = painter.UnwrapColor(System.Drawing.Color.FromArgb(0xF0, 0xF0, 0xF0));
138+
if (painter.FontSize is PainterConstants.DefaultFontSize)
139+
// We want a large and clear output so we increase the font size
140+
// If we really want to test PainterConstants.DefaultFontSize = 14, choose e.g. 14.001 instead
141+
painter.FontSize = 50;
138142
painter.LaTeX = latex;
139143

140144
var actualFile = new FileInfo(System.IO.Path.Combine(folder, inFile + "." + frontEnd + ".png"));

CSharpMath.Rendering/FrontEnd/Painter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CSharpMath.Rendering.FrontEnd {
1313
using BackEnd;
1414

1515
public static class PainterConstants {
16-
public const float DefaultFontSize = 50f;
16+
public const float DefaultFontSize = 14;
1717
}
1818
public abstract class Painter<TCanvas, TContent, TColor> : ICSharpMathAPI<TContent, TColor> where TContent : class {
1919
public const float DefaultFontSize = PainterConstants.DefaultFontSize;

CSharpMath.Xaml.Tests.NuGet/Test.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace CSharpMath.Xaml.Tests.NuGet {
1+
namespace CSharpMath.Xaml.Tests.NuGet {
22
using Avalonia;
33
using SkiaSharp;
44
using Forms;
@@ -11,9 +11,9 @@ public void TestImage() {
1111
Xamarin.Forms.Device.PlatformServices = new Xamarin.Forms.Core.UnitTests.MockPlatformServices();
1212

1313
using (var forms = System.IO.File.OpenWrite(File(nameof(Forms))))
14-
new Forms.MathView { LaTeX = "1" }.Painter.DrawAsStream()?.CopyTo(forms);
14+
new Forms.MathView { LaTeX = "1", FontSize = 50 }.Painter.DrawAsStream()?.CopyTo(forms);
1515
using (var avalonia = System.IO.File.OpenWrite(File(nameof(Avalonia))))
16-
new Avalonia.MathView { LaTeX = "1" }.Painter.DrawAsPng(avalonia);
16+
new Avalonia.MathView { LaTeX = "1", FontSize = 50 }.Painter.DrawAsPng(avalonia);
1717

1818
using (var forms = System.IO.File.OpenRead(File(nameof(Forms))))
1919
Xunit.Assert.Contains(forms.Length, new[] { 344L, 797 }); // 797 on Mac, 344 on Ubuntu

0 commit comments

Comments
 (0)