file-scoped namespaces and other cleanup stuff
This commit is contained in:
parent
c2e7cc1a3c
commit
fc7cdceb05
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
@ -11,10 +9,10 @@ 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!;
|
||||
@ -106,5 +104,4 @@ namespace AvaloniaCoreRTDemo
|
||||
oldWindow.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
using System;
|
||||
namespace AvaloniaCoreRTDemo;
|
||||
|
||||
namespace AvaloniaCoreRTDemo
|
||||
public enum ApplicationTheme : byte
|
||||
{
|
||||
public enum ApplicationTheme : byte
|
||||
{
|
||||
SimpleLight = 0,
|
||||
SimpleDark = 1,
|
||||
FluentLight = 2,
|
||||
FluentDark = 3,
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
<PublishAot>true</PublishAot>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<SelfContained>true</SelfContained>
|
||||
<ImplicitUsing>enable</ImplicitUsing>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@ -61,6 +61,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PublishAotCompressed" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Information for Dotnet.Bundle to Generate macOS app-->
|
||||
|
@ -3,10 +3,10 @@ using Avalonia.Markup.Xaml;
|
||||
|
||||
using AvaloniaCoreRTDemo.Controls.ViewModels;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Controls
|
||||
namespace AvaloniaCoreRTDemo.Controls;
|
||||
|
||||
public sealed partial class MainControl : UserControl
|
||||
{
|
||||
public sealed partial class MainControl : UserControl
|
||||
{
|
||||
public MainControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -22,5 +22,4 @@ namespace AvaloniaCoreRTDemo.Controls
|
||||
{
|
||||
DataContext = new MainControlViewModel(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
using Avalonia.Media.Imaging;
|
||||
using MvvmGen;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Controls.ViewModels
|
||||
namespace AvaloniaCoreRTDemo.Controls.ViewModels;
|
||||
|
||||
[ViewModel]
|
||||
internal sealed partial class MainControlViewModel : IMainWindowState
|
||||
{
|
||||
[ViewModel]
|
||||
internal sealed partial class MainControlViewModel : IMainWindowState
|
||||
{
|
||||
private IBitmap _dotNetImage;
|
||||
private IBitmap _avaloniaImage;
|
||||
|
||||
@ -42,5 +42,4 @@ namespace AvaloniaCoreRTDemo.Controls.ViewModels
|
||||
{
|
||||
_unloadable = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Interfaces
|
||||
namespace AvaloniaCoreRTDemo.Interfaces;
|
||||
|
||||
public interface IMainWindow
|
||||
{
|
||||
public interface IMainWindow
|
||||
{
|
||||
IThemeSwitch ThemeSwitch { get; }
|
||||
IMainWindowState Model { get; }
|
||||
PixelPoint Position { get; }
|
||||
Size ClientSize { get; }
|
||||
Size? FrameSize { get; }
|
||||
WindowState State { get; }
|
||||
}
|
||||
}
|
@ -1,15 +1,12 @@
|
||||
using System;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
||||
using Avalonia.Media.Imaging;
|
||||
namespace AvaloniaCoreRTDemo;
|
||||
|
||||
namespace AvaloniaCoreRTDemo
|
||||
public interface IMainWindowState
|
||||
{
|
||||
public interface IMainWindowState
|
||||
{
|
||||
IBitmap DotNetImage { get; }
|
||||
IBitmap AvaloniaImage { get; }
|
||||
string? Text { get; }
|
||||
|
||||
void SetUnloadable();
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace AvaloniaCoreRTDemo.Interfaces
|
||||
namespace AvaloniaCoreRTDemo.Interfaces;
|
||||
|
||||
public interface IThemeSwitch
|
||||
{
|
||||
public interface IThemeSwitch
|
||||
{
|
||||
ApplicationTheme Current { get; }
|
||||
void ChangeTheme(ApplicationTheme theme);
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
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.
|
||||
@ -13,5 +13,4 @@ namespace AvaloniaCoreRTDemo
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>().UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
}
|
||||
}
|
@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
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);
|
||||
|
||||
@ -45,5 +43,4 @@ namespace AvaloniaCoreRTDemo
|
||||
}
|
||||
|
||||
private static string GetImageFullPath(string fileName) => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
using System;
|
||||
|
||||
using Avalonia;
|
||||
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) { }
|
||||
@ -28,5 +26,4 @@ namespace AvaloniaCoreRTDemo.Windows
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
DataContext = new AboutViewModel(_darkTheme);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,10 +6,10 @@ using AvaloniaCoreRTDemo.Controls;
|
||||
using AvaloniaCoreRTDemo.Interfaces;
|
||||
using AvaloniaCoreRTDemo.Windows.ViewModels;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Windows
|
||||
namespace AvaloniaCoreRTDemo.Windows;
|
||||
|
||||
public sealed partial class MainWindow : Window, IMainWindow
|
||||
{
|
||||
public sealed partial class MainWindow : Window, IMainWindow
|
||||
{
|
||||
private readonly Application? _app = Application.Current;
|
||||
|
||||
private MainControl MainController => this.GetControl<MainControl>("MainControl");
|
||||
@ -45,5 +45,4 @@ namespace AvaloniaCoreRTDemo.Windows
|
||||
ClientSize = window.ClientSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Avalonia.Media.Imaging;
|
||||
using MvvmGen;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
{
|
||||
internal record SystemDetail(string Key, string Value);
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
|
||||
|
||||
[ViewModel]
|
||||
internal sealed partial class AboutViewModel
|
||||
{
|
||||
internal record SystemDetail(string Key, string Value);
|
||||
|
||||
[ViewModel]
|
||||
internal sealed partial class AboutViewModel
|
||||
{
|
||||
private readonly IBitmap _computerImage;
|
||||
private readonly bool _darkTheme;
|
||||
|
||||
@ -58,5 +56,4 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
{
|
||||
_computerImage.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
using System;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
|
||||
using AvaloniaCoreRTDemo.Interfaces;
|
||||
using MvvmGen;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
|
||||
|
||||
[ViewModel]
|
||||
internal abstract partial class ApplicationModelBase
|
||||
{
|
||||
[ViewModel]
|
||||
internal abstract partial class ApplicationModelBase
|
||||
{
|
||||
private readonly IThemeSwitch _themeSwitch;
|
||||
|
||||
[Property]
|
||||
@ -86,5 +84,4 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
ApplicationTheme.FluentDark => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
using AvaloniaCoreRTDemo.Interfaces;
|
||||
using MvvmGen;
|
||||
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
namespace AvaloniaCoreRTDemo.Windows.ViewModels;
|
||||
|
||||
internal sealed class MainViewModel<TWindow> : ApplicationModelBase where TWindow : Window, IMainWindow
|
||||
{
|
||||
internal sealed class MainViewModel<TWindow> : ApplicationModelBase where TWindow : Window, IMainWindow
|
||||
{
|
||||
private TWindow _window;
|
||||
|
||||
public MainViewModel(TWindow window) : base(window.ThemeSwitch)
|
||||
@ -23,5 +22,4 @@ namespace AvaloniaCoreRTDemo.Windows.ViewModels
|
||||
protected override void FluentLight() => SetTheme(ApplicationTheme.FluentLight);
|
||||
|
||||
protected override void FluentDark() => SetTheme(ApplicationTheme.FluentDark);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user