From a7c164477cec5d4c33a00a4d7357110bf73008e7 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 10 Mar 2014 13:34:46 +0100 Subject: [PATCH 1/3] introduce VSWindowStyleKey --- MahApps.Metro/MahApps.Metro.NET45.csproj | 4 ++++ MahApps.Metro/MahApps.Metro.csproj | 4 ++++ MahApps.Metro/Styles/VS/Styles.xaml | 1 + MahApps.Metro/Styles/VS/Window.xaml | 16 ++++++++++++++++ samples/MetroDemo/ExampleWindows/VSDemo.xaml | 2 +- 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 MahApps.Metro/Styles/VS/Window.xaml diff --git a/MahApps.Metro/MahApps.Metro.NET45.csproj b/MahApps.Metro/MahApps.Metro.NET45.csproj index a2226c343e..e1bbfe4686 100644 --- a/MahApps.Metro/MahApps.Metro.NET45.csproj +++ b/MahApps.Metro/MahApps.Metro.NET45.csproj @@ -411,6 +411,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/MahApps.Metro/MahApps.Metro.csproj b/MahApps.Metro/MahApps.Metro.csproj index 7085c55ef8..b13ff55070 100644 --- a/MahApps.Metro/MahApps.Metro.csproj +++ b/MahApps.Metro/MahApps.Metro.csproj @@ -420,6 +420,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/MahApps.Metro/Styles/VS/Styles.xaml b/MahApps.Metro/Styles/VS/Styles.xaml index e633eec44b..64836e6a33 100644 --- a/MahApps.Metro/Styles/VS/Styles.xaml +++ b/MahApps.Metro/Styles/VS/Styles.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + diff --git a/MahApps.Metro/Styles/VS/Window.xaml b/MahApps.Metro/Styles/VS/Window.xaml new file mode 100644 index 0000000000..72c3c3783c --- /dev/null +++ b/MahApps.Metro/Styles/VS/Window.xaml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/samples/MetroDemo/ExampleWindows/VSDemo.xaml b/samples/MetroDemo/ExampleWindows/VSDemo.xaml index 6888acef3e..dc622e2ca9 100644 --- a/samples/MetroDemo/ExampleWindows/VSDemo.xaml +++ b/samples/MetroDemo/ExampleWindows/VSDemo.xaml @@ -7,7 +7,7 @@ Height="800" Width="1000" WindowStartupLocation="CenterScreen" - TitleForeground="#999988"> + Style="{DynamicResource VSWindowStyleKey}"> From 1f9a65f4fe60b718a0c78bbab740eebf2b40e040 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 10 Mar 2014 13:37:24 +0100 Subject: [PATCH 2/3] fix GlowWindowBehaviour fix GlowWindowBehaviour to use styled window properties e.g. a GlowBrush can now set via style --- .../Behaviours/GlowWindowBehavior.cs | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/MahApps.Metro/Behaviours/GlowWindowBehavior.cs b/MahApps.Metro/Behaviours/GlowWindowBehavior.cs index ec05f21ecf..d53a2507cc 100644 --- a/MahApps.Metro/Behaviours/GlowWindowBehavior.cs +++ b/MahApps.Metro/Behaviours/GlowWindowBehavior.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Interactivity; using MahApps.Metro.Controls; @@ -12,6 +13,11 @@ protected override void OnAttached() { base.OnAttached(); + this.AssociatedObject.Loaded += AssociatedObjectOnLoaded; + } + + private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs) + { // now glow effect if UseNoneWindowStyle is true or GlowBrush not set var metroWindow = this.AssociatedObject as MetroWindow; if (metroWindow != null && (metroWindow.UseNoneWindowStyle || metroWindow.GlowBrush == null)) @@ -19,41 +25,37 @@ protected override void OnAttached() return; } - this.AssociatedObject.Loaded += (sender, e) => - { - this.left = new GlowWindow(this.AssociatedObject, GlowDirection.Left); - this.right = new GlowWindow(this.AssociatedObject, GlowDirection.Right); - this.top = new GlowWindow(this.AssociatedObject, GlowDirection.Top); - this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom); + this.left = new GlowWindow(this.AssociatedObject, GlowDirection.Left); + this.right = new GlowWindow(this.AssociatedObject, GlowDirection.Right); + this.top = new GlowWindow(this.AssociatedObject, GlowDirection.Top); + this.bottom = new GlowWindow(this.AssociatedObject, GlowDirection.Bottom); - this.Show(); - this.Update(); + this.Show(); + this.Update(); - var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled; - if (!windowTransitionsEnabled) - { - // no storyboard so set opacity to 1 - this.SetOpacityTo(1); - } - else - { - // start the opacity storyboard 0->1 - this.StartOpacityStoryboard(); - // hide the glows if window get invisible state - this.AssociatedObject.IsVisibleChanged += this.AssociatedObject_IsVisibleChanged; - // closing always handled - this.AssociatedObject.Closing += (o, args) => - { - if (!args.Cancel) - { - this.AssociatedObject.IsVisibleChanged -= this.AssociatedObject_IsVisibleChanged; - } - }; - } - }; + var windowTransitionsEnabled = metroWindow != null && metroWindow.WindowTransitionsEnabled; + if (!windowTransitionsEnabled) + { + // no storyboard so set opacity to 1 + this.SetOpacityTo(1); + } + else + { + // start the opacity storyboard 0->1 + this.StartOpacityStoryboard(); + // hide the glows if window get invisible state + this.AssociatedObject.IsVisibleChanged += this.AssociatedObjectIsVisibleChanged; + // closing always handled + this.AssociatedObject.Closing += (o, args) => { + if (!args.Cancel) + { + this.AssociatedObject.IsVisibleChanged -= this.AssociatedObjectIsVisibleChanged; + } + }; + } } - private void AssociatedObject_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + private void AssociatedObjectIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { this.Update(); From 390df5111f3180d9092d5e84112f64ab75cd7835 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 10 Mar 2014 13:45:09 +0100 Subject: [PATCH 3/3] add color keys --- MahApps.Metro/Styles/VS/Colors.xaml | 2 ++ MahApps.Metro/Styles/VS/Window.xaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MahApps.Metro/Styles/VS/Colors.xaml b/MahApps.Metro/Styles/VS/Colors.xaml index 3a4e438fda..5827614365 100644 --- a/MahApps.Metro/Styles/VS/Colors.xaml +++ b/MahApps.Metro/Styles/VS/Colors.xaml @@ -44,6 +44,7 @@ + @@ -52,6 +53,7 @@ + diff --git a/MahApps.Metro/Styles/VS/Window.xaml b/MahApps.Metro/Styles/VS/Window.xaml index 72c3c3783c..39b4de93d1 100644 --- a/MahApps.Metro/Styles/VS/Window.xaml +++ b/MahApps.Metro/Styles/VS/Window.xaml @@ -8,9 +8,9 @@ + Value="{DynamicResource WindowGlowBrush}" /> + Value="{DynamicResource WindowTitleForeground}" /> \ No newline at end of file