@@ -16,12 +16,35 @@ public class GlowWindowBehavior : Behavior<Window>
16
16
private GlowWindow left , right , top , bottom ;
17
17
private DispatcherTimer makeGlowVisibleTimer ;
18
18
private IntPtr handle ;
19
+
20
+ private bool IsGlowDisabled
21
+ {
22
+ get
23
+ {
24
+ var metroWindow = this . AssociatedObject as MetroWindow ;
25
+ return metroWindow != null && ( metroWindow . UseNoneWindowStyle || metroWindow . GlowBrush == null ) ;
26
+ }
27
+ }
28
+
29
+ private bool IsWindowTransitionsEnabled
30
+ {
31
+ get
32
+ {
33
+ var metroWindow = this . AssociatedObject as MetroWindow ;
34
+ return metroWindow != null && metroWindow . WindowTransitionsEnabled ;
35
+ }
36
+ }
19
37
20
38
protected override void OnAttached ( )
21
39
{
22
40
base . OnAttached ( ) ;
23
41
24
42
this . AssociatedObject . SourceInitialized += ( o , args ) => {
43
+ // No glow effect if UseNoneWindowStyle is true or GlowBrush not set.
44
+ if ( this . IsGlowDisabled )
45
+ {
46
+ return ;
47
+ }
25
48
handle = new WindowInteropHelper ( this . AssociatedObject ) . Handle ;
26
49
var hwndSource = HwndSource . FromHwnd ( handle ) ;
27
50
if ( hwndSource != null )
@@ -98,8 +121,7 @@ private void HideGlow()
98
121
private void AssociatedObjectOnLoaded ( object sender , RoutedEventArgs routedEventArgs )
99
122
{
100
123
// No glow effect if UseNoneWindowStyle is true or GlowBrush not set.
101
- var metroWindow = this . AssociatedObject as MetroWindow ;
102
- if ( metroWindow != null && ( metroWindow . UseNoneWindowStyle || metroWindow . GlowBrush == null ) )
124
+ if ( this . IsGlowDisabled )
103
125
{
104
126
return ;
105
127
}
@@ -121,8 +143,7 @@ private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEvent
121
143
this . Show ( ) ;
122
144
this . Update ( ) ;
123
145
124
- var windowTransitionsEnabled = metroWindow != null && metroWindow . WindowTransitionsEnabled ;
125
- if ( ! windowTransitionsEnabled )
146
+ if ( ! this . IsWindowTransitionsEnabled )
126
147
{
127
148
// no storyboard so set opacity to 1
128
149
this . SetOpacityTo ( 1 ) ;
0 commit comments