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

System wide font settings. #31

Merged
merged 9 commits into from
Dec 4, 2014
4 changes: 3 additions & 1 deletion Fluent/AttachedProperties/RibbonProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class RibbonProperties
{
#region TitleBarHeight Property

public const double MIN_TITLE_BAR_HEIGHT = 25;

/// <summary>
/// Using a DependencyProperty as the backing store for TitleBarHeight.
/// This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty TitleBarHeightProperty =
DependencyProperty.RegisterAttached("TitleBarHeight", typeof(double), typeof(RibbonProperties),
new FrameworkPropertyMetadata(25D, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.Inherits));
new FrameworkPropertyMetadata(MIN_TITLE_BAR_HEIGHT, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.Inherits));

/// <summary>
/// Sets TitleBarHeight for element
Expand Down
26 changes: 26 additions & 0 deletions Fluent/Controls/RibbonWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace Fluent
#else
using System.Windows.Shell;
#endif
using Microsoft.Win32;
using System.Globalization;

/// <summary>
/// Represents basic window for ribbon
Expand Down Expand Up @@ -235,6 +237,9 @@ public RibbonWindow()
this.SizeChanged += this.OnSizeChanged;

this.windowSizing = new WindowSizing(this);

SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged;
UpdateTitleBarHeight();
}

#endregion
Expand Down Expand Up @@ -274,6 +279,27 @@ protected override void OnContentChanged(object oldContent, object newContent)

#endregion

private void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
{
// When SystemsFont.MenuFont* changed
if (e.Category == UserPreferenceCategory.Window)
{
UpdateTitleBarHeight();
}
}

private void UpdateTitleBarHeight()
{
var fmt = new FormattedText(
"CANDIDATE",
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(SystemFonts.CaptionFontFamily, SystemFonts.CaptionFontStyle, SystemFonts.CaptionFontWeight, FontStretches.Normal),
SystemFonts.CaptionFontSize,
Brushes.Black);
RibbonProperties.SetTitleBarHeight(this, Math.Max(fmt.Height, RibbonProperties.MIN_TITLE_BAR_HEIGHT));
}

private static void OnWindowChromeRelevantPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var window = d as RibbonWindow;
Expand Down
2 changes: 1 addition & 1 deletion Fluent/Themes/Office2010/Controls/Backstage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:Fluent="clr-namespace:Fluent" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<ControlTemplate x:Key="BackstageToggleButtonControlTemplate" TargetType="{x:Type Fluent:Backstage}">
<Border x:Name="border2" MinWidth="56" Height="24" CornerRadius="2,2,0,0" Background="{TemplateBinding Background}" Margin="0,0,0,1">
<Border x:Name="border2" MinWidth="56" Height="Auto" CornerRadius="2,2,0,0" Background="{TemplateBinding Background}" Margin="0,0,0,1">
<Border x:Name="border1" BorderThickness="1,1,1,0" CornerRadius="2,2,0,0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
Expand Down
6 changes: 3 additions & 3 deletions Fluent/Themes/Office2010/Controls/MenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="22"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down Expand Up @@ -312,7 +312,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="22"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down Expand Up @@ -588,7 +588,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="22"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down
2 changes: 1 addition & 1 deletion Fluent/Themes/Office2010/Controls/MenuSeparator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</Style>
<ControlTemplate x:Key="MenuGroupSeparatorControlTemplate"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}">
<Grid Height="21"
<Grid Height="Auto"
Background="#FFF0F2F5">
<TextBlock Margin="7,0"
Text="{TemplateBinding Header}"
Expand Down
14 changes: 13 additions & 1 deletion Fluent/Themes/Office2010/Controls/Ribbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
Style="{DynamicResource RibbonTitleBarStyle}"
Margin="20,0,113,0"
VerticalAlignment="Top"
IsCollapsed="{TemplateBinding IsCollapsed}">
IsCollapsed="{TemplateBinding IsCollapsed}"
TextBlock.FontSize="{DynamicResource {x:Static SystemFonts.CaptionFontSizeKey}}"
TextBlock.FontFamily="{DynamicResource {x:Static SystemFonts.CaptionFontFamilyKey}}"
TextBlock.FontStyle="{DynamicResource {x:Static SystemFonts.CaptionFontStyleKey}}"
TextBlock.FontWeight="{DynamicResource {x:Static SystemFonts.CaptionFontWeightKey}}">
<Fluent:RibbonTitleBar.Header>
<Grid>
<Rectangle x:Name="rectangle"
Expand Down Expand Up @@ -135,5 +139,13 @@
Value="False" />
<Setter Property="Fluent:FrameworkHelper.UseLayoutRounding"
Value="True" />
<Setter Property="FontSize"
Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" />
<Setter Property="FontFamily"
Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}" />
<Setter Property="FontStyle"
Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}" />
<Setter Property="FontWeight"
Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}" />
</Style>
</ResourceDictionary>
14 changes: 11 additions & 3 deletions Fluent/Themes/Office2010/Controls/RibbonStatusBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Fluent">
<Style x:Key="{x:Type Controls:StatusBar}" TargetType="{x:Type Controls:StatusBar}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Height" Value="22"/>
<Setter Property="Height" Value="Auto"/>
<Setter Property="FontSize"
Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" />
<Setter Property="FontFamily"
Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}" />
<Setter Property="FontStyle"
Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}" />
<Setter Property="FontWeight"
Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}" />
<Setter Property="Template" >
<Setter.Value>
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:StatusBar}">
<Border BorderThickness="0,1" BorderBrush="{DynamicResource StatusBarBorderBrushBrush}">
<Border Height="Auto" BorderThickness="0,1" BorderBrush="{DynamicResource StatusBarInnerBorderBrush}" Background="{DynamicResource StatusBarInnerBackgroundBrush}">
Expand Down Expand Up @@ -51,7 +59,7 @@

<!--Menu Item Template-->
<ControlTemplate x:Key="RibbonStatusBarContextMenuItemControlTemplate" TargetType="{x:Type Controls:StatusBarMenuItem}">
<Grid Width="Auto" Height="22" Background="#00000000">
<Grid Width="Auto" Height="Auto" Background="#00000000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
Expand Down
4 changes: 2 additions & 2 deletions Fluent/Themes/Office2010/Controls/RibbonTabControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
Height="Auto"
VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="Auto" />
<RowDefinition x:Name="rowDefinition"
Height="94" />
<RowDefinition x:Name="rowDefinition1"
Expand Down Expand Up @@ -454,7 +454,7 @@
</Grid.ColumnDefinitions>

<DockPanel LastChildFill="True">
<ContentPresenter VerticalAlignment="Top"
<ContentPresenter VerticalAlignment="Stretch"
ContentSource="Menu"
DockPanel.Dock="Left" />
<Fluent:RibbonScrollViewer x:Name="scrollViewer"
Expand Down
4 changes: 2 additions & 2 deletions Fluent/Themes/Office2010/Controls/RibbonTabItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Setter Property="VerticalAlignment"
Value="Top" />
<Setter Property="Height"
Value="31" />
Value="Auto" />
<Setter Property="IsMinimized"
Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonTabControl}}, Path=IsMinimized, Mode=OneWay, FallbackValue=False}" />
<Setter Property="IsOpen"
Expand All @@ -33,7 +33,7 @@
<ControlTemplate TargetType="{x:Type Fluent:RibbonTabItem}">
<Grid x:Name="grid"
Background="#00000000"
Height="24"
Height="Auto"
VerticalAlignment="Top"
Margin="0,7,0,0">
<Border x:Name="border3"
Expand Down
2 changes: 1 addition & 1 deletion Fluent/Themes/Office2013/Controls/Backstage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ControlTemplate x:Key="BackstageToggleButtonControlTemplate" TargetType="{x:Type Fluent:Backstage}">
<Border x:Name="border2" MinWidth="60" Height="24" Background="{TemplateBinding Background}" Margin="0,0,1,0">
<Border x:Name="border2" MinWidth="60" Height="Auto" Background="{TemplateBinding Background}" Margin="0,0,1,0">
<Grid>
<Rectangle x:Name="rectangle" />
<ContentPresenter x:Name="contentPresenter"
Expand Down
6 changes: 3 additions & 3 deletions Fluent/Themes/Office2013/Controls/MenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="24"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down Expand Up @@ -290,7 +290,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="24"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down Expand Up @@ -541,7 +541,7 @@
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Height="24"
Height="Auto"
Background="{DynamicResource MenuItemBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down
2 changes: 1 addition & 1 deletion Fluent/Themes/Office2013/Controls/MenuSeparator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</Style>
<ControlTemplate x:Key="MenuGroupSeparatorControlTemplate"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}">
<Grid Height="24"
<Grid Height="Auto"
Background="#FFEEEEEE">
<TextBlock Margin="7,0"
Text="{TemplateBinding Header}"
Expand Down
14 changes: 13 additions & 1 deletion Fluent/Themes/Office2013/Controls/Ribbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
Style="{DynamicResource RibbonTitleBarStyle}"
Margin="36,0,113,0"
VerticalAlignment="Top"
IsCollapsed="{TemplateBinding IsCollapsed}">
IsCollapsed="{TemplateBinding IsCollapsed}"
TextBlock.FontSize="{DynamicResource {x:Static SystemFonts.CaptionFontSizeKey}}"
TextBlock.FontFamily="{DynamicResource {x:Static SystemFonts.CaptionFontFamilyKey}}"
TextBlock.FontStyle="{DynamicResource {x:Static SystemFonts.CaptionFontStyleKey}}"
TextBlock.FontWeight="{DynamicResource {x:Static SystemFonts.CaptionFontWeightKey}}">
<Fluent:RibbonTitleBar.Header>
<TextBlock x:Name="PART_Title"
Margin="-2,0"
Expand Down Expand Up @@ -114,5 +118,13 @@
Value="False" />
<Setter Property="Fluent:FrameworkHelper.UseLayoutRounding"
Value="True" />
<Setter Property="FontSize"
Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" />
<Setter Property="FontFamily"
Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}" />
<Setter Property="FontStyle"
Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}" />
<Setter Property="FontWeight"
Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}" />
</Style>
</ResourceDictionary>
12 changes: 10 additions & 2 deletions Fluent/Themes/Office2013/Controls/RibbonStatusBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
<Setter Property="SnapsToDevicePixels"
Value="True" />
<Setter Property="Height"
Value="24" />
Value="Auto" />
<Setter Property="Margin"
Value="0,0,0,-1" />
<Setter Property="FontSize"
Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" />
<Setter Property="FontFamily"
Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}" />
<Setter Property="FontStyle"
Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}" />
<Setter Property="FontWeight"
Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:StatusBar}">
Expand Down Expand Up @@ -76,7 +84,7 @@
<ControlTemplate x:Key="RibbonStatusBarContextMenuItemControlTemplate"
TargetType="{x:Type Controls:StatusBarMenuItem}">
<Grid Width="Auto"
Height="24"
Height="Auto"
Background="#00000000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />
Expand Down
4 changes: 2 additions & 2 deletions Fluent/Themes/Office2013/Controls/RibbonTabControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
Height="Auto"
VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="Auto" />
<RowDefinition x:Name="rowDefinition"
Height="94" />
<RowDefinition x:Name="rowDefinition1"
Expand Down Expand Up @@ -385,7 +385,7 @@
</Grid.ColumnDefinitions>

<DockPanel LastChildFill="True">
<ContentPresenter VerticalAlignment="Top"
<ContentPresenter VerticalAlignment="Stretch"
ContentSource="Menu"
DockPanel.Dock="Left" />
<Fluent:RibbonScrollViewer x:Name="scrollViewer"
Expand Down
4 changes: 2 additions & 2 deletions Fluent/Themes/Office2013/Controls/RibbonTabItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ControlTemplate TargetType="{x:Type Fluent:RibbonTabItem}" x:Key="RibbonTabItemControlTemplate">
<Grid x:Name="grid" Background="#00000000" Height="24" VerticalAlignment="Top" Margin="0,7,0,0">
<Grid x:Name="grid" Background="#00000000" Height="Auto" VerticalAlignment="Top" Margin="0,7,0,0">
<Border x:Name="border3" Margin="0,0,0,1" Grid.ColumnSpan="2">
<Border x:Name="border5"
Background="{Binding Group.Background, RelativeSource={RelativeSource TemplatedParent}, FallbackValue=Transparent}"
Expand Down Expand Up @@ -294,7 +294,7 @@
<Setter Property="VerticalAlignment"
Value="Top" />
<Setter Property="Height"
Value="31" />
Value="Auto" />
<Setter Property="IsMinimized"
Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonTabControl}}, Path=IsMinimized, Mode=OneWay, FallbackValue=False}" />
<Setter Property="IsOpen"
Expand Down