Browse Source

Starting to play around with theming. Starting with the ButtonSpinner.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
265b4c02aa
  1. 9
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ButtonSpinner.cs
  2. 101
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml
  3. 127
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Aero/Brushes.xaml
  4. 60
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Aero/Buttons.xaml
  5. 8
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj

9
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ButtonSpinner.cs

@ -9,9 +9,14 @@ namespace Microsoft.Windows.Controls
/// <summary>
/// Represents a spinner control that includes two Buttons.
/// </summary>
[TemplatePart(Name = PART_IncreaseButton, Type = typeof(ButtonBase))]
[TemplatePart(Name = PART_DecreaseButton, Type = typeof(ButtonBase))]
[ContentProperty("Content")]
public class ButtonSpinner : Spinner
{
private const string PART_IncreaseButton = "PART_IncreaseButton";
private const string PART_DecreaseButton = "PART_DecreaseButton";
#region Properties
#region AllowSpin
@ -132,8 +137,8 @@ namespace Microsoft.Windows.Controls
{
base.OnApplyTemplate();
IncreaseButton = GetTemplateChild("IncreaseButton") as ButtonBase;
DecreaseButton = GetTemplateChild("DecreaseButton") as ButtonBase;
IncreaseButton = GetTemplateChild(PART_IncreaseButton) as ButtonBase;
DecreaseButton = GetTemplateChild(PART_DecreaseButton) as ButtonBase;
SetButtonUsage();
}

101
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml

@ -3,90 +3,55 @@
xmlns:local="clr-namespace:Microsoft.Windows.Controls"
xmlns:chrome="clr-namespace:Microsoft.Windows.Controls.Chromes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Themes/Aero/Buttons.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- =============================================================================== -->
<!-- ButtonSpinner -->
<!-- =============================================================================== -->
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<SolidColorBrush x:Key="SpinButtonGlyphNormalForegroundFillKey" Color="#FF000000" />
<SolidColorBrush x:Key="SpinButtonGlyphDisabledForegroundFillKey" Color="DarkGray" />
<Style TargetType="{x:Type local:ButtonSpinner}">
<Setter Property="Background" Value="{StaticResource ControlNormalBackgroundKey}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9" Offset="0" />
<GradientStop Color="#FF8399A9" Offset="0.375" />
<GradientStop Color="#FF718597" Offset="0.375" />
<GradientStop Color="#FF617584" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{StaticResource ControlNormalBorderFillKey}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ButtonSpinner}">
<Grid>
<Border x:Name="ElementContainer" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<DockPanel Focusable="False">
<Grid DockPanel.Dock="Right" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="1" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RepeatButton x:Name="IncreaseButton" SnapsToDevicePixels="True" Grid.Row="0" ClickMode="Press" IsTabStop="{Binding IsTabStop, RelativeSource={RelativeSource TemplatedParent}}" >
<RepeatButton.Template>
<ControlTemplate TargetType="RepeatButton">
<ContentPresenter />
</ControlTemplate>
</RepeatButton.Template>
<Grid>
<chrome:ButtonChrome CornerRadius="0"
RenderEnabled="{TemplateBinding IsEnabled}"
RenderMouseOver="{Binding IsMouseOver, ElementName=IncreaseButton}"
RenderPressed="{Binding IsPressed, ElementName=IncreaseButton}">
<Path x:Name="_increaseGlyph" Width="7" Height="4" Data="M 0,3 C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,2 5,1 5,1 5,1 4,1 4,1 4,1 4,0 4,0 4,0 3,0 3,0 3,0 3,1 3,1 3,1 2,1 2,1 2,1 2,2 2,2 2,2 1,2 1,2 1,2 1,3 1,3 1,3 0,3 0,3 z"
Fill="{StaticResource SpinButtonGlyphNormalForegroundFillKey}"
Margin="5,1" Focusable="False" />
</chrome:ButtonChrome>
</Grid>
</RepeatButton>
<RepeatButton x:Name="DecreaseButton" SnapsToDevicePixels="True" Grid.Row="2" ClickMode="Press" IsTabStop="{Binding IsTabStop, RelativeSource={RelativeSource TemplatedParent}}" >
<RepeatButton.Template>
<ControlTemplate TargetType="RepeatButton">
<ContentPresenter />
</ControlTemplate>
</RepeatButton.Template>
<Grid>
<chrome:ButtonChrome CornerRadius="0"
RenderEnabled="{TemplateBinding IsEnabled}"
RenderMouseOver="{Binding IsMouseOver, ElementName=DecreaseButton}"
RenderPressed="{Binding IsPressed, ElementName=DecreaseButton}" >
<Path x:Name="_decreaseGlyph" Width="7" Height="4" Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z"
Fill="{StaticResource SpinButtonGlyphNormalForegroundFillKey}"
Margin="5,1" Focusable="False" />
</chrome:ButtonChrome>
</Grid>
</RepeatButton>
</Grid>
<ContentControl x:Name="presentationSite" Focusable="False"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}" />
</DockPanel>
</Border>
</Grid>
<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter Focusable="False" />
<Grid Grid.Column="1" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource BooleanToVisibilityConverter}}" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RepeatButton x:Name="PART_IncreaseButton"
Style="{StaticResource SpinnerButtonStyle}"
IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource IncreaseGlyphKey}" />
<RepeatButton x:Name="PART_DecreaseButton" Grid.Row="1"
Style="{StaticResource SpinnerButtonStyle}"
IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource DecreaseGlyphKey}" />
</Grid>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="_increaseGlyph" Property="Fill" Value="{StaticResource SpinButtonGlyphDisabledForegroundFillKey}" />
<Setter TargetName="_decreaseGlyph" Property="Fill" Value="{StaticResource SpinButtonGlyphDisabledForegroundFillKey}" />
<Setter Property="Background" Value="{StaticResource ControlDisabledBackgroundKey}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

127
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Aero/Brushes.xaml

@ -0,0 +1,127 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" >
<SolidColorBrush x:Key="ControlNormalBackgroundKey" Color="#FFFFFF" PresentationOptions:Freeze="true"/>
<SolidColorBrush x:Key="ControlDisabledBackgroundKey" Color="#F4F4F4" PresentationOptions:Freeze="true"/>
<LinearGradientBrush x:Key="ControlNormalBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1" PresentationOptions:Freeze="true">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFabadb3" Offset="0" />
<GradientStop Color="#FFdbdfe6" Offset="0.05000000074505806" />
<GradientStop Color="#FFdbdfe6" Offset="0.949999988079071" />
<GradientStop Color="#FFe3e9ef" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ControlMouseOverBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1" PresentationOptions:Freeze="true" >
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF3d7bad" Offset="0" />
<GradientStop Color="#FFa4c9e3" Offset="0.05000000074505806" />
<GradientStop Color="#FFa4c9e3" Offset="0.949999988079071" />
<GradientStop Color="#FFb7d9ed" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ControlFocusedBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1" PresentationOptions:Freeze="true">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF3d7bad" Offset="0" />
<GradientStop Color="#FFa4c9e3" Offset="0.05000000074505806" />
<GradientStop Color="#FFa4c9e3" Offset="0.949999988079071" />
<GradientStop Color="#FFb7d9ed" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnNormalOuterBorderFillKey" Color="#FFABADB3"/>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnNormalInnerBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFfcfcfc"/>
<GradientStop Offset="0.69" Color="#FFf9f9f9"/>
<GradientStop Offset="0.69" Color="#FFf3f3f3"/>
<GradientStop Offset="1" Color="#FFf3f3f3"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnNormalCenterFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Offset="0" Color="#FFf2f2f2"/>
<GradientStop Offset="0.69" Color="#FFe8e8e8"/>
<GradientStop Offset="0.69" Color="#FFd1d1d1"/>
<GradientStop Offset="1" Color="#FFd1d1d1"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnHottrackOuterBorderFillKey" Color="#FF3C7FB1"/>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnHottrackInnerBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFfafdfe" Offset="0" />
<GradientStop Color="#FFf5fbfe" Offset="0.5" />
<GradientStop Color="#FFeff9fe" Offset="0.5009999871253967" />
<GradientStop Color="#FFe8f5fc" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnHottrackCenterFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFeaf6fd" Offset="0" />
<GradientStop Color="#FFd9f0fc" Offset="0.5" />
<GradientStop Color="#FFbee6fd" Offset="0.5009999871253967" />
<GradientStop Color="#FFa7d9f5" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnPressedOuterBorderFillKey" Color="#FF2C628B"/>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnPressedInnerBorderFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FF9eb0ba" Offset="0" />
<GradientStop Color="#FF9abacb" Offset="0.5" />
<GradientStop Color="#FF78aac5" Offset="0.5008999705314636" />
<GradientStop Color="#FF5a96b8" Offset="0.8999999761581421" />
<GradientStop Color="#FF68b2da" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnPressedCenterFillKey" StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFe5f4fc" Offset="0" />
<GradientStop Color="#FFc4e5f6" Offset="0.5" />
<GradientStop Color="#FF98d1ef" Offset="0.5009999871253967" />
<GradientStop Color="#FF68b3db" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush PresentationOptions:Freeze="true" x:Key="DropdownBtnGlyphNormalForegroundFillKey" Color="#FF000000" />
<CornerRadius x:Key="SpinButtonCornerRadiusKey" TopLeft="0" TopRight="0" BottomRight="0" BottomLeft="0" PresentationOptions:Freeze="true" />
</ResourceDictionary>

60
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Aero/Buttons.xaml

@ -0,0 +1,60 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Brushes.xaml" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="IncreaseGlyphKey">
<Path
Width="7"
Height="4"
Data="M 0,3 C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,2 5,1 5,1 5,1 4,1 4,1 4,1 4,0 4,0 4,0 3,0 3,0 3,0 3,1 3,1 3,1 2,1 2,1 2,1 2,2 2,2 2,2 1,2 1,2 1,2 1,3 1,3 1,3 0,3 0,3 z"
Fill="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}"
SnapsToDevicePixels="True"
HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
</DataTemplate>
<DataTemplate x:Key="DecreaseGlyphKey">
<Path
Width="7"
Height="4"
Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z"
Fill="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}"
SnapsToDevicePixels="True"
HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" />
</DataTemplate>
<Style x:Key="SpinnerButtonStyle" TargetType="RepeatButton">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}"/>
<Setter Property="Padding" Value="4,2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{StaticResource SpinButtonCornerRadiusKey}" >
<Grid>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource DropdownBtnHottrackCenterFillKey}"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource DropdownBtnHottrackOuterBorderFillKey}"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource DropdownBtnPressedOuterBorderFillKey}"/>
<Setter Property="Background" TargetName="Bd" Value="{StaticResource DropdownBtnPressedCenterFillKey}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ControlDisabledBackgroundKey}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

8
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj

@ -151,6 +151,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Aero\Brushes.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Aero\Buttons.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Common\Generic_Common.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

Loading…
Cancel
Save