@@ -24,7 +24,7 @@ public class Theme
24
24
{
25
25
#region Properties & Fields
26
26
27
- public bool BlurEnabled { get ; set ; }
27
+ public bool BlurEnabled { get ; private set ; }
28
28
29
29
private const string ThemeMetadataNamePrefix = "Name:" ;
30
30
private const string ThemeMetadataIsDarkPrefix = "IsDark:" ;
@@ -42,6 +42,8 @@ public class Theme
42
42
private static string DirectoryPath => Path . Combine ( Constant . ProgramDirectory , Folder ) ;
43
43
private static string UserDirectoryPath => Path . Combine ( DataLocation . DataDirectory ( ) , Folder ) ;
44
44
45
+ private Thickness _themeResizeBorderThickness ;
46
+
45
47
#endregion
46
48
47
49
#region Constructor
@@ -463,7 +465,7 @@ public void AddDropShadowEffectToCurrentTheme()
463
465
464
466
var effectSetter = new Setter
465
467
{
466
- Property = Border . EffectProperty ,
468
+ Property = UIElement . EffectProperty ,
467
469
Value = new DropShadowEffect
468
470
{
469
471
Opacity = 0.3 ,
@@ -473,12 +475,12 @@ public void AddDropShadowEffectToCurrentTheme()
473
475
}
474
476
} ;
475
477
476
- if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) is not Setter marginSetter )
478
+ if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == FrameworkElement . MarginProperty ) is not Setter marginSetter )
477
479
{
478
480
var margin = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ;
479
481
marginSetter = new Setter ( )
480
482
{
481
- Property = Border . MarginProperty ,
483
+ Property = FrameworkElement . MarginProperty ,
482
484
Value = margin ,
483
485
} ;
484
486
windowBorderStyle . Setters . Add ( marginSetter ) ;
@@ -508,12 +510,12 @@ public void RemoveDropShadowEffectFromCurrentTheme()
508
510
var dict = GetCurrentResourceDictionary ( ) ;
509
511
var windowBorderStyle = dict [ "WindowBorderStyle" ] as Style ;
510
512
511
- if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . EffectProperty ) is Setter effectSetter )
513
+ if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == UIElement . EffectProperty ) is Setter effectSetter )
512
514
{
513
515
windowBorderStyle . Setters . Remove ( effectSetter ) ;
514
516
}
515
517
516
- if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) is Setter marginSetter )
518
+ if ( windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == FrameworkElement . MarginProperty ) is Setter marginSetter )
517
519
{
518
520
var currentMargin = ( Thickness ) marginSetter . Value ;
519
521
var newMargin = new Thickness (
@@ -529,28 +531,41 @@ public void RemoveDropShadowEffectFromCurrentTheme()
529
531
UpdateResourceDictionary ( dict ) ;
530
532
}
531
533
534
+ public void SetResizeBoarderThickness ( WindowChrome windowChrome , bool resizeWindow )
535
+ {
536
+ if ( resizeWindow )
537
+ {
538
+ windowChrome . ResizeBorderThickness = _themeResizeBorderThickness ;
539
+ }
540
+ else
541
+ {
542
+ windowChrome . ResizeBorderThickness = new Thickness ( 0 ) ;
543
+ }
544
+ }
545
+
532
546
// because adding drop shadow effect will change the margin of the window,
533
547
// we need to update the window chrome thickness to correct set the resize border
534
- private static void SetResizeBoarderThickness ( Thickness ? effectMargin )
548
+ private void SetResizeBoarderThickness ( Thickness ? effectMargin )
535
549
{
536
550
var window = Application . Current . MainWindow ;
537
551
if ( WindowChrome . GetWindowChrome ( window ) is WindowChrome windowChrome )
538
552
{
539
- Thickness thickness ;
553
+ // Save the theme resize border thickness so that we can restore it if we change ResizeWindow setting
540
554
if ( effectMargin == null )
541
555
{
542
- thickness = SystemParameters . WindowResizeBorderThickness ;
556
+ _themeResizeBorderThickness = SystemParameters . WindowResizeBorderThickness ;
543
557
}
544
558
else
545
559
{
546
- thickness = new Thickness (
560
+ _themeResizeBorderThickness = new Thickness (
547
561
effectMargin . Value . Left + SystemParameters . WindowResizeBorderThickness . Left ,
548
562
effectMargin . Value . Top + SystemParameters . WindowResizeBorderThickness . Top ,
549
563
effectMargin . Value . Right + SystemParameters . WindowResizeBorderThickness . Right ,
550
564
effectMargin . Value . Bottom + SystemParameters . WindowResizeBorderThickness . Bottom ) ;
551
565
}
552
566
553
- windowChrome . ResizeBorderThickness = thickness ;
567
+ // Apply the resize border thickness to the window chrome
568
+ SetResizeBoarderThickness ( windowChrome , _settings . ResizeWindow ) ;
554
569
}
555
570
}
556
571
@@ -582,7 +597,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
582
597
{
583
598
AutoDropShadow ( useDropShadowEffect ) ;
584
599
}
585
- } , DispatcherPriority . Normal ) ;
600
+ } , DispatcherPriority . Render ) ;
586
601
}
587
602
588
603
/// <summary>
@@ -596,7 +611,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
596
611
var ( backdropType , _) = GetActualValue ( ) ;
597
612
598
613
SetBlurForWindow ( GetCurrentTheme ( ) , backdropType ) ;
599
- } , DispatcherPriority . Normal ) ;
614
+ } , DispatcherPriority . Render ) ;
600
615
}
601
616
602
617
/// <summary>
0 commit comments