ProgressButtonBaseStyle.xaml 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls">
  4. <Style x:Key="ProgressBarFlat4ProgressButton" TargetType="ProgressBar">
  5. <Setter Property="Background" Value="Transparent"/>
  6. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  7. <Setter Property="Foreground" Value="{DynamicResource DarkMaskBrush}"/>
  8. <Setter Property="Template">
  9. <Setter.Value>
  10. <ControlTemplate TargetType="ProgressBar">
  11. <Border x:Name="PART_Track">
  12. <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
  13. <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" x:Name="Indicator" Background="{TemplateBinding Foreground}"/>
  14. </Decorator>
  15. </Border>
  16. </ControlTemplate>
  17. </Setter.Value>
  18. </Setter>
  19. </Style>
  20. <Style x:Key="ProgressButtonBaseStyle" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="hc:ProgressButton">
  21. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  22. <Setter Property="ProgressStyle" Value="{StaticResource ProgressBarFlat4ProgressButton}"/>
  23. <Setter Property="Template">
  24. <Setter.Value>
  25. <ControlTemplate TargetType="hc:ProgressButton">
  26. <Border x:Name="Chrome" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
  27. <hc:SimplePanel>
  28. <ProgressBar x:Name="ProgressBar" Height="Auto" Value="{TemplateBinding Progress}" Maximum="100" Visibility="Collapsed" Style="{TemplateBinding ProgressStyle}"/>
  29. <ContentPresenter Name="UnCheckedElement" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  30. <ContentPresenter Name="CheckedElement" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Visibility="Collapsed" Content="{Binding Path=(hc:StatusSwitchElement.CheckedElement),RelativeSource={RelativeSource TemplatedParent}}"/>
  31. </hc:SimplePanel>
  32. </Border>
  33. <ControlTemplate.Triggers>
  34. <Trigger Property="IsMouseOver" Value="True">
  35. <Setter Property="Opacity" Value=".9"/>
  36. </Trigger>
  37. <Trigger Property="IsPressed" Value="True">
  38. <Setter Property="Opacity" Value=".6"/>
  39. </Trigger>
  40. <Trigger Property="IsChecked" Value="True">
  41. <Setter Property="Visibility" Value="Visible" TargetName="ProgressBar"/>
  42. <Setter Property="Visibility" Value="Visible" TargetName="CheckedElement"/>
  43. </Trigger>
  44. <MultiTrigger>
  45. <MultiTrigger.Conditions>
  46. <Condition Property="hc:StatusSwitchElement.HideUncheckedElement" Value="True"/>
  47. <Condition Property="IsChecked" Value="True"/>
  48. </MultiTrigger.Conditions>
  49. <Setter Property="Visibility" Value="Collapsed" TargetName="UnCheckedElement"/>
  50. </MultiTrigger>
  51. <Trigger Property="IsEnabled" Value="False">
  52. <Setter Property="Opacity" Value="0.4"/>
  53. </Trigger>
  54. </ControlTemplate.Triggers>
  55. </ControlTemplate>
  56. </Setter.Value>
  57. </Setter>
  58. </Style>
  59. </ResourceDictionary>