<!--
  // (c) Copyright Microsoft Corporation.
  // This source is subject to the Microsoft Public License (Ms-PL).
  // Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
  // All other rights reserved.
-->

<ResourceDictionary xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Design.PreviewWith>
    <Border Width="200"
            Padding="20">
      <StackPanel Spacing="20">
        <ListBoxItem Theme="{DynamicResource SimpleDateTimePickerItem}">Standard Item</ListBoxItem>
        <ListBoxItem Theme="{DynamicResource SimpleDateTimePickerItem}" Classes="MonthItem">Month Item</ListBoxItem>
        <RepeatButton Theme="{DynamicResource SimpleDateTimePickerButton}">Button</RepeatButton>
        <RepeatButton Theme="{DynamicResource SimpleDateTimePickerUpButton}" IsVisible="True"/>
        <RepeatButton Theme="{DynamicResource SimpleDateTimePickerDownButton}" IsVisible="True"/>
      </StackPanel>
    </Border>
  </Design.PreviewWith>

  <!--  Theme for the items displayed in the selectors  -->
  <ControlTheme x:Key="SimpleDateTimePickerItem"
                BasedOn="{StaticResource {x:Type ListBoxItem}}"
                TargetType="ListBoxItem">
    <Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterItemPadding}" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />

    <Style Selector="^:selected">
      <Setter Property="IsHitTestVisible" Value="False" />
      <Style Selector="^/template/ Rectangle#PressedBackground">
        <Setter Property="Fill" Value="Transparent" />
      </Style>
      <Style Selector="^/template/ ContentPresenter">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
      </Style>
    </Style>
    <Style Selector="^.MonthItem">
      <Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterMonthPadding}" />
      <Setter Property="HorizontalContentAlignment" Value="Left" />
    </Style>
  </ControlTheme>

  <!--  This is used for both the accept/dismiss & repeatbuttons in the presenter  -->
  <ControlTheme x:Key="SimpleDateTimePickerButton"
                TargetType="Button">
    <Setter Property="Background" Value="{DynamicResource ThemeControlTransparentBrush}" />
    <Setter Property="Height" Value="22" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Template">
      <ControlTemplate>
        <!--
          The background is doubled here for the loopingselector up/down repeat buttons
          that appear opaque. Not sure how MS does it though I suspect this is it
          but source isn't MIT yet, so this is my solution
        -->
        <Border Background="{TemplateBinding Background}">
          <ContentPresenter x:Name="ContentPresenter"
                            Padding="{TemplateBinding Padding}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{DynamicResource ThemeControlTransparentBrush}"
                            BorderThickness="{DynamicResource DateTimeFlyoutButtonBorderThickness}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            CornerRadius="{TemplateBinding CornerRadius}"
                            Foreground="{DynamicResource ThemeForegroundBrush}" />
        </Border>
      </ControlTemplate>
    </Setter>

    <Style Selector="^:pointerover /template/ ContentPresenter">
      <Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}" />
      <Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
    </Style>

    <Style Selector="^:pressed /template/ ContentPresenter">
      <Setter Property="Background">
        <SolidColorBrush Opacity="0.6"
                         Color="{DynamicResource ThemeControlMidHighColor}" />
      </Setter>
      <Setter Property="BorderBrush" Value="{DynamicResource ThemeControlLowBrush}" />
      <Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
    </Style>
  </ControlTheme>

  <ControlTheme x:Key="SimpleDateTimePickerUpButton"
                BasedOn="{StaticResource SimpleDateTimePickerButton}"
                TargetType="RepeatButton">
    <Setter Property="VerticalAlignment" Value="Top" />
    <Setter Property="Height" Value="22" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightLowBrush}" />
    <Setter Property="IsVisible" Value="False" />
    <Setter Property="Content">
      <Template>
        <Viewbox Width="10"
                 Height="10"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center">
          <Path Data="M 0,9 L 9,0 L 18,9"
                Stroke="{Binding $parent[RepeatButton].Foreground}"
                StrokeThickness="1" />
        </Viewbox>
      </Template>
    </Setter>
  </ControlTheme>

  <ControlTheme x:Key="SimpleDateTimePickerDownButton"
                BasedOn="{StaticResource SimpleDateTimePickerButton}"
                TargetType="RepeatButton">
    <Setter Property="VerticalAlignment" Value="Bottom" />
    <Setter Property="Height" Value="22" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightLowBrush}" />
    <Setter Property="IsVisible" Value="False" />
    <Setter Property="Content">
      <Template>
        <Viewbox Width="10"
                 Height="10"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center">
          <Path Data="M 0,0 L 9,9 L 18,0"
                Stroke="{Binding $parent[RepeatButton].Foreground}"
                StrokeThickness="1" />
        </Viewbox>
      </Template>
    </Setter>
  </ControlTheme>
</ResourceDictionary>