Skip to content

Commit

Permalink
[Refactor] 添加CurrentMianWindow属性。
Browse files Browse the repository at this point in the history
  • Loading branch information
zhh135 committed Feb 2, 2024
1 parent 6f0aa0b commit a9bdbbd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/HyPlayer.App/Helpers/TitleBarHelper.cs
Original file line number Diff line number Diff line change
@@ -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
{
}
}
3 changes: 3 additions & 0 deletions src/HyPlayer.App/Helpers/WindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using WinRT.Interop;
using HyPlayer.Views.Window;
using Microsoft.UI.Windowing;
using WinUIEx;

namespace HyPlayer.Helpers
{
Expand Down Expand Up @@ -89,6 +90,8 @@ static public void InitializeTitleBarForWindow(Window window, bool isTallTitleBa
static public List<Window> ActiveWindows { get { return _activeWindows; } }

static private List<Window> _activeWindows = new List<Window>();

static public readonly MainWindow CurrentMainWindow = (MainWindow)CreateWindow();
}
}

4 changes: 2 additions & 2 deletions src/HyPlayer.App/Services/ActivationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<INavigationService>().NavigateTo(typeof(Views.Pages.ErrorPage), ActivateEventArgs);
App.GetService<INavigationService>().NavigateTo(typeof(Views.Pages.HomePage), ActivateEventArgs);
}
MainWindow.Activate();
}
Expand Down

0 comments on commit a9bdbbd

Please sign in to comment.