InkCanvasForClass/Ink Canvas/Windows/HasNewUpdateWindow.xaml.cs

67 lines
2.0 KiB
C#
Raw Normal View History

2024-05-04 19:46:20 +08:00
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls.Helpers;
using System;
using System.Collections.Generic;
2024-05-04 21:10:42 +08:00
using System.Diagnostics;
2024-05-04 19:46:20 +08:00
using System.Linq;
2024-05-04 21:10:42 +08:00
using System.Runtime.InteropServices;
2024-05-04 19:46:20 +08:00
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
2024-05-04 21:10:42 +08:00
using System.Windows.Interop;
2024-05-04 19:46:20 +08:00
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Ink_Canvas
{
/// <summary>
/// HasNewUpdateWindow.xaml 的交互逻辑
/// </summary>
2024-05-04 21:10:42 +08:00
///
2024-05-04 19:46:20 +08:00
public partial class HasNewUpdateWindow : Window
{
2024-05-04 21:10:42 +08:00
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
private static bool UseImmersiveDarkMode(IntPtr handle, bool enabled)
{
if (IsWindows10OrGreater(17763))
{
var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
if (IsWindows10OrGreater(18985))
{
attribute = DWMWA_USE_IMMERSIVE_DARK_MODE;
}
int useImmersiveDarkMode = enabled ? 1 : 0;
return DwmSetWindowAttribute(handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
}
return false;
}
private static bool IsWindows10OrGreater(int build = -1)
{
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
}
2024-05-04 19:46:20 +08:00
public HasNewUpdateWindow()
{
InitializeComponent();
AnimationsHelper.ShowWithFadeIn(this, 0.25);
2024-05-04 21:10:42 +08:00
Trace.WriteLine(new WindowInteropHelper(this).Handle);
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
2024-05-04 19:46:20 +08:00
}
}
}