<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
                    xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters">

	<converters:ClockLineConverter x:Key="ClockHourLineConverter" DisplayMode="Hours" />
	<converters:ClockLineConverter x:Key="ClockMinuteLineConverter" DisplayMode="Minutes" />
    <converters:NotConverter x:Key="NotConverter" />
	
	<Style x:Key="MaterialDesignClockItemThumb" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Ellipse Fill="{TemplateBinding Background}" />
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="MaterialDesignCalendarMeridiemRadioButton" TargetType="{x:Type RadioButton}">
		<Setter Property="FontSize" Value="14" />
		<Setter Property="FontWeight" Value="Medium" />
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RadioButton}">
					<Grid>
						<Ellipse Fill="{TemplateBinding Background}" />
						<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<Trigger Property="IsChecked" Value="True">
				<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}" />
				<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}" />
			</Trigger>
		</Style.Triggers>
	</Style>

	<Style x:Key="MaterialDesignClock" TargetType="{x:Type wpf:Clock}">
		<Setter Property="Width" Value="280" />
		<Setter Property="Height" Value="470" />
		<Setter Property="BorderThickness" Value="1" />		
		<Setter Property="ButtonRadiusRatio" Value=".835" />		
		<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
		<Setter Property="ButtonStyle">
			<Setter.Value>
				<Style TargetType="{x:Type wpf:ClockItemButton}">
					<Setter Property="Background" Value="Transparent" />
					<Setter Property="Width" Value="32" />
					<Setter Property="Height" Value="32" />
					<Setter Property="HorizontalContentAlignment" Value="Center" />
					<Setter Property="VerticalContentAlignment" Value="Center" />
					<Setter Property="Canvas.ZIndex" Value="0" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type wpf:ClockItemButton}">
								<Grid>
									<Thumb Style="{StaticResource MaterialDesignClockItemThumb}" Background="{TemplateBinding Background}" Opacity="23"
												   x:Name="PART_Thumb"/>
									<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
															  IsHitTestVisible="False"/>
								</Grid>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
					<Style.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" />
						</Trigger>
						<Trigger Property="IsChecked" Value="True">
							<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}" />
							<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</Setter.Value>
		</Setter>
		<Setter Property="LesserButtonStyle">
			<Setter.Value>
				<Style TargetType="{x:Type wpf:ClockItemButton}">
					<Setter Property="Background" Value="Transparent" />
					<Setter Property="Width" Value="12" />
					<Setter Property="Height" Value="12" />
					<Setter Property="HorizontalContentAlignment" Value="Center" />
					<Setter Property="VerticalContentAlignment" Value="Center" />
					<Setter Property="Canvas.ZIndex" Value="1" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type wpf:ClockItemButton}">
								<Grid>
									<Thumb Style="{StaticResource MaterialDesignClockItemThumb}" Background="{TemplateBinding Background}" Opacity=".52"
												   x:Name="PART_Thumb"
												   ToolTip="{TemplateBinding Content}"/>
									<Ellipse Fill="{TemplateBinding Background}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="6" Width="6"
													 IsHitTestVisible="False"/>
								</Grid>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
					<Style.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" />
						</Trigger>
						<Trigger Property="IsChecked" Value="True">
							<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</Setter.Value>
		</Setter>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type wpf:Clock}">
					<Border Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
        					BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="*" />
							</Grid.RowDefinitions>
							<Border Background="{DynamicResource PrimaryHueMidBrush}" Height="120"  CornerRadius="2 2 0 0">
								<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 6 38 0">
									<StackPanel.Resources>
										<Style x:Key="TimeTextBlock" TargetType="{x:Type TextBlock}">
                                            <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}" />
											<Setter Property="FontSize" Value="66" />
											<Setter Property="FontWeight" Value="Normal" />
										</Style>
									</StackPanel.Resources>
									<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Time, Mode=OneWay, StringFormat={}{0:%h}}" 
													   x:Name="PART_HourReadOut">
										<TextBlock.Style>
											<Style BasedOn="{StaticResource TimeTextBlock}" TargetType="{x:Type TextBlock}">
												<Setter Property="Opacity" Value=".56"></Setter>
												<Style.Triggers>
													<DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisplayMode}" Value="{x:Static wpf:ClockDisplayMode.Hours}">
														<Setter Property="Opacity" Value="1" />
													</DataTrigger>
												</Style.Triggers>
											</Style>
										</TextBlock.Style>
									</TextBlock>
									<TextBlock Text=":" Style="{StaticResource TimeTextBlock}" />
									<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Time, Mode=OneWay, StringFormat={}{0:mm}}" 
													   x:Name="PART_MinuteReadOut">
										<TextBlock.Style>
											<Style BasedOn="{StaticResource TimeTextBlock}" TargetType="{x:Type TextBlock}">
												<Setter Property="Opacity" Value=".56"></Setter>
												<Style.Triggers>
													<DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisplayMode}" Value="{x:Static  wpf:ClockDisplayMode.Minutes}">
														<Setter Property="Opacity" Value="1" />
													</DataTrigger>
												</Style.Triggers>
											</Style>
										</TextBlock.Style>
									</TextBlock>
									<TextBlock FontSize="16" 
                                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Time, Mode=OneWay, StringFormat={}{0:tt}}" 
                                               VerticalAlignment="Bottom" Margin="2 0 0 16" Foreground="{DynamicResource PrimaryHueMidForegroundBrush}" />
								</StackPanel>
							</Border>
							<Ellipse Grid.Row="1" Margin="0,24.5,0,94" Width="230" Height="230" Fill="{DynamicResource PrimaryHueLightBrush}" Opacity=".23" />
							<Canvas x:Name="PART_HoursCanvas" Grid.Row="1" Margin="0,24.5,0,159.5" Width="230" Height="230"
											RenderTransformOrigin=".5,.5">
								<Path x:Name="HourLine" Data="M2.25,95.515 C2.25,96.036356 1.8582492,96.459 1.375,96.459 C0.89175084,96.459 0.5,96.036356 0.5,95.515 C0.5,94.993643 0.89175084,94.571 1.375,94.571 C1.8582492,94.571 2.25,94.993643 2.25,95.515 z M1.375,95.469003 L1.375,0.50000001" Fill="{DynamicResource PrimaryHueMidBrush}" Height="96.959" Canvas.Left="113.625" Stretch="Fill" Stroke="{DynamicResource PrimaryHueMidBrush}" Canvas.Top="19.047" Width="2.75" RenderTransformOrigin="0.5,0.985">
									<Path.RenderTransform>
										<RotateTransform Angle="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Time, Converter={StaticResource ClockHourLineConverter}}" />
									</Path.RenderTransform>
								</Path>
								<Canvas.RenderTransform>
									<ScaleTransform x:Name="HoursScaleTransform" ScaleX="1" ScaleY="1" />
								</Canvas.RenderTransform>
							</Canvas>
							<Canvas x:Name="PART_MinutesCanvas" Grid.Row="1" Margin="0,24.5,0,159.5" Width="230" Height="230" Opacity="0" IsHitTestVisible="False"
											RenderTransformOrigin=".5,.5">
								<Path x:Name="MinuteLine" Data="M2.25,95.515 C2.25,96.036356 1.8582492,96.459 1.375,96.459 C0.89175084,96.459 0.5,96.036356 0.5,95.515 C0.5,94.993643 0.89175084,94.571 1.375,94.571 C1.8582492,94.571 2.25,94.993643 2.25,95.515 z M1.375,95.469003 L1.375,0.50000001" Fill="{DynamicResource PrimaryHueMidBrush}" Height="96.959" Canvas.Left="113.625" Stretch="Fill" Stroke="{DynamicResource PrimaryHueMidBrush}" Canvas.Top="19.047" Width="2.75" RenderTransformOrigin="0.5,0.985">
									<Path.RenderTransform>
										<RotateTransform Angle="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Time, Converter={StaticResource ClockMinuteLineConverter}}" />
									</Path.RenderTransform>
								</Path>
								<Canvas.RenderTransform>
									<ScaleTransform x:Name="MinutesScaleTransform" ScaleX="1" ScaleY="1" />
								</Canvas.RenderTransform>
							</Canvas>
							<RadioButton Content="AM" GroupName="Meridien" HorizontalAlignment="Left" Height="47.333" Margin="31.666,0,0,37.667" Grid.Row="1" VerticalAlignment="Bottom" Width="47.333" Style="{StaticResource MaterialDesignCalendarMeridiemRadioButton}"
												 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsPostMeridiem, Converter={StaticResource NotConverter}}" />
							<RadioButton Content="PM" GroupName="Meridien" HorizontalAlignment="Right" Height="47.333" Margin="0,0,31.667,37.667" Grid.Row="1" VerticalAlignment="Bottom" Width="47.333" Style="{StaticResource MaterialDesignCalendarMeridiemRadioButton}"
												 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsPostMeridiem}" />
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="DisplayMode" Value="Minutes">
							<Trigger.EnterActions>
								<BeginStoryboard>
									<Storyboard>
										<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_HoursCanvas" Storyboard.TargetProperty="IsHitTestVisible">
											<DiscreteBooleanKeyFrame Value="False" KeyTime="0" />
										</BooleanAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HoursCanvas" Storyboard.TargetProperty="Opacity">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="HoursScaleTransform" Storyboard.TargetProperty="ScaleX">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1.2" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="HoursScaleTransform" Storyboard.TargetProperty="ScaleY">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1.2" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_MinutesCanvas" Storyboard.TargetProperty="IsHitTestVisible">
											<DiscreteBooleanKeyFrame Value="True" KeyTime="0" />
										</BooleanAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_MinutesCanvas" Storyboard.TargetProperty="Opacity">
											<DiscreteDoubleKeyFrame Value="0" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MinutesScaleTransform" Storyboard.TargetProperty="ScaleX">
											<DiscreteDoubleKeyFrame Value="0.85" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MinutesScaleTransform" Storyboard.TargetProperty="ScaleY">
											<DiscreteDoubleKeyFrame Value="0.85" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard>
									<Storyboard>
										<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_HoursCanvas" Storyboard.TargetProperty="IsHitTestVisible">
											<DiscreteBooleanKeyFrame Value="True" KeyTime="0" />
										</BooleanAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HoursCanvas" Storyboard.TargetProperty="Opacity">
											<DiscreteDoubleKeyFrame Value="0" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.4">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="HoursScaleTransform" Storyboard.TargetProperty="ScaleX">
											<DiscreteDoubleKeyFrame Value="1.2" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="HoursScaleTransform" Storyboard.TargetProperty="ScaleY">
											<DiscreteDoubleKeyFrame Value="1.2" KeyTime="0" />
											<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_MinutesCanvas" Storyboard.TargetProperty="IsHitTestVisible">
											<DiscreteBooleanKeyFrame Value="False" KeyTime="0" />
										</BooleanAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_MinutesCanvas" Storyboard.TargetProperty="Opacity">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MinutesScaleTransform" Storyboard.TargetProperty="ScaleX">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value=".85" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MinutesScaleTransform" Storyboard.TargetProperty="ScaleY">
											<DiscreteDoubleKeyFrame Value="1" KeyTime="0" />
											<EasingDoubleKeyFrame Value=".85" KeyTime="0:0:0.5">
												<EasingDoubleKeyFrame.EasingFunction>
													<SineEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.ExitActions>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>