Compare commits

...

35 Commits
v0.10 ... main

Author SHA1 Message Date
90430ff32f Do something 2024-08-15 21:39:10 +02:00
4107ca217a code cleanup 2023-04-07 22:19:13 +02:00
934ecff41a „src/AvaloniaCoreRTDemo.csproj“ ändern 2023-04-02 23:08:43 +02:00
e03d91f128 „src/AvaloniaCoreRTDemo.csproj“ ändern 2023-04-02 23:08:09 +02:00
fc7cdceb05 file-scoped namespaces and other cleanup stuff 2023-04-02 22:49:00 +02:00
c2e7cc1a3c Removed Reactive stuff and do code cleanup 2023-04-02 22:44:52 +02:00
Todor Totev
2af0df14c9
Merge pull request #29 from josephmoresena/master
Avalonia UI 11 Preview 5
2023-02-26 10:25:49 +02:00
Joseph Moreno
46bb647934 Comment out Avalonia source in nuget.config 2023-02-17 17:36:22 -05:00
Joseph Moreno
a3ad58c937 Restore SystemDetail record 2023-02-17 08:35:39 -05:00
Joseph Moreno
ad13e8ca29 Restore nuget.config 2023-02-17 08:15:09 -05:00
Joseph Moreno
c345223fdc Fix window position on macOS 2023-02-11 11:35:53 -05:00
Joseph Moreno
8caed1f4d2 More fixes 2023-02-11 00:41:41 -05:00
Joseph Moreno
15ede9b17a Update dotnet.yml
Fixes for macOS artifact publish
2023-02-10 13:48:21 -05:00
Joseph Moreno
cc5c97e1d0 Update dotnet.yml 2023-02-10 13:42:06 -05:00
Joseph Moreno
ffcfefa065 Strip only for release 2023-02-10 13:37:09 -05:00
Joseph Moreno
350ac86ac4 Merge branch 'master' of https://github.com/josephmoresena/AvaloniaCoreRTDemo 2023-02-10 13:33:30 -05:00
Joseph Moreno
bb42d30511 Test bash fix 2023-02-10 13:33:19 -05:00
Joseph Moreno
53a2de07e7 Solution file Fix 2023-02-10 13:19:36 -05:00
Joseph Moreno
dcc47c332f Window Size
* Preserve window size when swapping Fluent and Simple themes.
* Simplify test batch files.
* Trim output.
* Different output type depending on the configuration.
2023-02-10 13:11:58 -05:00
Joseph Moreno
cd2a9d72aa * Datagrid fixes 2023-02-08 00:05:42 -05:00
Joseph Moreno
defcc0b360 Avalonia UI 11 Preview 5
* Menu fixes for macOS.
* Delete nuget.config.
* Nullable enabled.
* Fixes in ViewModel class names.
* ViewModel for MainControl as MainWindow state.
* Preserve window state when swapping Fluent and Simple themes.
2023-02-07 23:34:30 -05:00
Todor Totev
f80bc50f8a
Merge pull request #27 from josephmoresena/master
Fix macOS build
2022-12-12 23:46:50 +02:00
Joseph Moreno
b492413a12 Fix macOS build 2022-12-10 22:19:19 -05:00
Todor Totev
5ee6979980
Merge pull request #26 from maxkatz6/master
Update to Avalonia 11 with some AOT improvements
2022-11-25 20:29:47 +02:00
Todor Totev
d299480046
Merge branch 'master' into master 2022-11-20 12:31:08 +02:00
Maksym Katsydan
59bc165240 Update Avalonia with fixed NativeMenuBar in AOT 2022-11-19 23:48:23 -05:00
Maksym Katsydan
f55c202b93 Fix ChangeTheme 2022-11-19 22:49:03 -05:00
Maksym Katsydan
f35336bfe3 Update pipeline 2022-11-19 21:59:11 -05:00
Maksym Katsydan
d7ada47c16 Update Avalonia version 2022-11-13 17:45:20 -05:00
Maksym Katsydan
e52a5869ed Reopen window when theme was changed 2022-11-12 22:23:50 -05:00
Maksym Katsydan
18c8883f18 Update test scripts 2022-11-12 22:23:41 -05:00
Maksym Katsydan
caea418ab5 Add DataGrid to the About page 2022-11-12 17:03:35 -05:00
Maksym Katsydan
47f5732b84 Use net7 AOT 2022-11-12 03:48:48 -05:00
Maksym Katsydan
8459f9bf3b Use compiled bindings insteaed of reflection bindings 2022-11-12 02:34:54 -05:00
Maksym Katsydan
1246a011c9 Update Avalonia to 11.0 2022-11-12 02:34:36 -05:00
34 changed files with 773 additions and 702 deletions

View File

@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Publish
run: |
sudo chmod +x ./test.sh
@ -25,9 +25,9 @@ jobs:
with:
name: Linux-Artifact
path: |
./src/bin/x64/Release/net6.0/linux-x64/publish/*.bin
./src/bin/x64/Release/net6.0/linux-x64/publish/*.so
./src/bin/x64/Release/net6.0/linux-x64/publish/*.png
./src/bin/Release/net7.0/linux-x64/publish/*.bin
./src/bin/Release/net7.0/linux-x64/publish/*.so
./src/bin/Release/net7.0/linux-x64/publish/*.png
build-on-windows:
runs-on: windows-latest
steps:
@ -35,16 +35,16 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Publish
run: ./test.cmd
- uses: actions/upload-artifact@v2
with:
name: Windows-Artifact
path: |
.\src\bin\x64\Release\net6.0\win-x64\publish\*.exe
.\src\bin\x64\Release\net6.0\win-x64\publish\*.dll
.\src\bin\x64\Release\net6.0\win-x64\publish\*.png
.\src\bin\Release\net7.0\win-x64\publish\*.exe
.\src\bin\Release\net7.0\win-x64\publish\*.dll
.\src\bin\Release\net7.0\win-x64\publish\*.png
build-on-macos:
runs-on: macos-latest
steps:
@ -52,14 +52,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Publish
run: |
sudo chmod +x ./test.command
./test.command
cd ./src/bin/x64/Release/net6.0/osx-x64/publish
cd ./src/bin/Release/net7.0/osx-x64/publish
zip -r -0 macOS-Artifact.zip *.app
mv *.zip ../../../../../../../.
mv *.zip ../../../../../../.
- uses: actions/upload-artifact@v2
with:
name: macOS-Artifact

View File

@ -7,14 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaCoreRTDemo", "src\A
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41A52A04-F7D8-4981-9546-DB020E54851D}.Debug|x64.ActiveCfg = Debug|x64
{41A52A04-F7D8-4981-9546-DB020E54851D}.Debug|x64.Build.0 = Debug|x64
{41A52A04-F7D8-4981-9546-DB020E54851D}.Release|x64.ActiveCfg = Release|x64
{41A52A04-F7D8-4981-9546-DB020E54851D}.Release|x64.Build.0 = Release|x64
{41A52A04-F7D8-4981-9546-DB020E54851D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41A52A04-F7D8-4981-9546-DB020E54851D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41A52A04-F7D8-4981-9546-DB020E54851D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41A52A04-F7D8-4981-9546-DB020E54851D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -7,7 +7,7 @@ This project is tested only under Windows, and this readme assumes you are using
* Any supported 64-bit edition of Windows. NativeAOT requires 64-bit Windows and produces only 64-bit Windows apps.
* Visual Studio. VS 2022 Community is free for personal use. Get if from [here](https://visualstudio.microsoft.com).
When installing Visual Studio, select *.NET desktop development* and *Desktop development with C++* workloads. To generate native code, NativeAOT requires the native C++ toolchain and Windows SDK. This configuration ensures you have them.
* .Net 6.0 SDK. Download it from [here](https://dotnet.microsoft.com/download/dotnet/6.0). Note: Make sure that you download and install the *SDK*. The runtime is not enough for building apps.
* .Net 7.0 SDK. Download it from [here](https://dotnet.microsoft.com/download/dotnet/7.0). Note: Make sure that you download and install the *SDK*. The runtime is not enough for building apps.
* Git. Install [Git for Windows](https://git-scm.com/download/win).
## Getting started
@ -34,8 +34,6 @@ We are ready - In your terminal, navigate to `src\bin\Release\net6.0\win-x64\pub
Feel free to use this sample as a base for your projects.
When developing, keep in mind that Avalonia uses Reflection extensively. NativeAOT, being an AOT compiler, needs your help to get reflection right. Refer to `rd.xml` file in the solution. In it, you describe all assemblies and types which your app would potentially reflect over. For more information, see [Reflection in AOT mode](https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/reflection-in-aot-mode.md)
This project is configured to help you debug issues with publishing. Before publishing, check the CSPROJ file and modify the various Ilc* properties according to [Optimizing programs targeting Native AOT](https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/optimizing.md) document.
## Artifact test

26
src/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net7.0/linux-x64/AvaloniaCoreRTDemo.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

41
src/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/AvaloniaCoreRTDemo.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/AvaloniaCoreRTDemo.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/AvaloniaCoreRTDemo.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -1,18 +1,22 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaCoreRTDemo.App">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About" Gesture="cmd+b" IsEnabled="{Binding AboutEnabled}" Command="{Binding HelpAboutMethod}"/>
</NativeMenu>
</NativeMenu.Menu>
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseDark.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
</Application.Styles>
<Application.Resources>
<FluentTheme x:Key="fluentLight" Mode="Light" />
<FluentTheme x:Key="fluentDark" Mode="Dark" />
</Application.Resources>
</Application>
<Application
x:Class="AvaloniaCoreRTDemo.App"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels1="clr-namespace:AvaloniaCoreRTDemo.Windows.ViewModels"
x:CompileBindings="True"
x:DataType="viewModels1:ApplicationModelBase"
RequestedThemeVariant="Light">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem
Command="{Binding HelpAboutCommand}"
Gesture="cmd+b"
Header="About"
IsEnabled="{Binding AboutEnabled}" />
</NativeMenu>
</NativeMenu.Menu>
<Application.Resources>
<StyleInclude x:Key="fluentDataGrid" Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
<StyleInclude x:Key="simpleDataGrid" Source="avares://Avalonia.Controls.DataGrid/Themes/Simple.xaml" />
</Application.Resources>
</Application>

View File

@ -1,83 +1,108 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
using Avalonia.Themes.Fluent;
using Avalonia.Themes.Simple;
using AvaloniaCoreRTDemo.Interfaces;
using AvaloniaCoreRTDemo.Windows;
namespace AvaloniaCoreRTDemo
namespace AvaloniaCoreRTDemo;
public sealed class App : Application, IThemeSwitch
{
public sealed class App : Application, IThemeSwitch
private FluentTheme _fluentTheme = default!;
private SimpleTheme _simpleTheme = default!;
private IStyle _fluentDataGrid = default!;
private IStyle _simpleDataGrid = default!;
private ApplicationTheme _currentTheme;
public override void Initialize()
{
private IStyle _baseLight;
private IStyle _baseDark;
private IStyle _fluentLight;
private IStyle _fluentDark;
private ApplicationTheme _currentTheme;
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
this.Name = "AvaloniaCoreRTDemo";
}
public override void OnFrameworkInitializationCompleted()
{
this.InitializeThemes();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = !Utilities.IsOSX ? new MainWindow() : new MainWindowMacOS();
this.DataContext = desktop.MainWindow.DataContext;
}
base.OnFrameworkInitializationCompleted();
}
private void InitializeThemes()
{
this._baseDark = this.Styles[0];
this._baseLight = this.Styles[1];
this.Styles.Remove(this._baseDark);
this._fluentLight = (FluentTheme)this.Resources["fluentLight"]!;
this._fluentDark = (FluentTheme)this.Resources["fluentDark"]!;
this._currentTheme = ApplicationTheme.DefaultLight;
}
ApplicationTheme IThemeSwitch.Current => this._currentTheme;
void IThemeSwitch.ChangeTheme(ApplicationTheme theme)
{
this._currentTheme = theme;
switch (theme)
{
case ApplicationTheme.DefaultLight:
this.Styles[0] = this._baseLight;
this.Styles.Remove(this._baseDark);
break;
case ApplicationTheme.DefaultDark:
this.Styles[0] = this._baseDark;
this.Styles.Remove(this._baseLight);
break;
case ApplicationTheme.FluentLight:
this.Styles[0] = this._fluentLight;
this.Styles.Remove(this._fluentDark);
if (!this.Styles.Contains(this._baseLight))
this.Styles.Add(this._baseLight);
break;
case ApplicationTheme.FluentDark:
this.Styles[0] = this._fluentDark;
this.Styles.Remove(this._baseLight);
if (!this.Styles.Contains(this._baseDark))
this.Styles.Add(this._baseDark);
break;
}
}
AvaloniaXamlLoader.Load(this);
Name = "AvaloniaCoreRTDemo";
}
}
public override void OnFrameworkInitializationCompleted()
{
InitializeThemes();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
DataContext = desktop.MainWindow.DataContext;
}
base.OnFrameworkInitializationCompleted();
}
private void InitializeThemes()
{
_simpleTheme = new SimpleTheme();
_fluentTheme = new FluentTheme();
_fluentDataGrid = (IStyle)Resources["fluentDataGrid"]!;
_simpleDataGrid = (IStyle)Resources["simpleDataGrid"]!;
Styles.Add(_fluentTheme);
Styles.Add(_fluentDataGrid);
_currentTheme = ApplicationTheme.FluentLight;
}
ApplicationTheme IThemeSwitch.Current => _currentTheme;
void IThemeSwitch.ChangeTheme(ApplicationTheme theme)
{
if (theme == _currentTheme)
return;
var themeChanged = theme switch
{
ApplicationTheme.SimpleLight
=> _currentTheme is ApplicationTheme.FluentDark or ApplicationTheme.FluentLight,
ApplicationTheme.SimpleDark
=> _currentTheme is ApplicationTheme.FluentDark or ApplicationTheme.FluentLight,
ApplicationTheme.FluentLight
=> _currentTheme is ApplicationTheme.SimpleLight or ApplicationTheme.SimpleDark,
ApplicationTheme.FluentDark
=> _currentTheme is ApplicationTheme.SimpleLight or ApplicationTheme.SimpleDark,
_ => throw new ArgumentOutOfRangeException(nameof(theme), theme, null)
};
_currentTheme = theme;
switch (theme)
{
case ApplicationTheme.SimpleLight:
SetValue(ThemeVariantScope.ActualThemeVariantProperty, ThemeVariant.Light);
Styles[0] = _simpleTheme;
Styles[1] = _simpleDataGrid;
break;
case ApplicationTheme.SimpleDark:
SetValue(ThemeVariantScope.ActualThemeVariantProperty, ThemeVariant.Dark);
Styles[0] = _simpleTheme;
Styles[1] = _simpleDataGrid;
break;
case ApplicationTheme.FluentLight:
SetValue(ThemeVariantScope.ActualThemeVariantProperty, ThemeVariant.Light);
Styles[0] = _fluentTheme;
Styles[1] = _fluentDataGrid;
break;
case ApplicationTheme.FluentDark:
SetValue(ThemeVariantScope.ActualThemeVariantProperty, ThemeVariant.Dark);
Styles[0] = _fluentTheme;
Styles[1] = _fluentDataGrid;
break;
}
if (!themeChanged || ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
var oldWindow = (desktop.MainWindow as MainWindow)!;
var newWindow = new MainWindow(oldWindow);
desktop.MainWindow = newWindow;
DataContext = newWindow.DataContext;
oldWindow.Hide();
newWindow.Show();
oldWindow.Close();
}
}

View File

@ -1,12 +1,9 @@
using System;
namespace AvaloniaCoreRTDemo;
namespace AvaloniaCoreRTDemo
public enum ApplicationTheme : byte
{
public enum ApplicationTheme : Byte
{
DefaultLight = 0,
DefaultDark = 1,
FluentLight = 2,
FluentDark = 3,
}
SimpleLight = 0,
SimpleDark = 1,
FluentLight = 2,
FluentDark = 3,
}

View File

@ -2,59 +2,69 @@
<PropertyGroup>
<!-- if you want to check exceptions, change this to "Exe" and start your app from the console -->
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x64</Platforms>
<OutputType Condition="'$(Configuration.toUpper())' != 'DEBUG'">WinExe</OutputType>
<OutputType Condition="'$(Configuration.toUpper())' == 'DEBUG'">Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ApplicationIcon>Assets/app.ico</ApplicationIcon>
<InvariantGlobalization>true</InvariantGlobalization>
<!--https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options-->
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
<DefineConstants Condition="'$(IsOSX)'=='true'">OSX</DefineConstants>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<SelfContained>true</SelfContained>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<!--Tthese can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md -->
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
</PropertyGroup>
<PropertyGroup>
<TrimMode>link</TrimMode>
<!--These can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md -->
<!--RootAllApplicationAssemblies: False -> TrimMode:link See https://github.com/dotnet/runtimelab/issues/597 and https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/optimizing.md -->
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcGenerateStackTraceData Condition="'$(Configuration.toUpper())' != 'DEBUG'">false</IlcGenerateStackTraceData>
<IlcDisableUnhandledExceptionExperience>true</IlcDisableUnhandledExceptionExperience>
<StripSymbols Condition="'$(Configuration.toUpper())' != 'DEBUG'">true</StripSymbols>
</PropertyGroup>
<!-- Instruct NativeAOT to use this native dependency, required to build Avalonia. This library comes from the Windows SDK. -->
<ItemGroup Condition="'$(IsWindows)'=='true'">
<NativeLibrary Include="WindowsApp.lib" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Include="Assets/**" />
<EmbeddedResource Include="Images/**" />
<None Update="avalonia.png" CopyToPublishDirectory="PreserveNewest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="dotnet.png" CopyToPublishDirectory="PreserveNewest">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<AvaloniaResource Include="Images/**" />
<None Update="Assets/app.icns" CopyToPublishDirectory="PreserveNewest" Condition="$(RuntimeIdentifier.StartsWith('osx'))">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="dotnet.png">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="avalonia.png">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Assembly.SimulatedCallingAssembly" Value="true" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia.Native" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.1.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.1.3" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.1.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.3" />
<!--Condition below is needed to generate macOS App only.-->
<PackageReference Include="Dotnet.Bundle" Version="*" Condition="$(RuntimeIdentifier.StartsWith('osx'))" />
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" Condition="$(RuntimeIdentifier.StartsWith('osx'))" />
<PackageReference Include="MvvmGen.PureCodeGeneration" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<!-- Information for Dotnet.Bundle to Generate macOS app-->
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<PropertyGroup>
<CFBundleName>$(AssemblyName)</CFBundleName>
<CFBundleDisplayName>$(AssemblyName)</CFBundleDisplayName>
<CFBundleIdentifier>com.$(username).$(AssemblyName)</CFBundleIdentifier>
@ -69,40 +79,5 @@
<!-- Optional -->
<NSRequiresAquaSystemAppearance>true</NSRequiresAquaSystemAppearance>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="8.0.0-*" />
<!-- Avalonia relies heavily on reflection. Describe types reflected upon here. -->
<RdXmlFile Include="rd.xml" />
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Assembly.SimulatedCallingAssembly" Value="true" />
</ItemGroup>
<!--App axaml-->
<ItemGroup>
<Compile Update="App.axaml.cs">
<DependentUpon>App.axaml</DependentUpon>
</Compile>
</ItemGroup>
<!--Cross platform xaml-->
<ItemGroup>
<Compile Update="Controls/MainControl.axaml.cs">
<DependentUpon>MainControl.axaml</DependentUpon>
</Compile>
<Compile Update="Windows/AboutWindow.axaml.cs">
<DependentUpon>AboutWindow.axaml</DependentUpon>
</Compile>
</ItemGroup>
<!--No-OSX only xaml-->
<ItemGroup Condition="'$(IsOSX)'!='true'">
<Compile Update="Windows/MainWindow.axaml.cs">
<DependentUpon>MainWindow.axaml</DependentUpon>
</Compile>
</ItemGroup>
<!--OSX only xaml-->
<ItemGroup Condition="'$(IsOSX)'=='true'">
<Compile Update="Windows/MainWindowMacOS.axaml.cs">
<DependentUpon>MainWindowMacOS.axaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>

View File

@ -1,9 +1,44 @@
<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="AvaloniaCoreRTDemo.Controls.MainControl">
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto,*" Margin="32">
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" TextAlignment="Center" Margin="0,6">Welcome to Avalonia UI + NativeAOT!</TextBlock>
<Image Grid.Row="1" Grid.Column="0" Stretch="None" Source="{Binding DotNetImage}"/>
<Image Grid.Row="1" Grid.Column="1" Stretch="None" Source="{Binding AvaloniaImage}"/>
<TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Watermark="Type here" AcceptsReturn="True" TextWrapping="Wrap"/>
</Grid>
<UserControl
x:Class="AvaloniaCoreRTDemo.Controls.MainControl"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:AvaloniaCoreRTDemo.Controls.ViewModels"
d:DesignHeight="450"
d:DesignWidth="800"
x:CompileBindings="True"
x:DataType="viewModels:MainControlViewModel"
mc:Ignorable="d">
<Grid
Margin="32"
ColumnDefinitions="*,*"
RowDefinitions="Auto,Auto,*">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,6"
TextAlignment="Center">
Welcome to Avalonia UI + NativeAOT!
</TextBlock>
<Image
Grid.Row="1"
Grid.Column="0"
Source="{Binding DotNetImage}"
Stretch="None" />
<Image
Grid.Row="1"
Grid.Column="1"
Source="{Binding AvaloniaImage}"
Stretch="None" />
<TextBox
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
AcceptsReturn="True"
Text="{Binding Text}"
TextWrapping="Wrap"
Watermark="Type here" />
</Grid>
</UserControl>

View File

@ -1,21 +1,24 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaCoreRTDemo.Controls.ViewModels;
namespace AvaloniaCoreRTDemo.Controls
{
public sealed partial class MainControl : UserControl
{
public MainControl()
{
InitializeComponent();
}
namespace AvaloniaCoreRTDemo.Controls;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
this.DataContext = new MainViewModel();
}
public sealed partial class MainControl : UserControl
{
public MainControl()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
DataContext = new MainControlViewModel();
}
public void Reload(IMainWindowState model)
{
DataContext = new MainControlViewModel(model);
}
}

View File

@ -0,0 +1,45 @@
using Avalonia.Media.Imaging;
namespace AvaloniaCoreRTDemo.Controls.ViewModels;
[ViewModel]
internal sealed partial class MainControlViewModel : IMainWindowState
{
private Bitmap _dotNetImage;
private Bitmap _avaloniaImage;
private bool _unloadable = false;
public Bitmap DotNetImage => _dotNetImage;
public Bitmap AvaloniaImage => _avaloniaImage;
public string? Text { get; set; }
partial void OnInitialize()
{
_dotNetImage = Utilities.GetImageFromFile("dotnet.png");
_avaloniaImage = Utilities.GetImageFromFile("avalonia.png");
}
public MainControlViewModel(IMainWindowState state)
: this()
{
_avaloniaImage = state.AvaloniaImage;
_dotNetImage = state.DotNetImage;
Text = state.Text;
state.SetUnloadable();
}
~MainControlViewModel()
{
if (!_unloadable)
{
_dotNetImage.Dispose();
_avaloniaImage.Dispose();
}
}
void IMainWindowState.SetUnloadable()
{
_unloadable = true;
}
}

View File

@ -1,34 +0,0 @@
using System;
using System.IO;
using Avalonia.Media.Imaging;
using ReactiveUI;
namespace AvaloniaCoreRTDemo.Controls.ViewModels
{
internal sealed class MainViewModel : ReactiveObject
{
private readonly IBitmap _dotNetImage;
private readonly IBitmap _avaloniaImage;
public IBitmap DotNetImage => this._dotNetImage;
public IBitmap AvaloniaImage => this._avaloniaImage;
public MainViewModel()
{
this._dotNetImage = Utilities.GetImageFromFile(GetImageFullPath("dotnet.png"));
this._avaloniaImage = Utilities.GetImageFromFile(GetImageFullPath("avalonia.png"));
}
private static String GetImageFullPath(String fileName)
=> Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);
~MainViewModel()
{
this._dotNetImage.Dispose();
this._avaloniaImage.Dispose();
}
}
}

3
src/GlobalUsings.cs Normal file
View File

@ -0,0 +1,3 @@
// Global using directives
global using MvvmGen;

View File

@ -1,9 +1,14 @@
using AvaloniaCoreRTDemo.Interfaces;
using Avalonia;
using Avalonia.Controls;
namespace AvaloniaCoreRTDemo
namespace AvaloniaCoreRTDemo.Interfaces;
public interface IMainWindow
{
public interface IMainWindow
{
IThemeSwitch ThemeSwitch { get; }
}
IThemeSwitch ThemeSwitch { get; }
IMainWindowState Model { get; }
PixelPoint Position { get; }
Size ClientSize { get; }
Size? FrameSize { get; }
WindowState State { get; }
}

View File

@ -0,0 +1,12 @@
using Avalonia.Media.Imaging;
namespace AvaloniaCoreRTDemo;
public interface IMainWindowState
{
Bitmap DotNetImage { get; }
Bitmap AvaloniaImage { get; }
string? Text { get; }
void SetUnloadable();
}

View File

@ -1,8 +1,7 @@
namespace AvaloniaCoreRTDemo.Interfaces
namespace AvaloniaCoreRTDemo.Interfaces;
public interface IThemeSwitch
{
public interface IThemeSwitch
{
ApplicationTheme Current { get; }
void ChangeTheme(ApplicationTheme theme);
}
ApplicationTheme Current { get; }
void ChangeTheme(ApplicationTheme theme);
}

View File

@ -1,21 +1,16 @@
using Avalonia;
namespace AvaloniaCoreRTDemo
namespace AvaloniaCoreRTDemo;
public static class Program
{
public static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) =>
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>().UsePlatformDetect()
.UseAvaloniaNativeOSX()
.LogToTrace();
private static AppBuilder UseAvaloniaNativeOSX(this AppBuilder appBuilder)
=> Utilities.IsOSX ? appBuilder.UseAvaloniaNative() : appBuilder;
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace();
}

View File

@ -1,39 +1,44 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
namespace AvaloniaCoreRTDemo
namespace AvaloniaCoreRTDemo;
internal static class Utilities
{
internal static class Utilities
public static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static readonly bool IsOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
public static Bitmap GetImageFromResources(string fileName)
{
public static readonly Boolean IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static readonly Boolean IsOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
using var assetStream = AssetLoader.Open(
new Uri($"avares://AvaloniaCoreRTDemo/Images/{fileName}")
);
return new Bitmap(assetStream);
}
public static Bitmap GetImageFromResources(String fileName)
public static PixelPoint GetWindowPosition(Window window)
{
if (!IsOSX || !window.FrameSize.HasValue)
return window.Position;
var yOffset = (int)(window.FrameSize.Value.Height - window.ClientSize.Height);
return new(window.Position.X, window.Position.Y + yOffset);
}
public static Bitmap GetImageFromFile(string path)
{
try
{
Assembly asm = Assembly.GetExecutingAssembly();
String resourceName = asm.GetManifestResourceNames().FirstOrDefault(str => str.EndsWith(fileName));
if (resourceName != null)
using (Stream bitmapStream = asm.GetManifestResourceStream(resourceName))
return new Bitmap(bitmapStream);
else
return default;
return new Bitmap(GetImageFullPath(path));
}
public static Bitmap GetImageFromFile(String path)
catch (Exception)
{
try
{
return new Bitmap(path);
}
catch (Exception)
{
return GetImageFromResources("broken-link.png");
}
return GetImageFromResources("broken-link.png");
}
}
private static string GetImageFullPath(string fileName) =>
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);
}

View File

@ -1,64 +1,50 @@
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" x:Class="AvaloniaCoreRTDemo.Windows.AboutWindow" d:DesignWidth="640" d:DesignHeight="256"
WindowState="Normal" WindowStartupLocation="CenterOwner" MinHeight="256" MinWidth="640" Height="256" Width="640" MaxHeight="256" MaxWidth="640" Title="About" CanResize="false" ShowInTaskbar="False" Icon="avares://AvaloniaCoreRTDemo/Assets/about.ico">
<Grid VerticalAlignment="Top" HorizontalAlignment="Left" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<Image Margin="0, 60" Grid.Row="0" Grid.Column="0" Stretch="None" Source="{Binding ComputerImage}" VerticalAlignment="Top" HorizontalAlignment="Left">
</Image>
<ScrollViewer Margin="0, 10" Width="500" Height="230" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<Grid ColumnDefinitions="Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Grid Grid.Row="0" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Number of Cores: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding NCores}"/>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="OS: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding OS}"/>
</Grid>
<Grid Grid.Row="2" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="OS Arch: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding OSArch}"/>
</Grid>
<Grid Grid.Row="3" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="OS Version: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding OSVersion}"/>
</Grid>
<Grid Grid.Row="4" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Computer: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding ComputerName}"/>
</Grid>
<Grid Grid.Row="5" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="User: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding UserName}"/>
</Grid>
<Grid Grid.Row="6" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="System Path: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding SystemPath}"/>
</Grid>
<Grid Grid.Row="7" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Current Path: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding CurrentPath}"/>
</Grid>
<Grid Grid.Row="8" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Process Arch: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding ProcessArch}"/>
</Grid>
<Grid Grid.Row="9" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Runtime Name: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding RuntimeName}"/>
</Grid>
<Grid Grid.Row="10" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Runtime Path: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding RuntimePath}"/>
</Grid>
<Grid Grid.Row="11" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Runtime Version: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding RuntimeVersion}"/>
</Grid>
<Grid Grid.Row="12" Grid.Column="0" ColumnDefinitions="Auto,Auto" RowDefinitions="Auto">
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" FontWeight="Bold" Text="Framework Version: "/>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left" Text="{Binding FrameworkVersion}"/>
</Grid>
</Grid>
</ScrollViewer>
</Grid>
<Window
x:Class="AvaloniaCoreRTDemo.Windows.AboutWindow"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:AvaloniaCoreRTDemo.Windows.ViewModels"
Title="About"
Height="256"
MaxWidth="840"
d:DesignHeight="256"
d:DesignWidth="640"
x:CompileBindings="True"
x:DataType="viewModels:AboutViewModel"
CanResize="false"
Icon="avares://AvaloniaCoreRTDemo/Assets/about.ico"
ShowInTaskbar="False"
SizeToContent="Width"
WindowStartupLocation="CenterOwner"
WindowState="Normal"
mc:Ignorable="d">
<Grid
HorizontalAlignment="Left"
VerticalAlignment="Top"
ColumnDefinitions="Auto,*">
<Image
Grid.Column="0"
Margin="0,60"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="{Binding ComputerImage}"
Stretch="None" />
<DataGrid
Grid.Column="1"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
HeadersVisibility="None"
IsReadOnly="True"
ItemsSource="{Binding SystemDetails}">
<DataGrid.Columns>
<DataGridTextColumn
Binding="{Binding Key, x:DataType=viewModels:SystemDetail}"
FontWeight="Bold"
Header="Key" />
<DataGridTextColumn Binding="{Binding Value, x:DataType=viewModels:SystemDetail}" Header="Value" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

View File

@ -1,28 +1,28 @@
using System;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaCoreRTDemo.Windows.ViewModels;
namespace AvaloniaCoreRTDemo.Windows
namespace AvaloniaCoreRTDemo.Windows;
public sealed partial class AboutWindow : Window
{
public sealed partial class AboutWindow : Window
private readonly bool _darkTheme;
public AboutWindow()
: this(false) { }
public AboutWindow(bool darkTheme)
{
public AboutWindow()
{
this.InitializeComponent();
}
_darkTheme = darkTheme;
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
public AboutWindow(Boolean darkTheme)
{
this.InitializeComponent(darkTheme);
}
private void InitializeComponent(Boolean darkTheme = default)
{
AvaloniaXamlLoader.Load(this);
this.DataContext = new AboutViewModel(darkTheme);
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
DataContext = new AboutViewModel(_darkTheme);
}
}

View File

@ -1,21 +1,66 @@
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:AvaloniaCoreRTDemo.Controls" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="AvaloniaCoreRTDemo.Windows.MainWindow"
Width="640" Height="480" WindowStartupLocation="CenterScreen" Title="AvaloniaCoreRTDemo" Icon="avares://AvaloniaCoreRTDemo/Assets/app.ico" MinWidth="400" MinHeight="350">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem Header="_Exit" Command="{Binding FileExitCommand}"/>
</MenuItem>
<MenuItem Header="_Theme">
<MenuItem Header="Default Light" IsEnabled="{Binding DefaultLightEnabled}" Command="{Binding DefaultLightMethod}"/>
<MenuItem Header="Default Dark" IsEnabled="{Binding DefaultDarkEnabled}" Command="{Binding DefaultDarkMethod}"/>
<MenuItem Header="Fluent Light" IsEnabled="{Binding FluentLightEnabled}" Command="{Binding FluentLightMethod}"/>
<MenuItem Header="Fluent Dark" IsEnabled="{Binding FluentDarkEnabled}" Command="{Binding FluentDarkMethod}"/>
</MenuItem>
<MenuItem Header="_Help">
<MenuItem Header="_About" IsEnabled="{Binding AboutEnabled}" Command="{Binding HelpAboutMethod}"/>
</MenuItem>
</Menu>
<controls:MainControl/>
</DockPanel>
</Window>
<Window
x:Class="AvaloniaCoreRTDemo.Windows.MainWindow"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:AvaloniaCoreRTDemo.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels1="clr-namespace:AvaloniaCoreRTDemo.Windows.ViewModels"
Title="AvaloniaCoreRTDemo"
Width="640"
Height="480"
MinWidth="400"
MinHeight="350"
d:DesignHeight="450"
d:DesignWidth="800"
x:CompileBindings="True"
x:DataType="viewModels1:ApplicationModelBase"
Icon="avares://AvaloniaCoreRTDemo/Assets/app.ico"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<DockPanel>
<NativeMenuBar DockPanel.Dock="Top" />
<controls:MainControl Name="MainControl" />
</DockPanel>
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="File">
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem
Command="{Binding FileExitCommand}"
Gesture="cmd+e"
Header="Exit" />
<NativeMenuItem
Command="{Binding HelpAboutCommand}"
Gesture="cmd+b"
Header="About"
IsEnabled="{Binding AboutEnabled}" />
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
<NativeMenuItem Header="Theme">
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem
Command="{Binding DefaultLightCommand}"
Header="Default Light"
IsEnabled="{Binding DefaultLightEnabled}" />
<NativeMenuItem
Command="{Binding DefaultDarkCommand}"
Header="Default Dark"
IsEnabled="{Binding DefaultDarkEnabled}" />
<NativeMenuItem
Command="{Binding FluentLightCommand}"
Header="Fluent Light"
IsEnabled="{Binding FluentLightEnabled}" />
<NativeMenuItem
Command="{Binding FluentDarkCommand}"
Header="Fluent Dark"
IsEnabled="{Binding FluentDarkEnabled}" />
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
</NativeMenu>
</NativeMenu.Menu>
</Window>

View File

@ -1,28 +1,48 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaCoreRTDemo.Interfaces;
using AvaloniaCoreRTDemo.Windows.ViewModels;
namespace AvaloniaCoreRTDemo.Windows
{
public sealed partial class MainWindow : Window, IMainWindow
{
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
this.DataContext = new MainViewModel<MainWindow>(this);
}
IThemeSwitch IMainWindow.ThemeSwitch => App.Current as IThemeSwitch;
}
}
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaCoreRTDemo.Controls;
using AvaloniaCoreRTDemo.Interfaces;
using AvaloniaCoreRTDemo.Windows.ViewModels;
namespace AvaloniaCoreRTDemo.Windows;
public sealed partial class MainWindow : Window, IMainWindow
{
private readonly Application? _app = Application.Current;
private MainControl MainController => this.GetControl<MainControl>("MainControl");
public MainWindow()
: this(default) { }
public MainWindow(IMainWindow? window)
{
InitializeComponent(window);
#if DEBUG
this.AttachDevTools();
#endif
}
IThemeSwitch IMainWindow.ThemeSwitch => (IThemeSwitch)_app!;
IMainWindowState IMainWindow.Model => (IMainWindowState)this.MainController.DataContext!;
PixelPoint IMainWindow.Position => Utilities.GetWindowPosition(this);
Size IMainWindow.ClientSize => ClientSize;
Size? IMainWindow.FrameSize => FrameSize;
WindowState IMainWindow.State => WindowState;
private void InitializeComponent(IMainWindow? window)
{
AvaloniaXamlLoader.Load(this);
DataContext = new MainViewModel<MainWindow>(this);
if (window is not null)
{
this.MainController.Reload(window.Model);
WindowStartupLocation = WindowStartupLocation.Manual;
WindowState = window.State;
Position = window.Position;
FrameSize = window.FrameSize;
ClientSize = window.ClientSize;
}
}
}

View File

@ -1,26 +0,0 @@
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:AvaloniaCoreRTDemo.Controls" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="AvaloniaCoreRTDemo.Windows.MainWindowMacOS"
Width="640" Height="480" WindowStartupLocation="CenterScreen" Title="AvaloniaCoreRTDemo" Icon="avares://AvaloniaCoreRTDemo/Assets/app.ico" MinWidth="400" MinHeight="350">
<controls:MainControl/>
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="File">
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem Header="Exit" Gesture="cmd+e" Command="{Binding FileExitCommand}"/>
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
<NativeMenuItem Header="Theme">
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem Header="Default Light" IsEnabled="{Binding DefaultLightEnabled}" Command="{Binding DefaultLightMethod}"/>
<NativeMenuItem Header="Default Dark" IsEnabled="{Binding DefaultDarkEnabled}" Command="{Binding DefaultDarkMethod}"/>
<NativeMenuItem Header="Fluent Light" IsEnabled="{Binding FluentLightEnabled}" Command="{Binding FluentLightMethod}"/>
<NativeMenuItem Header="Fluent Dark" IsEnabled="{Binding FluentDarkEnabled}" Command="{Binding FluentDarkMethod}"/>
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
</NativeMenu>
</NativeMenu.Menu>
</Window>

View File

@ -1,28 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaCoreRTDemo.Interfaces;
using AvaloniaCoreRTDemo.Windows.ViewModels;
namespace AvaloniaCoreRTDemo.Windows
{
public partial class MainWindowMacOS : Window, IMainWindow
{
public MainWindowMacOS()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
this.DataContext = new MainViewModel<MainWindowMacOS>(this);
}
IThemeSwitch IMainWindow.ThemeSwitch => App.Current as IThemeSwitch;
}
}

View File

@ -1,54 +1,56 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using Avalonia.Media.Imaging;
using ReactiveUI;
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
namespace AvaloniaCoreRTDemo.Windows.ViewModels
internal record SystemDetail(string Key, string Value);
[ViewModel]
internal sealed partial class AboutViewModel
{
internal sealed class AboutViewModel : ReactiveObject
private readonly Bitmap _computerImage;
private readonly bool _darkTheme;
public Bitmap ComputerImage => _computerImage;
public IReadOnlyList<SystemDetail> SystemDetails { get; } =
[
new SystemDetail("Number of Cores", Environment.ProcessorCount.ToString()),
new SystemDetail("OS", RuntimeInformation.OSDescription),
new SystemDetail("OS Arch", RuntimeInformation.OSArchitecture.ToString()),
new SystemDetail("OS Version", Environment.OSVersion.ToString()),
new SystemDetail("Computer", Environment.MachineName),
new SystemDetail("User", Environment.UserName),
new SystemDetail("System Path", Environment.SystemDirectory),
new SystemDetail("Current Path", Environment.CurrentDirectory),
new SystemDetail("Process Arch", RuntimeInformation.ProcessArchitecture.ToString()),
new SystemDetail("Runtime Name", RuntimeInformation.FrameworkDescription),
new SystemDetail("Runtime Path", RuntimeEnvironment.GetRuntimeDirectory()),
new SystemDetail("Runtime Version", RuntimeEnvironment.GetSystemVersion()),
new SystemDetail("Framework Version", Environment.Version.ToString())
];
private string ComputerImageName
{
private readonly IBitmap _computerImage;
private readonly Boolean _darkTheme;
public IBitmap ComputerImage => _computerImage;
public static String NCores => Environment.ProcessorCount.ToString();
public static String OS => RuntimeInformation.OSDescription;
public static String OSArch => RuntimeInformation.OSArchitecture.ToString();
public static String OSVersion => Environment.OSVersion.ToString();
public static String ComputerName => Environment.MachineName;
public static String UserName => Environment.UserName;
public static String SystemPath => Environment.SystemDirectory;
public static String CurrentPath => Environment.CurrentDirectory;
public static String ProcessArch => RuntimeInformation.ProcessArchitecture.ToString();
public static String RuntimeName => RuntimeInformation.FrameworkDescription;
public static String RuntimePath => RuntimeEnvironment.GetRuntimeDirectory();
public static String RuntimeVersion => RuntimeEnvironment.GetSystemVersion();
public static String FrameworkVersion => Environment.Version.ToString();
private String ComputerImageName
get
{
get
{
if (Utilities.IsWindows)
return !this._darkTheme ? "windows.png" : "windows_d.png";
else if (Utilities.IsOSX)
return !this._darkTheme ? "macos.png" : "macos_d.png";
else
return !this._darkTheme ? "linux.png" : "linux_d.png";
}
}
public AboutViewModel(Boolean darkTheme)
{
this._darkTheme = darkTheme;
this._computerImage = Utilities.GetImageFromResources(this.ComputerImageName);
}
~AboutViewModel()
{
this._computerImage.Dispose();
if (Utilities.IsWindows)
return !_darkTheme ? "windows.png" : "windows_d.png";
if (Utilities.IsOSX)
return !_darkTheme ? "macos.png" : "macos_d.png";
return !_darkTheme ? "linux.png" : "linux_d.png";
}
}
public AboutViewModel(bool darkTheme)
: this()
{
_darkTheme = darkTheme;
_computerImage = Utilities.GetImageFromResources(ComputerImageName);
}
~AboutViewModel()
{
_computerImage.Dispose();
}
}

View File

@ -0,0 +1,86 @@
using Avalonia.Controls;
using AvaloniaCoreRTDemo.Interfaces;
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
[ViewModel]
internal abstract partial class ApplicationModelBase
{
private readonly IThemeSwitch _themeSwitch;
[Property]
private bool _aboutEnabled = true;
[Property]
private bool _defaultLightEnabled;
[Property]
private bool _defaultDarkEnabled;
[Property]
private bool _fluentLightEnabled;
[Property]
private bool _fluentDarkEnabled;
public ApplicationModelBase(IThemeSwitch themeSwitch)
: this()
{
_themeSwitch = themeSwitch;
InitializeTheme(themeSwitch.Current);
}
[Command]
protected abstract void HelpAbout();
[Command]
protected abstract void DefaultLight();
[Command]
protected abstract void DefaultDark();
[Command]
protected abstract void FluentLight();
[Command]
protected abstract void FluentDark();
protected async void RunHelpAbout(Window currentWindow)
{
if (AboutEnabled)
try
{
AboutEnabled = false;
await new AboutWindow(IsDarkTheme(_themeSwitch.Current)).ShowDialog(currentWindow);
}
finally
{
AboutEnabled = true;
}
}
protected void SetTheme(ApplicationTheme theme)
{
InitializeTheme(theme);
_themeSwitch.ChangeTheme(theme);
}
[Command]
private void FileExit() => Environment.Exit(0);
private void InitializeTheme(ApplicationTheme theme)
{
DefaultLightEnabled = theme != ApplicationTheme.SimpleLight;
DefaultDarkEnabled = theme != ApplicationTheme.SimpleDark;
FluentLightEnabled = theme != ApplicationTheme.FluentLight;
FluentDarkEnabled = theme != ApplicationTheme.FluentDark;
}
private static bool IsDarkTheme(ApplicationTheme? theme) =>
theme switch
{
ApplicationTheme.SimpleDark => true,
ApplicationTheme.FluentDark => true,
_ => false,
};
}

View File

@ -1,72 +1,26 @@
using System;
using System.Reactive;
using Avalonia.Controls;
using AvaloniaCoreRTDemo.Interfaces;
using Avalonia.Controls;
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
using ReactiveUI;
namespace AvaloniaCoreRTDemo.Windows.ViewModels
internal sealed class MainViewModel<TWindow> : ApplicationModelBase
where TWindow : Window, IMainWindow
{
internal sealed class MainViewModel<TWindow> : MainViewModelBase
where TWindow : Window, IMainWindow
private readonly TWindow _window;
public MainViewModel(TWindow window)
: base(window.ThemeSwitch)
{
private readonly TWindow _window;
private Boolean _defaultLightEnable = true;
private Boolean _defaultDarkEnable = true;
private Boolean _fluentLightEnable = true;
private Boolean _fluentDarkEnable = true;
public Boolean DefaultLightEnabled
{
get => this._defaultLightEnable;
set => this.RaiseAndSetIfChanged(ref this._defaultLightEnable, value);
}
public Boolean DefaultDarkEnabled
{
get => this._defaultDarkEnable;
set => this.RaiseAndSetIfChanged(ref this._defaultDarkEnable, value);
}
public Boolean FluentLightEnabled
{
get => this._fluentLightEnable;
set => this.RaiseAndSetIfChanged(ref this._fluentLightEnable, value);
}
public Boolean FluentDarkEnabled
{
get => this._fluentDarkEnable;
set => this.RaiseAndSetIfChanged(ref this._fluentDarkEnable, value);
}
public ReactiveCommand<Unit, Unit> FileExitCommand { get; }
public MainViewModel(TWindow window)
: base(window.ThemeSwitch)
{
this._window = window;
this.FileExitCommand = ReactiveCommand.Create(RunFileExit);
this.ChangeTheme(window.ThemeSwitch.Current);
}
public void DefaultLightMethod() => this.ChangeTheme(ApplicationTheme.DefaultLight);
public void DefaultDarkMethod() => this.ChangeTheme(ApplicationTheme.DefaultDark);
public void FluentLightMethod() => this.ChangeTheme(ApplicationTheme.FluentLight);
public void FluentDarkMethod() => this.ChangeTheme(ApplicationTheme.FluentDark);
public override void HelpAboutMethod() => base.RunHelpAbout(this._window);
private void RunFileExit()
=> Environment.Exit(0);
private void ChangeTheme(ApplicationTheme theme)
{
this.DefaultLightEnabled = theme != ApplicationTheme.DefaultLight && theme != ApplicationTheme.FluentLight;
this.DefaultDarkEnabled = theme != ApplicationTheme.DefaultDark && theme != ApplicationTheme.FluentDark;
this.FluentLightEnabled = theme != ApplicationTheme.FluentLight;
this.FluentDarkEnabled = theme != ApplicationTheme.FluentDark;
this._window.ThemeSwitch?.ChangeTheme(theme);
}
_window = window;
}
protected override void HelpAbout() => RunHelpAbout(_window);
protected override void DefaultLight() => SetTheme(ApplicationTheme.SimpleLight);
protected override void DefaultDark() => SetTheme(ApplicationTheme.SimpleDark);
protected override void FluentLight() => SetTheme(ApplicationTheme.FluentLight);
protected override void FluentDark() => SetTheme(ApplicationTheme.FluentDark);
}

View File

@ -1,49 +0,0 @@
using System;
using Avalonia.Controls;
using AvaloniaCoreRTDemo.Interfaces;
using ReactiveUI;
namespace AvaloniaCoreRTDemo.Windows.ViewModels
{
internal abstract class MainViewModelBase : ReactiveObject
{
private readonly IThemeSwitch _themeSwitch;
private Boolean _aboutEnable = true;
public Boolean AboutEnabled
{
get => this._aboutEnable;
set => this.RaiseAndSetIfChanged(ref this._aboutEnable, value);
}
public MainViewModelBase(IThemeSwitch window)
=> this._themeSwitch = window;
public abstract void HelpAboutMethod();
protected async void RunHelpAbout(Window currentWindow)
{
if (this.AboutEnabled)
try
{
this.AboutEnabled = false;
await new AboutWindow(IsDarkTheme(this._themeSwitch.Current)).ShowDialog(currentWindow);
}
finally
{
this.AboutEnabled = true;
}
}
private static Boolean IsDarkTheme(ApplicationTheme? theme)
=> theme switch
{
ApplicationTheme.DefaultDark => true,
ApplicationTheme.FluentDark => true,
_ => false,
};
}
}

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
<!--<add key="avalonia" value="https://nuget.avaloniaui.net/repository/avalonia-all/index.json" />-->
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

View File

@ -1,48 +0,0 @@
<Directives>
<Application>
<!-- main app assembly provides types which needs to be reflected upon -->
<Assembly Name="AvaloniaCoreRTDemo" Dynamic="Required All"></Assembly>
<!-- these are needed when you show images and draw text -->
<Assembly Name="Avalonia.Animation">
<Type Name="Avalonia.Animation.Easings.QuadraticEaseIn" Dynamic="Required All" />
<Type Name="Avalonia.Animation.Easings.QuadraticEaseOut" Dynamic="Required All" />
<Type Name="Avalonia.Animation.Easings.CubicEaseOut" Dynamic="Required All" />
<Type Name="Avalonia.Animation.Easings.LinearEasing" Dynamic="Required All" />
</Assembly>
<Assembly Name="Avalonia.Themes.Default" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Visuals" Dynamic="Required All">
<Type Name="Avalonia.Media.SolidColorBrush" Dynamic="Required All" />
</Assembly>
<Assembly Name="SkiaSharp" Dynamic="Required All"></Assembly>
<!-- To support Fluent themes trimming the final assembly we need to add this entry -->
<Assembly Name="Avalonia.Themes.Fluent" Dynamic="Required All"></Assembly>
<!-- Not known if and when you need these:
<Assembly Name="Avalonia.Controls" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Base" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Interactivity" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Layout" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Markup" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Markup.Xaml" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Styling" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.DesktopRuntime" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.DesignerSupport" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Diagnostics" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Dialogs" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Input" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Logging.Serilog" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.OpenGL" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Desktop" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Direct2D1" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.ReactiveUI" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Skia" Dynamic="Required All"></Assembly>
<Assembly Name="Avalonia.Win32" Dynamic="Required All"></Assembly>
<Assembly Name="ReactiveUI" Dynamic="Required All"></Assembly>
<Assembly Name="System.Reactive" Dynamic="Required All"></Assembly>
<Assembly Name="Splat" Dynamic="Required All"></Assembly>
-->
</Application>
</Directives>

View File

@ -1,2 +1,2 @@
del src\packages.lock.json
dotnet publish -r win-x64 -c release /p:RestoreLockedMode=true /p:TrimLink=true --self-contained
dotnet publish -r win-x64 -c Release /p:RestoreLockedMode=true

View File

@ -4,10 +4,7 @@ if [ -d "$dir" ]; then
cd "$dir"
fi
rm -f src/packages.lock.json
dotnet publish -r osx-x64 -c release /p:RestoreLockedMode=true -t:BundleApp /p:TrimLink=true --self-contained
rm -rf src/bin/x64/Release/net6.0/osx-x64/publish/Assets/
strip src/bin/x64/Release/net6.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo
rm -rf src/bin/x64/Release/net6.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/Assets/
rm src/bin/x64/Release/net6.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.runtimeconfig.json
rm src/bin/x64/Release/net6.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.pdb
rm src/bin/x64/Release/net6.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.deps.json
dotnet publish -r osx-x64 -c Release /p:RestoreLockedMode=true -t:BundleApp
rm -rf src/bin/Release/net7.0/osx-x64/publish/Assets/
rm -rf src/bin/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/Assets/
rm src/bin/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.dwarf

View File

@ -1,6 +1,5 @@
#!/bin/bash
rm -f src/packages.lock.json
dotnet publish -r linux-x64 -c release /p:RestoreLockedMode=true /p:TrimLink=true --self-contained
cd src/bin/x64/Release/net6.0/linux-x64/publish
dotnet publish -r linux-x64 -c Release /p:RestoreLockedMode=true
cd src/bin/Release/net7.0/linux-x64/publish
cp AvaloniaCoreRTDemo AvaloniaCoreRTDemo.bin
strip AvaloniaCoreRTDemo.bin