Skip to content

Commit d0e68dd

Browse files
committed
another minor glow window change
1 parent 90ed85f commit d0e68dd

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

MahApps.Metro/Behaviours/GlowWindowBehavior.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,35 @@ public class GlowWindowBehavior : Behavior<Window>
1616
private GlowWindow left, right, top, bottom;
1717
private DispatcherTimer makeGlowVisibleTimer;
1818
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+
}
1937

2038
protected override void OnAttached()
2139
{
2240
base.OnAttached();
2341

2442
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+
}
2548
handle = new WindowInteropHelper(this.AssociatedObject).Handle;
2649
var hwndSource = HwndSource.FromHwnd(handle);
2750
if (hwndSource != null)
@@ -98,8 +121,7 @@ private void HideGlow()
98121
private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs)
99122
{
100123
// 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)
103125
{
104126
return;
105127
}
@@ -121,8 +143,7 @@ private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEvent
121143
this.Show();
122144
this.Update();
123145

124-
var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled;
125-
if (!windowTransitionsEnabled)
146+
if (!this.IsWindowTransitionsEnabled)
126147
{
127148
// no storyboard so set opacity to 1
128149
this.SetOpacityTo(1);

0 commit comments

Comments
 (0)