67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using Ink_Canvas.Helpers;
|
|
using iNKORE.UI.WPF.Modern.Controls.Helpers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
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;
|
|
using System.Windows.Interop;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace Ink_Canvas
|
|
{
|
|
/// <summary>
|
|
/// HasNewUpdateWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
///
|
|
|
|
|
|
public partial class HasNewUpdateWindow : Window
|
|
{
|
|
|
|
[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;
|
|
}
|
|
public HasNewUpdateWindow()
|
|
{
|
|
InitializeComponent();
|
|
AnimationsHelper.ShowWithFadeIn(this, 0.25);
|
|
Trace.WriteLine(new WindowInteropHelper(this).Handle);
|
|
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
|
|
}
|
|
}
|
|
}
|