Skip to content

Commit

Permalink
Merge pull request #30 from lippkg/develop
Browse files Browse the repository at this point in the history
refactor with winui3
  • Loading branch information
futrime authored Jan 15, 2024
2 parents a75326c + 308173c commit 9b4af16
Show file tree
Hide file tree
Showing 174 changed files with 8,692 additions and 5,348 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ permissions:
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
framework:
- net462
- net7.0-windows
runtime:
- win10-x64
steps:
- uses: actions/checkout@v3

Expand All @@ -25,10 +18,10 @@ jobs:

- name: Build
run: |
dotnet publish src/LipUI/LipUI.csproj -c Release -f ${{ matrix.framework }} -o build/ -r ${{ matrix.runtime }} --sc true
dotnet publish src/LipUI.sln -c Release
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.framework }}-${{ matrix.runtime }}
name: net7.0-windows-win10-x64
path: |
build/
src/LipUI/bin/Release/net7.0-windows10.0.19041.0/win10-x64/publish/
26 changes: 6 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ permissions:
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
framework:
- net462
- net7.0-windows
runtime:
- win10-x64
steps:
- uses: actions/checkout@v3

Expand All @@ -25,31 +18,24 @@ jobs:

- name: Build
run: |
dotnet publish src/LipUI/LipUI.csproj -c Release -f ${{ matrix.framework }} -o build/ -r ${{ matrix.runtime }} --sc true
dotnet publish src/LipUI.sln -c Release
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.framework }}-${{ matrix.runtime }}
name: net7.0-windows-win10-x64
path: |
build/
src/LipUI/bin/Release/net7.0-windows10.0.19041.0/win10-x64/publish/
upload-to-release:
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
framework:
- net462
- net7.0-windows
runtime:
- win10-x64
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: ${{ matrix.framework }}-${{ matrix.runtime }}
name: net7.0-windows-win10-x64
path: artifacts/

- name: Copy essential files
Expand All @@ -59,12 +45,12 @@ jobs:
- name: Pack artifacts
run: |
cd artifacts
zip -9r ../lipui-${{ matrix.framework }}-${{ matrix.runtime }}.zip *
zip -9r ../lipui-net7.0-windows-win10-x64.zip *
cd ..
- name: Upload artifacts to release
uses: softprops/action-gh-release@v1
with:
append_body: true
files: |
lipui-${{ matrix.framework }}-${{ matrix.runtime }}.zip
lipui-net7.0-windows-win10-x64.zip
54 changes: 31 additions & 23 deletions src/LipUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,44 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LipUI", "LipUI\LipUI.csproj", "{7AFA9B27-6BD1-4BE1-AEA3-EA560BAD4289}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LipNETWrapper", "LipNETWrapper\LipNETWrapper.csproj", "{A274FAC9-3169-4EAB-A659-4090F8D6E568}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LipNETWrapperTest", "LipNETWrapperTest\LipNETWrapperTest.csproj", "{2245E398-21FD-4F05-87A8-C6E8E29A4685}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LipWebApi", "LipWebApi\LipWebApi.csproj", "{17569CD2-D4D2-4E10-927C-BECEAECF7786}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LipUI", "LipUI\LipUI.csproj", "{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7AFA9B27-6BD1-4BE1-AEA3-EA560BAD4289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AFA9B27-6BD1-4BE1-AEA3-EA560BAD4289}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AFA9B27-6BD1-4BE1-AEA3-EA560BAD4289}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AFA9B27-6BD1-4BE1-AEA3-EA560BAD4289}.Release|Any CPU.Build.0 = Release|Any CPU
{A274FAC9-3169-4EAB-A659-4090F8D6E568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A274FAC9-3169-4EAB-A659-4090F8D6E568}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A274FAC9-3169-4EAB-A659-4090F8D6E568}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A274FAC9-3169-4EAB-A659-4090F8D6E568}.Release|Any CPU.Build.0 = Release|Any CPU
{2245E398-21FD-4F05-87A8-C6E8E29A4685}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2245E398-21FD-4F05-87A8-C6E8E29A4685}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2245E398-21FD-4F05-87A8-C6E8E29A4685}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2245E398-21FD-4F05-87A8-C6E8E29A4685}.Release|Any CPU.Build.0 = Release|Any CPU
{17569CD2-D4D2-4E10-927C-BECEAECF7786}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17569CD2-D4D2-4E10-927C-BECEAECF7786}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17569CD2-D4D2-4E10-927C-BECEAECF7786}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17569CD2-D4D2-4E10-927C-BECEAECF7786}.Release|Any CPU.Build.0 = Release|Any CPU
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|Any CPU.ActiveCfg = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|Any CPU.Build.0 = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|Any CPU.Deploy.0 = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|ARM64.ActiveCfg = Debug|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|ARM64.Build.0 = Debug|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|ARM64.Deploy.0 = Debug|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x64.ActiveCfg = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x64.Build.0 = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x64.Deploy.0 = Debug|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x86.ActiveCfg = Debug|x86
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x86.Build.0 = Debug|x86
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Debug|x86.Deploy.0 = Debug|x86
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|Any CPU.ActiveCfg = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|Any CPU.Build.0 = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|Any CPU.Deploy.0 = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|ARM64.ActiveCfg = Release|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|ARM64.Build.0 = Release|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|ARM64.Deploy.0 = Release|ARM64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x64.ActiveCfg = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x64.Build.0 = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x64.Deploy.0 = Release|x64
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x86.ActiveCfg = Release|x86
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x86.Build.0 = Release|x86
{ADF26F0A-8BCE-4F01-ACA8-042B9EC35064}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
34 changes: 6 additions & 28 deletions src/LipUI/App.xaml
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>
123 changes: 28 additions & 95 deletions src/LipUI/App.xaml.cs
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;
}
}
}
11 changes: 0 additions & 11 deletions src/LipUI/AssemblyInfo.cs

This file was deleted.

Loading

0 comments on commit 9b4af16

Please sign in to comment.