コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Guerra24/LRReader
 private void SetTheme(IntPtr hwnd)
 {
     if (!IsWin11)
     {
         if (ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark)
         {
             LeftBorder.Background  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2B2B2B"));
             RightBorder.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#202020"));
         }
         else
         {
             LeftBorder.Background  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FBFBFB"));
             RightBorder.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F3F3F3"));
         }
     }
     else
     {
         int trueValue  = 0x01;
         int falseValue = 0x00;
         if (ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark)
         {
             Dwmapi.DwmSetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref trueValue, Marshal.SizeOf(typeof(int)));
         }
         else
         {
             Dwmapi.DwmSetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref falseValue, Marshal.SizeOf(typeof(int)));
         }
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Guerra24/LRReader
        private void EnableMica(IntPtr hwnd)
        {
            if (!IsWin11)
            {
                return;
            }
            int trueValue = 0x01;

            if (IsPublicApi)
            {
                int flag = (int)DWM_SYSTEMBACKDROP_TYPE.DWMSBT_MAINWINDOW;
                Dwmapi.DwmSetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_SYSTEMBACKDROP_TYPE, ref flag, Marshal.SizeOf(typeof(int)));
            }
            else
            {
                Dwmapi.DwmSetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_MICA_EFFECT, ref trueValue, Marshal.SizeOf(typeof(int)));
            }
        }