Created
March 7, 2012 04:52
-
-
Save developerdizzle/1990997 to your computer and use it in GitHub Desktop.
Base class for a WPF Window that automatically enables Aero/Glass effects (if available on Windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.WindowsAPICodePack.Shell; | |
namespace System.Windows | |
{ | |
public class AutomaticGlassWindow : GlassWindow | |
{ | |
public AutomaticGlassWindow() { | |
this.AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(AutomaticGlassWindow_AeroGlassCompositionChanged); | |
} | |
void AutomaticGlassWindow_AeroGlassCompositionChanged(object sender, AeroGlassCompositionChangedEventArgs e) | |
{ | |
this.UpdateGlass(e.GlassAvailable); | |
} | |
protected override void OnSourceInitialized(EventArgs e) | |
{ | |
base.OnSourceInitialized(e); | |
this.UpdateGlass(GlassWindow.AeroGlassCompositionEnabled); | |
} | |
private void UpdateGlass(bool aeroEnabled) | |
{ | |
if (aeroEnabled) | |
{ | |
this.SetAeroGlassTransparency(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment