Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce VSWindowStyleKey for #904 #1140

Merged
merged 3 commits into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions MahApps.Metro/Behaviours/GlowWindowBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Interactivity;
using MahApps.Metro.Controls;

Expand All @@ -12,48 +13,49 @@ 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))
{
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();

Expand Down
4 changes: 4 additions & 0 deletions MahApps.Metro/MahApps.Metro.NET45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Styles\VS\Window.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Dialogs\BaseMetroDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
4 changes: 4 additions & 0 deletions MahApps.Metro/MahApps.Metro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Styles\VS\Window.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Dialogs\BaseMetroDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
2 changes: 2 additions & 0 deletions MahApps.Metro/Styles/VS/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!--Foreground-->
<SolidColorBrush x:Key="Foreground" Color="#FFFFFF"/>
<SolidColorBrush x:Key="WindowTitleForeground" Color="#999988"/>

<!--General-->
<SolidColorBrush x:Key="BackgroundHighlighted" Color="#54545C"/>
Expand All @@ -52,6 +53,7 @@
<SolidColorBrush x:Key="BorderBrushSelected" Color="#1C97EA"/>
<SolidColorBrush x:Key="BackgroundNormal" Color="#3F3F46"/>
<SolidColorBrush x:Key="BorderBrushNormal" Color="#54545C"/>
<SolidColorBrush x:Key="WindowGlowBrush" Color="#017ACC"/>

<!--Text Box-->
<SolidColorBrush x:Key="TextBoxBackground" Color="#333337"/>
Expand Down
1 change: 1 addition & 0 deletions MahApps.Metro/Styles/VS/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Window.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/ListBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Menu.xaml" />
Expand Down
16 changes: 16 additions & 0 deletions MahApps.Metro/Styles/VS/Window.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls">

<Style TargetType="{x:Type Controls:MetroWindow}"
BasedOn="{StaticResource {x:Type Controls:MetroWindow}}"
x:Key="VSWindowStyleKey">
<Setter Property="ShowTitleBar"
Value="True" />
<Setter Property="GlowBrush"
Value="{DynamicResource WindowGlowBrush}" />
<Setter Property="TitleForeground"
Value="{DynamicResource WindowTitleForeground}" />
</Style>

</ResourceDictionary>
2 changes: 1 addition & 1 deletion samples/MetroDemo/ExampleWindows/VSDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Height="800"
Width="1000"
WindowStartupLocation="CenterScreen"
TitleForeground="#999988">
Style="{DynamicResource VSWindowStyleKey}">

<Window.Resources>
<ResourceDictionary>
Expand Down