From a9bdbbdfa835ec5fd7f4ed1680a4078cac0e3d6d Mon Sep 17 00:00:00 2001 From: zhh135 Date: Fri, 2 Feb 2024 22:32:08 +0800 Subject: [PATCH] =?UTF-8?q?[Refactor]=20=E6=B7=BB=E5=8A=A0CurrentMianWindo?= =?UTF-8?q?w=E5=B1=9E=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HyPlayer.App/Helpers/TitleBarHelper.cs | 12 ++++++++++++ src/HyPlayer.App/Helpers/WindowHelper.cs | 3 +++ src/HyPlayer.App/Services/ActivationService.cs | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/HyPlayer.App/Helpers/TitleBarHelper.cs diff --git a/src/HyPlayer.App/Helpers/TitleBarHelper.cs b/src/HyPlayer.App/Helpers/TitleBarHelper.cs new file mode 100644 index 0000000..326ba71 --- /dev/null +++ b/src/HyPlayer.App/Helpers/TitleBarHelper.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HyPlayer.Helpers +{ + class TitleBarHelper + { + } +} diff --git a/src/HyPlayer.App/Helpers/WindowHelper.cs b/src/HyPlayer.App/Helpers/WindowHelper.cs index a54d46d..f3590c2 100644 --- a/src/HyPlayer.App/Helpers/WindowHelper.cs +++ b/src/HyPlayer.App/Helpers/WindowHelper.cs @@ -9,6 +9,7 @@ using WinRT.Interop; using HyPlayer.Views.Window; using Microsoft.UI.Windowing; +using WinUIEx; namespace HyPlayer.Helpers { @@ -89,6 +90,8 @@ static public void InitializeTitleBarForWindow(Window window, bool isTallTitleBa static public List ActiveWindows { get { return _activeWindows; } } static private List _activeWindows = new List(); + + static public readonly MainWindow CurrentMainWindow = (MainWindow)CreateWindow(); } } diff --git a/src/HyPlayer.App/Services/ActivationService.cs b/src/HyPlayer.App/Services/ActivationService.cs index 3d0cc1d..3807c37 100644 --- a/src/HyPlayer.App/Services/ActivationService.cs +++ b/src/HyPlayer.App/Services/ActivationService.cs @@ -38,10 +38,10 @@ public async Task OnLaunchedAsync(object ActivateEventArgs) if(ActivatedEventArgs != null) { - Window MainWindow = WindowHelper.CreateWindow(); + Window MainWindow = WindowHelper.CurrentMainWindow; if (ActivatedEventArgs.Kind == ExtendedActivationKind.Launch) { - App.GetService().NavigateTo(typeof(Views.Pages.ErrorPage), ActivateEventArgs); + App.GetService().NavigateTo(typeof(Views.Pages.HomePage), ActivateEventArgs); } MainWindow.Activate(); }