diff --git a/src/Controls/MainControl.axaml b/src/Controls/MainControl.axaml index cdf5d75..d443c2d 100644 --- a/src/Controls/MainControl.axaml +++ b/src/Controls/MainControl.axaml @@ -1,5 +1,8 @@ - + Welcome to Avalonia UI + NativeAOT! diff --git a/src/Windows/AboutWindow.axaml b/src/Windows/AboutWindow.axaml index 8ef32d8..bcd4700 100644 --- a/src/Windows/AboutWindow.axaml +++ b/src/Windows/AboutWindow.axaml @@ -1,6 +1,9 @@ - + diff --git a/src/Windows/MainWindow.axaml b/src/Windows/MainWindow.axaml index 29db8e0..e82bf20 100644 --- a/src/Windows/MainWindow.axaml +++ b/src/Windows/MainWindow.axaml @@ -1,6 +1,10 @@ + xmlns:controls="clr-namespace:AvaloniaCoreRTDemo.Controls" + xmlns:viewModels1="clr-namespace:AvaloniaCoreRTDemo.Windows.ViewModels" + 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" + x:CompileBindings="True" + x:DataType="viewModels1:MainViewModelBase"> @@ -11,6 +15,7 @@ + diff --git a/src/Windows/ViewModels/AboutViewModel.cs b/src/Windows/ViewModels/AboutViewModel.cs index b09161e..c252ac3 100644 --- a/src/Windows/ViewModels/AboutViewModel.cs +++ b/src/Windows/ViewModels/AboutViewModel.cs @@ -13,19 +13,19 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels 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(); + public String NCores => Environment.ProcessorCount.ToString(); + public String OS => RuntimeInformation.OSDescription; + public String OSArch => RuntimeInformation.OSArchitecture.ToString(); + public String OSVersion => Environment.OSVersion.ToString(); + public String ComputerName => Environment.MachineName; + public String UserName => Environment.UserName; + public String SystemPath => Environment.SystemDirectory; + public String CurrentPath => Environment.CurrentDirectory; + public String ProcessArch => RuntimeInformation.ProcessArchitecture.ToString(); + public String RuntimeName => RuntimeInformation.FrameworkDescription; + public String RuntimePath => RuntimeEnvironment.GetRuntimeDirectory(); + public String RuntimeVersion => RuntimeEnvironment.GetSystemVersion(); + public String FrameworkVersion => Environment.Version.ToString(); private String ComputerImageName { diff --git a/src/Windows/ViewModels/MainViewModel.cs b/src/Windows/ViewModels/MainViewModel.cs index b1b295e..07cf63d 100644 --- a/src/Windows/ViewModels/MainViewModel.cs +++ b/src/Windows/ViewModels/MainViewModel.cs @@ -12,54 +12,21 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels { 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 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.SimpleLight); - public void DefaultDarkMethod() => this.ChangeTheme(ApplicationTheme.SimpleDark); - 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); - + public override void DefaultLightMethod() => this.ChangeTheme(ApplicationTheme.SimpleLight); + public override void DefaultDarkMethod() => this.ChangeTheme(ApplicationTheme.SimpleDark); + public override void FluentLightMethod() => this.ChangeTheme(ApplicationTheme.FluentLight); + public override void FluentDarkMethod() => this.ChangeTheme(ApplicationTheme.FluentDark); + private void ChangeTheme(ApplicationTheme theme) { this.DefaultLightEnabled = theme != ApplicationTheme.SimpleLight && theme != ApplicationTheme.FluentLight; diff --git a/src/Windows/ViewModels/MainViewModelBase.cs b/src/Windows/ViewModels/MainViewModelBase.cs index d2b0b53..f9d09da 100644 --- a/src/Windows/ViewModels/MainViewModelBase.cs +++ b/src/Windows/ViewModels/MainViewModelBase.cs @@ -1,5 +1,5 @@ using System; - +using System.Reactive; using Avalonia.Controls; using AvaloniaCoreRTDemo.Interfaces; @@ -12,6 +12,10 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels { private readonly IThemeSwitch _themeSwitch; private Boolean _aboutEnable = true; + private Boolean _defaultLightEnable = true; + private Boolean _defaultDarkEnable = true; + private Boolean _fluentLightEnable = true; + private Boolean _fluentDarkEnable = true; public Boolean AboutEnabled { @@ -20,10 +24,47 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels } public MainViewModelBase(IThemeSwitch window) - => this._themeSwitch = window; + { + this._themeSwitch = window; + this.FileExitCommand = ReactiveCommand.Create(RunFileExit); + } + 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 FileExitCommand { get; } + public abstract void HelpAboutMethod(); + public abstract void DefaultLightMethod(); + public abstract void DefaultDarkMethod(); + public abstract void FluentLightMethod(); + public abstract void FluentDarkMethod(); + + private void RunFileExit() + => Environment.Exit(0); + protected async void RunHelpAbout(Window currentWindow) { if (this.AboutEnabled)