-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from lippkg/develop
refactor with winui3
- Loading branch information
Showing
174 changed files
with
8,692 additions
and
5,348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,16 @@ | ||
<Application | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Application | ||
x:Class="LipUI.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
xmlns:helpers="clr-namespace:LipUI.Helpers" | ||
xmlns:language="clr-namespace:LipUI.Language" | ||
DispatcherUnhandledException="OnDispatcherUnhandledException" | ||
Exit="OnExit" | ||
Startup="OnStartup"> | ||
xmlns:local="using:LipUI"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ui:ThemesDictionary Theme="Dark"/> | ||
<ui:ControlsDictionary/> | ||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> | ||
<!-- Other merged dictionaries here --> | ||
</ResourceDictionary.MergedDictionaries> | ||
<language:Model x:Key="I18N"/> | ||
<Style TargetType="TextBlock" x:Key="Title"> | ||
<Setter Property="FontSize" Value="16"/> | ||
<Setter Property="VerticalAlignment" Value="Center"/> | ||
<Setter Property="FontFamily" Value="Microsoft YaHei"/> | ||
<Setter Property="TextWrapping" Value="Wrap"/> | ||
</Style> | ||
<helpers:HalfOriginalConverter x:Key="HalfOriginalConverter"/> | ||
<helpers:InvBooleanToVisibilityConverter x:Key="InvBooleanToVisibilityConverter"/> | ||
<helpers:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> | ||
<helpers:BooleanToVisibilityHiddenConverter x:Key="BooleanToVisibilityHiddenConverter"/> | ||
<helpers:MultiValueConverter x:Key="MultiValueConverter"/> | ||
<helpers:OpacityToVisibilityConverter x:Key="OpacityToVisibilityConverter"/> | ||
<helpers:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/> | ||
<helpers:StringNotEmptyToVisibilityConverter x:Key="StringNotEmptyToVisibilityConverter"/> | ||
<helpers:InvBooleanConverter x:Key="InvBooleanConverter"/> | ||
<helpers:BooleanToOpacityConverter x:Key="BooleanToOpacityConverter"/> | ||
<helpers:FeaturedTagConverter x:Key="FeaturedTagConverter"/> | ||
<helpers:StringFormatConverter x:Key="StringFormatConverter"/> | ||
<!-- Other app resources here --> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,48 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Windows; | ||
using System.Windows.Threading; | ||
using LipUI.Services; | ||
using LipUI.ViewModels; | ||
using LipUI.Views.Pages; | ||
using LipUI.Views.Windows; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Wpf.Ui.Mvvm.Contracts; | ||
using Wpf.Ui.Mvvm.Services; | ||
using LipUI.Models; | ||
using Microsoft.UI.Xaml; | ||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace LipUI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
} | ||
// The.NET Generic Host provides dependency injection, configuration, logging, and other services. | ||
// https://docs.microsoft.com/dotnet/core/extensions/generic-host | ||
// https://docs.microsoft.com/dotnet/core/extensions/dependency-injection | ||
// https://docs.microsoft.com/dotnet/core/extensions/configuration | ||
// https://docs.microsoft.com/dotnet/core/extensions/logging | ||
private static readonly IHost _host = Host | ||
.CreateDefaultBuilder() | ||
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); }) | ||
.ConfigureServices((context, services) => | ||
{ | ||
// App Host | ||
services.AddHostedService<ApplicationHostService>(); | ||
// Page resolver service | ||
services.AddSingleton<IPageService, PageService>(); | ||
// Theme manipulation | ||
services.AddSingleton<IThemeService, ThemeService>(); | ||
// TaskBar manipulation | ||
services.AddSingleton<ITaskBarService, TaskBarService>(); | ||
// Service containing navigation, same as INavigationWindow... but without window | ||
services.AddSingleton<INavigationService, NavigationService>(); | ||
// Main window with navigation | ||
services.AddScoped<INavigationWindow, MainWindow>(); | ||
services.AddScoped<MainWindowViewModel>(); | ||
// Views | ||
services.AddScoped<DashboardPage>(); | ||
services.AddScoped<DeveloperPage>(); | ||
services.AddScoped<ToothLocalPage>(); | ||
services.AddScoped<SettingsPage>(); | ||
services.AddScoped<InstallPage>(); | ||
services.AddScoped<UninstallPage>(); | ||
services.AddScoped<LipRegistryPage>(); | ||
services.AddScoped<LipWebPage>(); | ||
// ViewModels | ||
services.AddScoped<DashboardViewModel>(); | ||
services.AddScoped<DeveloperPageViewModel>(); | ||
services.AddScoped<ToothLocalModel>(); | ||
services.AddScoped<SettingsViewModel>(); | ||
services.AddScoped<InstallPageViewModel>(); | ||
services.AddScoped<UninstallPageViewModel>(); | ||
services.AddScoped<LipRegistryPageViewModel>(); | ||
services.AddScoped<LipWebPageViewModel>(); | ||
// Configuration | ||
//services.Configure<AppConfig>(context.Configuration.GetSection(nameof(AppConfig))); | ||
}).Build(); | ||
|
||
/// <summary> | ||
/// Gets registered service. | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
/// <typeparam name="T">Type of the service to get.</typeparam> | ||
/// <returns>Instance of the service or <see langword="null"/>.</returns> | ||
public static T GetService<T>() | ||
where T : class | ||
{ | ||
#pragma warning disable CS8603 | ||
return _host.Services.GetService(typeof(T)) as T; | ||
#pragma warning restore CS8603 | ||
} | ||
/// <summary> | ||
/// Occurs when the application is loading. | ||
/// </summary> | ||
private async void OnStartup(object sender, StartupEventArgs e) | ||
public App() | ||
{ | ||
await Global.Init(); | ||
await _host.StartAsync(); | ||
InitializeComponent(); | ||
|
||
Current.RequestedTheme = InternalServices.ApplicationTheme = Main.Config.PersonalizationSettings.ColorTheme switch | ||
{ | ||
ElementTheme.Dark => ApplicationTheme.Dark, | ||
ElementTheme.Light => ApplicationTheme.Light, | ||
ElementTheme.Default or _ => Current.RequestedTheme | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Occurs when the application is closing. | ||
/// Invoked when the application is launched. | ||
/// </summary> | ||
private async void OnExit(object sender, ExitEventArgs e) | ||
/// <param name="args">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
await _host.StopAsync(); | ||
|
||
_host.Dispose(); | ||
m_window = new MainWindow(); | ||
m_window.Activate(); | ||
|
||
UnhandledException += App_UnhandledException; | ||
} | ||
|
||
/// <summary> | ||
/// Occurs when an exception is thrown by an application but not handled. | ||
/// </summary> | ||
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) | ||
private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e) | ||
{ | ||
// For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0 | ||
} | ||
|
||
internal Window? m_window; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.