@@ -673,13 +673,13 @@ private void SetBlurForWindow(string theme, BackdropTypes backdropType)
673673 // If the BackdropType is Mica or MicaAlt, set the windowborderstyle's background to transparent
674674 if ( backdropType == BackdropTypes . Mica || backdropType == BackdropTypes . MicaAlt )
675675 {
676- windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property . Name == "Background" ) ) ;
677- windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , new SolidColorBrush ( Color . FromArgb ( 1 , 0 , 0 , 0 ) ) ) ) ;
676+ windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property == Control . BackgroundProperty ) ) ;
677+ windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , ThemeHelper . GetFrozenSolidColorBrush ( Color . FromArgb ( 1 , 0 , 0 , 0 ) ) ) ) ;
678678 }
679679 else if ( backdropType == BackdropTypes . Acrylic )
680680 {
681- windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property . Name == "Background" ) ) ;
682- windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , new SolidColorBrush ( Colors . Transparent ) ) ) ;
681+ windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property == Control . BackgroundProperty ) ) ;
682+ windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , Brushes . Transparent ) ) ;
683683 }
684684
685685 // For themes with blur enabled, the window border is rendered by the system, so it's treated as a simple rectangle regardless of thickness.
@@ -798,12 +798,12 @@ private void ApplyPreviewBackground(Color? bgColor = null)
798798 Application . Current . Resources [ "WindowBorderStyle" ] is Style originalStyle )
799799 {
800800 // Copy the original style, including the base style if it exists
801- CopyStyle ( originalStyle , previewStyle ) ;
801+ ThemeHelper . CopyStyle ( originalStyle , previewStyle ) ;
802802 }
803803
804804 // Apply background color (remove transparency in color)
805- Color backgroundColor = Color . FromRgb ( bgColor . Value . R , bgColor . Value . G , bgColor . Value . B ) ;
806- previewStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , new SolidColorBrush ( backgroundColor ) ) ) ;
805+ var backgroundColor = Color . FromRgb ( bgColor . Value . R , bgColor . Value . G , bgColor . Value . B ) ;
806+ previewStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , ThemeHelper . GetFrozenSolidColorBrush ( backgroundColor ) ) ) ;
807807
808808 // The blur theme keeps the corner round fixed (applying DWM code to modify it causes rendering issues).
809809 // The non-blur theme retains the previously set WindowBorderStyle.
@@ -817,21 +817,6 @@ private void ApplyPreviewBackground(Color? bgColor = null)
817817 Application . Current . Resources [ "PreviewWindowBorderStyle" ] = previewStyle ;
818818 }
819819
820- private void CopyStyle ( Style originalStyle , Style targetStyle )
821- {
822- // If the style is based on another style, copy the base style first
823- if ( originalStyle . BasedOn != null )
824- {
825- CopyStyle ( originalStyle . BasedOn , targetStyle ) ;
826- }
827-
828- // Copy the setters from the original style
829- foreach ( var setter in originalStyle . Setters . OfType < Setter > ( ) )
830- {
831- targetStyle . Setters . Add ( new Setter ( setter . Property , setter . Value ) ) ;
832- }
833- }
834-
835820 private void ColorizeWindow ( string theme , BackdropTypes backdropType )
836821 {
837822 var dict = GetThemeResourceDictionary ( theme ) ;
@@ -917,11 +902,11 @@ private void ColorizeWindow(string theme, BackdropTypes backdropType)
917902 // Only set the background to transparent if the theme supports blur
918903 if ( backdropType == BackdropTypes . Mica || backdropType == BackdropTypes . MicaAlt )
919904 {
920- mainWindow . Background = new SolidColorBrush ( Color . FromArgb ( 1 , 0 , 0 , 0 ) ) ;
905+ mainWindow . Background = ThemeHelper . GetFrozenSolidColorBrush ( Color . FromArgb ( 1 , 0 , 0 , 0 ) ) ;
921906 }
922907 else
923908 {
924- mainWindow . Background = new SolidColorBrush ( selectedBG ) ;
909+ mainWindow . Background = ThemeHelper . GetFrozenSolidColorBrush ( selectedBG ) ;
925910 }
926911 }
927912 }
0 commit comments