|
6 | 6 | xmlns:system="clr-namespace:System;assembly=mscorlib"
|
7 | 7 | xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
|
8 | 8 | xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
|
| 9 | + xmlns:cicularProgressBar="clr-namespace:MaterialDesignColors.WpfExample.ProvingGroundStuff.MaterialDesignColors.WpfExample.ProvingGroundStuff.CicularProgressBar" |
9 | 10 | x:Class="MaterialDesignColors.WpfExample.ProvingGround"
|
10 | 11 | TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
11 | 12 | Background="{DynamicResource MaterialDesignPaper}"
|
12 | 13 | FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
13 | 14 | mc:Ignorable="d"
|
14 |
| - d:DesignWidth="680" d:DesignHeight="120"> |
| 15 | + d:DesignWidth="200" d:DesignHeight="120"> |
15 | 16 | <UserControl.Resources>
|
16 | 17 | <ResourceDictionary>
|
17 | 18 | <ResourceDictionary.MergedDictionaries>
|
|
25 | 26 | <ResourceDictionary>
|
26 | 27 | <!-- include your primary palette -->
|
27 | 28 | <ResourceDictionary.MergedDictionaries>
|
28 |
| - <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/MaterialDesignColor.Green.xaml" /> |
| 29 | + <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/MaterialDesignColor.Indigo.xaml" /> |
29 | 30 | </ResourceDictionary.MergedDictionaries>
|
30 | 31 | <!--
|
31 | 32 | include three hues from the primary palette (and the associated forecolours).
|
|
52 | 53 | </ResourceDictionary>
|
53 | 54 | </ResourceDictionary.MergedDictionaries>
|
54 | 55 |
|
| 56 | + <cicularProgressBar:StartPointConverter x:Key="StartPointConverter" /> |
| 57 | + <cicularProgressBar:ArcSizeConverter x:Key="ArcSizeConverter" /> |
| 58 | + <cicularProgressBar:ArcEndPointConverter x:Key="ArcEndPointConverter" /> |
| 59 | + <cicularProgressBar:LargeArcConverter x:Key="LargeArcConverter" /> |
| 60 | + <cicularProgressBar:RotateTransformConverter x:Key="RotateTransformConverter" /> |
| 61 | + <cicularProgressBar:RotateTransformCentreConverter x:Key="RotateTransformCentreConverter" /> |
| 62 | + |
| 63 | + <Style x:Key="MaterialDesignCicularProgressBar" TargetType="{x:Type ProgressBar}"> |
| 64 | + <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}" /> |
| 65 | + <Setter Property="Background" Value="Transparent" /> |
| 66 | + <Setter Property="Width" Value="20" /> |
| 67 | + <Setter Property="Height" Value="20" /> |
| 68 | + <Setter Property="Template"> |
| 69 | + <Setter.Value> |
| 70 | + <ControlTemplate TargetType="{x:Type ProgressBar}"> |
| 71 | + <ControlTemplate.Resources> |
| 72 | + <Storyboard x:Key="IsIndeterminateStoryboard" TargetName="RotateTransform" TargetProperty="Angle" RepeatBehavior="Forever"> |
| 73 | + <DoubleAnimation From="0" To="359" Duration="0:0:2" /> |
| 74 | + </Storyboard> |
| 75 | + </ControlTemplate.Resources> |
| 76 | + <Grid x:Name="TemplateRoot" Background="{TemplateBinding Background}" ClipToBounds="False"> |
| 77 | + <Grid x:Name="PathGrid" Margin="2" /> |
| 78 | + <Canvas> |
| 79 | + <Path x:Name="Path" Stroke="{TemplateBinding Foreground}" StrokeThickness="3" |
| 80 | + Canvas.Top="2" Canvas.Left="2" |
| 81 | + RenderTransformOrigin="0, 0"> |
| 82 | + <Path.Data> |
| 83 | + <PathGeometry> |
| 84 | + <PathFigure StartPoint="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource StartPointConverter}, Mode=OneWay}"> |
| 85 | + <ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource ArcSizeConverter}, Mode=OneWay}" |
| 86 | + SweepDirection="Clockwise" |
| 87 | + > |
| 88 | + <ArcSegment.IsLargeArc> |
| 89 | + <MultiBinding Converter="{StaticResource LargeArcConverter}"> |
| 90 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" /> |
| 91 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" /> |
| 92 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" /> |
| 93 | + </MultiBinding> |
| 94 | + </ArcSegment.IsLargeArc> |
| 95 | + <ArcSegment.Point> |
| 96 | + <MultiBinding Converter="{StaticResource ArcEndPointConverter}"> |
| 97 | + <Binding ElementName="PathGrid" Path="ActualWidth" /> |
| 98 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" /> |
| 99 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" /> |
| 100 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" /> |
| 101 | + </MultiBinding> |
| 102 | + </ArcSegment.Point> |
| 103 | + </ArcSegment> |
| 104 | + </PathFigure> |
| 105 | + </PathGeometry> |
| 106 | + </Path.Data> |
| 107 | + <Path.RenderTransform> |
| 108 | + <TransformGroup> |
| 109 | + <RotateTransform x:Name="RotateTransform" |
| 110 | + CenterX="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource RotateTransformCentreConverter}, Mode=OneWay}" |
| 111 | + CenterY="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource RotateTransformCentreConverter}, Mode=OneWay}"> |
| 112 | + <RotateTransform.Angle> |
| 113 | + <MultiBinding Converter="{StaticResource RotateTransformConverter}"> |
| 114 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" /> |
| 115 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" /> |
| 116 | + <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" /> |
| 117 | + </MultiBinding> |
| 118 | + </RotateTransform.Angle> |
| 119 | + </RotateTransform> |
| 120 | + </TransformGroup> |
| 121 | + </Path.RenderTransform> |
| 122 | + </Path> |
| 123 | + </Canvas> |
| 124 | + </Grid> |
| 125 | + <ControlTemplate.Triggers> |
| 126 | + <Trigger Property="IsIndeterminate" Value="True"> |
| 127 | + <Trigger.EnterActions> |
| 128 | + <BeginStoryboard Storyboard="{StaticResource IsIndeterminateStoryboard}" |
| 129 | + Name="IsIndeterminateStoryboard"/> |
| 130 | + </Trigger.EnterActions> |
| 131 | + <Trigger.ExitActions> |
| 132 | + <RemoveStoryboard BeginStoryboardName="IsIndeterminateStoryboard" /> |
| 133 | + </Trigger.ExitActions> |
| 134 | + </Trigger> |
| 135 | + <!-- |
| 136 | + <MultiTrigger> |
| 137 | + <MultiTrigger.Conditions> |
| 138 | + <Condition Property="IsIndeterminate" Value="True" /> |
| 139 | + <Condition Property="Value" Value="0" /> |
| 140 | + </MultiTrigger.Conditions> |
| 141 | + <MultiTrigger.EnterActions> |
| 142 | + <BeginStoryboard Storyboard="{StaticResource IsFullyIndeterminateStoryboard}" |
| 143 | + Name="IsFullyIndeterminateStoryboard"/> |
| 144 | + </MultiTrigger.EnterActions> |
| 145 | + <MultiTrigger.ExitActions> |
| 146 | + <RemoveStoryboard BeginStoryboardName="IsFullyIndeterminateStoryboard" /> |
| 147 | + </MultiTrigger.ExitActions> |
| 148 | + </MultiTrigger> |
| 149 | + --> |
| 150 | + </ControlTemplate.Triggers> |
| 151 | + </ControlTemplate> |
| 152 | + </Setter.Value> |
| 153 | + </Setter> |
| 154 | + </Style> |
| 155 | + |
55 | 156 | </ResourceDictionary>
|
56 | 157 |
|
| 158 | + |
| 159 | + |
57 | 160 | </UserControl.Resources>
|
58 | 161 |
|
59 |
| - <Grid> |
| 162 | + <Grid VerticalAlignment="Top"> |
| 163 | + <Grid.RowDefinitions> |
| 164 | + <RowDefinition Height="Auto" /> |
| 165 | + <RowDefinition Height="Auto" /> |
| 166 | + <RowDefinition /> |
| 167 | + <RowDefinition /> |
| 168 | + </Grid.RowDefinitions> |
| 169 | + <Grid.ColumnDefinitions> |
| 170 | + <ColumnDefinition Width="Auto" /> |
| 171 | + <ColumnDefinition Width="*" /> |
| 172 | + </Grid.ColumnDefinitions> |
| 173 | + |
| 174 | + <ProgressBar Style="{StaticResource MaterialDesignCicularProgressBar}" |
| 175 | + x:Name="DeterminateCircularProgress" |
| 176 | + VerticalAlignment="Center" Margin="12 12 0 12" /> |
| 177 | + <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="12" TextWrapping="Wrap">Standard deterministic progress bar, running from 0 to 100%.  For the purpose of the demo, a storyboard is used to animate the .Value property.</TextBlock> |
| 178 | + |
| 179 | + <ProgressBar Style="{StaticResource MaterialDesignCicularProgressBar}" |
| 180 | + Value="35" |
| 181 | + IsIndeterminate="True" |
| 182 | + Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="12 12 0 12"/> |
| 183 | + <TextBlock Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="12" TextWrapping="Wrap">Indeterminate progress bar, at 35%.</TextBlock> |
| 184 | + |
| 185 | + <ProgressBar Style="{StaticResource MaterialDesignCicularProgressBar}" |
| 186 | + Value="0" |
| 187 | + IsIndeterminate="True" |
| 188 | + Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="12 12 0 12"/> |
| 189 | + <TextBlock Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="12" TextWrapping="Wrap">Fully indeterminate progress bar, using .Value=0 to inform the theme.</TextBlock> |
| 190 | + |
| 191 | + <ProgressBar Style="{StaticResource MaterialDesignCicularProgressBar}" |
| 192 | + Value="20" |
| 193 | + IsIndeterminate="True" |
| 194 | + x:Name="IndeterminateToDeterminateCircularProgress" |
| 195 | + Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="12 12 0 12"/> |
| 196 | + <TextBlock Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" Margin="12" TextWrapping="Wrap">An indeterminate job transitioning to a determinate job, completing to 100%.</TextBlock> |
| 197 | + |
60 | 198 |
|
| 199 | + |
| 200 | + |
61 | 201 | </Grid>
|
| 202 | + <UserControl.Triggers> |
| 203 | + <EventTrigger RoutedEvent="FrameworkElement.Loaded"> |
| 204 | + <EventTrigger.Actions> |
| 205 | + <BeginStoryboard> |
| 206 | + <Storyboard TargetName="DeterminateCircularProgress" TargetProperty="Value" RepeatBehavior="Forever"> |
| 207 | + <DoubleAnimation From="0" To="100" Duration="0:0:2.5"> |
| 208 | + <DoubleAnimation.EasingFunction> |
| 209 | + <CircleEase EasingMode="EaseOut" /> |
| 210 | + </DoubleAnimation.EasingFunction> |
| 211 | + </DoubleAnimation> |
| 212 | + </Storyboard> |
| 213 | + </BeginStoryboard> |
| 214 | + <BeginStoryboard> |
| 215 | + <Storyboard TargetName="IndeterminateToDeterminateCircularProgress" RepeatBehavior="Forever" Duration="0:0:10"> |
| 216 | + <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsIndeterminate"> |
| 217 | + <DiscreteBooleanKeyFrame Value="False" KeyTime="0:0:4" /> |
| 218 | + </BooleanAnimationUsingKeyFrames> |
| 219 | + <DoubleAnimation From="20" To="100" Duration="0:0:2.5" BeginTime="0:0:4" |
| 220 | + Storyboard.TargetProperty="Value" |
| 221 | + FillBehavior="HoldEnd"> |
| 222 | + <DoubleAnimation.EasingFunction> |
| 223 | + <CircleEase EasingMode="EaseOut" /> |
| 224 | + </DoubleAnimation.EasingFunction> |
| 225 | + </DoubleAnimation> |
| 226 | + </Storyboard> |
| 227 | + </BeginStoryboard> |
| 228 | + </EventTrigger.Actions> |
| 229 | + </EventTrigger> |
| 230 | + </UserControl.Triggers> |
62 | 231 |
|
63 | 232 | </UserControl>
|
0 commit comments