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

Control: NumericUpDown #846

Merged
merged 16 commits into from
Dec 7, 2013
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
450 changes: 450 additions & 0 deletions MahApps.Metro/Controls/NumericUpDown.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions MahApps.Metro/MahApps.Metro.NET45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Compile Include="Controls\MetroProgressBar.cs" />
<Compile Include="Controls\MetroTabControl.cs" />
<Compile Include="Controls\MetroTabItem.cs" />
<Compile Include="Controls\NumericUpDown.cs" />
<Compile Include="Controls\Pivot.cs" />
<Compile Include="Controls\PivotItem.cs" />
<Compile Include="Controls\Position.cs" />
Expand Down Expand Up @@ -441,6 +442,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\NumericUpDown.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Panorama.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
6 changes: 5 additions & 1 deletion MahApps.Metro/MahApps.Metro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="Controls\MetroProgressBar.cs" />
<Compile Include="Controls\MetroTabControl.cs" />
<Compile Include="Controls\MetroTabItem.cs" />
<Compile Include="Controls\NumericUpDown.cs" />
<Compile Include="Controls\Pivot.cs" />
<Compile Include="Controls\PivotItem.cs" />
<Compile Include="Controls\Position.cs" />
Expand Down Expand Up @@ -465,6 +466,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\NumericUpDown.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Panorama.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -583,7 +588,6 @@
<DependentUpon>Controls.xaml</DependentUpon>
</Page>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
Expand Down
4 changes: 2 additions & 2 deletions MahApps.Metro/Styles/Controls.Buttons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

<!-- "Chromeless" style for buttons -->
<ControlTemplate x:Key="ChromelessButtonTemplate"
TargetType="{x:Type Button}">
TargetType="{x:Type ButtonBase}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand Down Expand Up @@ -139,7 +139,7 @@
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ChromelessButtonStyle"
TargetType="{x:Type Button}">
TargetType="{x:Type ButtonBase}">
<Setter Property="Background"
Value="{DynamicResource TransparentWhiteBrush}" />
<Setter Property="Foreground"
Expand Down
1 change: 1 addition & 0 deletions MahApps.Metro/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ResourceDictionary Source="/MahApps.Metro;component/Themes/MetroImage.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/MetroProgressBar.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/MetroWindow.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/NumericUpDown.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/Pivot.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/Panorama.xaml" />
<ResourceDictionary Source="/MahApps.Metro;component/Themes/ProgressRing.xaml" />
Expand Down
118 changes: 118 additions & 0 deletions MahApps.Metro/Themes/NumericUpDown.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<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:NumericUpDown}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:NumericUpDown}">
<ControlTemplate.Resources>
<Color x:Key="RangeReachedColor">OrangeRed</Color>
<Storyboard x:Key="MinMaxReached">
<ColorAnimation AutoReverse="True"
Duration="00:00:00.1"
Storyboard.TargetName="PART_TextBox"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="{StaticResource RangeReachedColor}" />
</Storyboard>
</ControlTemplate.Resources>
<Grid Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>

<TextBox x:Name="PART_TextBox"
Grid.ColumnSpan="3"
Padding="0,0,40,0"
VerticalAlignment="Stretch"
TextAlignment="{TemplateBinding TextAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="Transparent" />
<RepeatButton x:Name="PART_NumericUp"
Margin="2,2,0,2"
Grid.Column="1"
Style="{DynamicResource ChromelessButtonStyle}"
FontSize="20"
IsTabStop="False">
<Path x:Name="PolygonUp"
Width="14"
Height="14"
Stretch="Fill"
Fill="{DynamicResource BlackBrush}"
Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z " />
</RepeatButton>
<RepeatButton x:Name="PART_NumericDown"
Margin="0,2,2,2"
Grid.Column="2"
Style="{DynamicResource ChromelessButtonStyle}"
FontSize="20"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False">
<Path x:Name="PolygonDown"
Width="14"
Height="3"
Stretch="Fill"
Fill="{DynamicResource BlackBrush}"
Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z " />
</RepeatButton>
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MaximumReached">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource MinMaxReached}" />
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="MinimumReached">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource MinMaxReached}" />
</EventTrigger.Actions>
</EventTrigger>
<Trigger SourceName="PART_NumericUp"
Property="IsMouseOver"
Value="True">
<Setter TargetName="PART_NumericUp"
Property="Background"
Value="{DynamicResource GrayBrush8}" />
<Setter TargetName="PolygonUp"
Property="Fill"
Value="{DynamicResource AccentColorBrush}" />
</Trigger>
<Trigger SourceName="PART_NumericUp"
Property="IsPressed"
Value="True">
<Setter TargetName="PART_NumericUp"
Property="Background"
Value="{DynamicResource BlackBrush}" />
<Setter TargetName="PolygonUp"
Property="Fill"
Value="{DynamicResource WhiteBrush}" />
</Trigger>

<Trigger SourceName="PART_NumericDown"
Property="IsMouseOver"
Value="True">
<Setter TargetName="PART_NumericDown"
Property="Background"
Value="{DynamicResource GrayBrush8}" />
<Setter TargetName="PolygonDown"
Property="Fill"
Value="{DynamicResource AccentColorBrush}" />
</Trigger>
<Trigger SourceName="PART_NumericDown"
Property="IsPressed"
Value="True">
<Setter TargetName="PART_NumericDown"
Property="Background"
Value="{DynamicResource BlackBrush}" />
<Setter TargetName="PolygonDown"
Property="Fill"
Value="{DynamicResource WhiteBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
33 changes: 33 additions & 0 deletions samples/MetroDemo/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
Width="150">
Expand Down Expand Up @@ -441,6 +442,38 @@
IsEnabled="False"
Password="Password" />
</StackPanel>
<StackPanel Grid.Column="3"
Width="200">
<Label Content="NumericUpDown"
Style="{StaticResource DescriptionHeaderStyle}" />

<Label Content='Minimum="0", Maximum="10"' />
<Controls:NumericUpDown Value="5"
Minimum="0"
Maximum="10" />

<Label Content='SmallChange="2"' />
<Controls:NumericUpDown Value="5"
SmallChange="2" />
<Label Content='SmallChange="5"' />
<Controls:NumericUpDown Value="5"
SmallChange="5" />

<Label Content="No Speedup when long pressed" />
<Controls:NumericUpDown Value="5"
Speedup="false" />
<Label Content="Speedup when long pressed" />
<Controls:NumericUpDown Value="5"
Speedup="true" />

<Label Content="StringFormat" />
<Controls:NumericUpDown Value="5"
SmallChange=".1"
StringFormat="C2" />
<Controls:NumericUpDown Value="5"
SmallChange=".1"
StringFormat="N2" />
</StackPanel>
</Grid>
</AdornerDecorator>
</TabItem>
Expand Down