This commit is contained in:
Lightczx
2024-05-31 11:38:36 +08:00
parent b8b9bb2436
commit 2cee94a529
9 changed files with 24 additions and 7 deletions

View File

@@ -59,7 +59,7 @@ public sealed partial class App : Application
public new void Exit()
{
XamlWindowLifetime.ApplicationExiting = true;
XamlLifetime.ApplicationExiting = true;
base.Exit();
}

View File

@@ -74,7 +74,7 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
if (serviceProvider.GetRequiredService<AppOptions>().IsNotifyIconEnabled)
{
XamlWindowLifetime.ApplicationLaunchedWithNotifyIcon = true;
XamlLifetime.ApplicationLaunchedWithNotifyIcon = true;
serviceProvider.GetRequiredService<App>().DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
_ = serviceProvider.GetRequiredService<NotifyIconController>();
}

View File

@@ -3,7 +3,7 @@
namespace Snap.Hutao.Core.Windowing;
internal static class XamlWindowLifetime
internal static class XamlLifetime
{
public static bool ApplicationLaunchedWithNotifyIcon { get; set; }

View File

@@ -99,7 +99,7 @@ internal sealed class XamlWindowController
private void OnWindowClosed(object sender, WindowEventArgs args)
{
if (XamlWindowLifetime.ApplicationLaunchedWithNotifyIcon && !XamlWindowLifetime.ApplicationExiting)
if (XamlLifetime.ApplicationLaunchedWithNotifyIcon && !XamlLifetime.ApplicationExiting)
{
args.Handled = true;
window.Hide();

View File

@@ -96,7 +96,7 @@ internal sealed class XamlWindowSubclass : IDisposable
}
}
if (XamlWindowLifetime.ApplicationExiting)
if (XamlLifetime.ApplicationExiting)
{
return default;
}

View File

@@ -3,6 +3,8 @@
namespace Snap.Hutao.Core;
// See %PROGRAMFILES(X86)%\Windows Kits\10\Platforms\UAP\
// Windows.Foundation.UniversalApiContract
internal enum WindowsVersion : ushort
{
/// <summary>

View File

@@ -11,7 +11,7 @@ using Windows.Graphics.Capture;
using Windows.Graphics.DirectX.Direct3D11;
using WinRT;
using static Snap.Hutao.Win32.ConstValues;
using static Snap.Hutao.Win32.D3D11;
using static Snap.Hutao.Win32.D3d11;
using static Snap.Hutao.Win32.Macros;
namespace Snap.Hutao.Service.Game.Automation.ScreenCapture;

View File

@@ -13,7 +13,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SA1313")]
[SuppressMessage("", "SYSLIB1054")]
internal static class D3D11
internal static class D3d11
{
[DllImport("d3d11.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern HRESULT CreateDirect3D11DeviceFromDXGIDevice(IDXGIDevice* dxgiDevice, IInspectable** graphicsDevice);

View File

@@ -0,0 +1,15 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Win32.Foundation;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace Snap.Hutao.Win32;
internal static class Dxgi
{
[DllImport("dxgi.dll", ExactSpelling = true, PreserveSig = false)]
[SupportedOSPlatform("windows8.1")]
public unsafe static extern HRESULT CreateDXGIFactory2([In] uint Flags, [In][Const] Guid* riid, [Out][ComOutPtr] void** ppFactory);
}