<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CustomViews"
    xmlns:c1="using:C1.Xaml"
    xmlns:c1calendar="using:C1.Xaml.Calendar"
    xmlns:c1sched="using:C1.Xaml.Schedule"
    >

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <SolidColorBrush x:Key="TodayBackgroundThemeBrush" Color="#FF006FD0" />
            <SolidColorBrush x:Key="SelectedDayBackgroundThemeBrush" Color="#66006FD0"/>
            <SolidColorBrush x:Key="CurrentTimeThemeBrush" Color="#FF757575" />
            <SolidColorBrush x:Key="TodayForegroundThemeBrush" Color="White"/>
            <SolidColorBrush x:Key="GridLinesBrush" Color="#DFFFFFFF"/>
            <SolidColorBrush x:Key="HotlightThemeBrush" Color="#FF1888D8" />
            <SolidColorBrush x:Key="AppointmentBorderThemeBrush" Color="#FF24AAD8" />
            <SolidColorBrush x:Key="C1SchedulerBackgroundBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="AlternatingBackgroundBrush" Color="#19FFFFFF" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="TodayBackgroundThemeBrush" Color="#FF006FD0" />
            <SolidColorBrush x:Key="SelectedDayBackgroundThemeBrush" Color="#66006FD0"/>
            <SolidColorBrush x:Key="CurrentTimeThemeBrush" Color="#FF757575" />
            <SolidColorBrush x:Key="TodayForegroundThemeBrush" Color="White"/>
            <SolidColorBrush x:Key="GridLinesBrush" Color="#FFEAEAEA"/>
            <SolidColorBrush x:Key="HotlightThemeBrush" Color="#FF1888D8" />
            <SolidColorBrush x:Key="AppointmentBorderThemeBrush" Color="#FF24AAD8" />
            <SolidColorBrush x:Key="C1SchedulerBackgroundBrush" Color="White" />
            <SolidColorBrush x:Key="AlternatingBackgroundBrush" Color="#09000000" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrast">
            <SolidColorBrush x:Key="TodayBackgroundThemeBrush" Color="#FF008000"/>
            <SolidColorBrush x:Key="CurrentTimeThemeBrush" Color="#FF008000" />
            <SolidColorBrush x:Key="TodayForegroundThemeBrush" Color="White"/>
            <SolidColorBrush x:Key="GridLinesBrush" Color="#FFFFFF00"/>
            <SolidColorBrush x:Key="HotlightThemeBrush" Color="#FF00A000" />
            <SolidColorBrush x:Key="AppointmentBorderThemeBrush" Color="#FFFFFF00" />
            <SolidColorBrush x:Key="C1SchedulerBackgroundBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="AlternatingBackgroundBrush" Color="#19FFFFFF" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrastBlack">
            <SolidColorBrush x:Key="TodayBackgroundThemeBrush" Color="#FF1AEBFF"/>
            <SolidColorBrush x:Key="CurrentTimeThemeBrush" Color="#FF1AEBFF" />
            <SolidColorBrush x:Key="TodayForegroundThemeBrush" Color="Black"/>
            <SolidColorBrush x:Key="GridLinesBrush" Color="#FFFFFFFF"/>
            <SolidColorBrush x:Key="HotlightThemeBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="AppointmentBorderThemeBrush" Color="#FFFFFFFF" />
            <SolidColorBrush x:Key="C1SchedulerBackgroundBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="AlternatingBackgroundBrush" Color="#19FFFFFF" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrastWhite">
            <SolidColorBrush x:Key="TodayBackgroundThemeBrush" Color="#FF37006E"/>
            <SolidColorBrush x:Key="CurrentTimeThemeBrush" Color="#FF37006E" />
            <SolidColorBrush x:Key="TodayForegroundThemeBrush" Color="White"/>
            <SolidColorBrush x:Key="GridLinesBrush" Color="#FF000000"/>
            <SolidColorBrush x:Key="HotlightThemeBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="AppointmentBorderThemeBrush" Color="#FF000000" />
            <SolidColorBrush x:Key="C1SchedulerBackgroundBrush" Color="#FFFFFFFF" />
            <SolidColorBrush x:Key="AlternatingBackgroundBrush" Color="#09000000" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <c1calendar:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    <c1sched:VisualIntervalToStringConverter x:Key="VisualIntervalToStringConverter"/>

    <Style TargetType="c1sched:C1Scheduler" x:Key="BaseViewStyle" >
        <Setter Property="TabNavigation" Value="Once" />
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="Background" Value="{ThemeResource C1SchedulerBackgroundBrush}" />
        <Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
        <Setter Property="AlternatingBackground" Value="{ThemeResource AlternatingBackgroundBrush}"/>
        <Setter Property="ControlBackground" Value="{ThemeResource C1SchedulerBackgroundBrush}"/>
        <Setter Property="ControlForeground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="SelectedBackground" Value="{ThemeResource SelectedDayBackgroundThemeBrush}"/>
        <Setter Property="AppointmentForeground" Value="{ThemeResource HotlightThemeBrush}"/>
        <Setter Property="TodayBackground" Value="{ThemeResource TodayBackgroundThemeBrush}"/>
        <Setter Property="CurrentTimeBrush" Value="{ThemeResource CurrentTimeThemeBrush}"/>
        <Setter Property="GridLinesBrush" Value="{ThemeResource GridLinesBrush}"/>
    </Style>

    <!-- determines the style of the month grid header (week day names) -->
    <Style x:Key="C1Scheduler_MonthHeader_Style" TargetType="ContentControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Border BorderThickness="0,0,1,0" IsHitTestVisible="False" BorderBrush="{Binding Path=Scheduler.GridLinesBrush}" >
                        <ContentPresenter Margin="8,6,0,6" Content="{TemplateBinding Content}" HorizontalAlignment="Left" VerticalAlignment="Center" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Alternate month day background (used in a month view) -->
    <c1sched:AlternateMonthBrushConverter x:Key="AlternateMonthBrushConverter" AlternateMonthBrush="Transparent"/>
    <c1sched:MonthToStringConverter x:Key="MonthToStringConverter"/>

    <!-- Determines the style used for displaying overflow jumper in a Month View when not all 
       appointment elements fit into available day space. -->
    <Style x:Key="C1Scheduler_OverflowJumper_Style" TargetType="Button">
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Padding" Value="4,0,4,4"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}"/>
    </Style>
    <!-- determines the style used for displaying single day in a Month view -->
    <c1sched:DayIntervalStyleSelector x:Key="MonthDayStyleSelector">
        <c1sched:DayIntervalStyleSelector.Resources>
            <ResourceDictionary>
                <Style x:Key="C1Scheduler_Day_Style" TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Grid BorderThickness="0,0,1,1" BorderBrush="{Binding Path=Scheduler.GridLinesBrush}"
                                      Background="{Binding Converter={StaticResource AlternateMonthBrushConverter}}" >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Rectangle Fill="{Binding Path=Scheduler.SelectedBackground}" IsHitTestVisible="False" Grid.RowSpan="2" CacheMode="BitmapCache"
								               Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                    <TextBlock FontWeight="Semibold" Foreground="{Binding Path=Scheduler.Foreground}" Margin="8,4,4,4" Grid.Row="0">
                                        <Run Text="{Binding Converter={StaticResource MonthToStringConverter}}"/>
      								    <Run Text="{Binding Converter={StaticResource VisualIntervalToStringConverter}, ConverterParameter=MonthViewDayHeaderDayFormat}"/>
                                    </TextBlock>
                                    <Rectangle x:Name="DayContentBorder" Grid.Row="1" Fill="Transparent" CacheMode="BitmapCache" c1sched:CoverElementsPane.Orientation="Horizontal"/>
                                    <Button x:Name="overflowJumper" Content="&#57361;" Grid.Row="0"
                                            HorizontalAlignment="Right" Foreground="{Binding Path=Scheduler.Foreground}" 
                                            c1:CommandExtensions.CommandParameter="OneDayStyle"  
                                            c1:CommandExtensions.Command="c1sched:C1Scheduler.ChangeStyleCommand" VerticalAlignment="Top" 
                                            Visibility="{Binding Path=(c1sched:CoverElementsPane.CoverElementsOverflow), ElementName=DayContentBorder, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                            Style="{StaticResource C1Scheduler_OverflowJumper_Style}"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
                <Style x:Key="C1Scheduler_Today_Style" TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Grid Background="{Binding Path=Scheduler.TodayBackground}"  
                                      BorderThickness="0,0,1,1" BorderBrush="{Binding Path=Scheduler.GridLinesBrush}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Rectangle Fill="{Binding Path=Scheduler.SelectedBackground}" IsHitTestVisible="False" Grid.RowSpan="2" CacheMode="BitmapCache"
								               Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                    <TextBlock FontWeight="Semibold" Foreground="{StaticResource TodayForegroundThemeBrush}" Margin="8,4,4,4" Grid.Row="0">
                                        <Run Text="{Binding Converter={StaticResource MonthToStringConverter}}"/>
      								    <Run Text="{Binding Converter={StaticResource VisualIntervalToStringConverter}, ConverterParameter=MonthViewDayHeaderDayFormat}"/>
                                    </TextBlock>
                                    <Rectangle x:Name="DayContentBorder" Grid.Row="1" Fill="Transparent" CacheMode="BitmapCache" 
                                               c1sched:CoverElementsPane.Orientation="Horizontal"/>
                                    <Button x:Name="overflowJumper" Content="&#57361;" Grid.Row="0"
                                            HorizontalAlignment="Right" Foreground="{Binding Path=Scheduler.Foreground}" 
                                            c1:CommandExtensions.CommandParameter="OneDayStyle" 
                                            c1:CommandExtensions.Command="c1sched:C1Scheduler.ChangeStyleCommand" VerticalAlignment="Top" 
                                            Visibility="{Binding Path=(c1sched:CoverElementsPane.CoverElementsOverflow), ElementName=DayContentBorder, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                            Style="{StaticResource C1Scheduler_OverflowJumper_Style}"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ResourceDictionary>
        </c1sched:DayIntervalStyleSelector.Resources>
    </c1sched:DayIntervalStyleSelector>

    <!-- Style that represents the base Month View -->
    <Style x:Key="FiveWeekMonthStyle" TargetType="c1sched:C1Scheduler" BasedOn="{StaticResource BaseViewStyle}">
        <Setter Property="VisualTimeSpan" Value="35" /> <!-- Only show 5 weeks --> 
        <Setter Property="VisualIntervalScale" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1sched:C1Scheduler">
                    <Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <!-- nested setters should present in the visual tree, in other case bindings might not work for them -->
                            <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NestedSetters}" IsHitTestVisible="False" />
                            <c1sched:C1SchedulerNavigator Background="{TemplateBinding ControlBackground}" Grid.Row="0" Foreground="{TemplateBinding ControlForeground}"/>
                            <ItemsControl x:Name="PART_FlipView" Grid.Row="1">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <!-- DataContext is the C1SchedulerViewModel object-->
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition />
                                            </Grid.RowDefinitions>
                                            <c1:C1UniformGrid Name="weekHeadersGrid" Grid.Row="0" Rows="1" Columns="7" Background="{Binding Path=Scheduler.ControlBackground}">
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[0], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[1], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[2], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[3], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[4], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[5], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                                <ContentControl Style="{StaticResource C1Scheduler_MonthHeader_Style}" Foreground="{Binding Path=Scheduler.ControlForeground}"
												    Content="{Binding Path=VisibleGroupItems[0].VisualIntervals[6], Converter={StaticResource VisualIntervalToStringConverter},
													    ConverterParameter=MonthViewHeaderFormat}"/>
                                            </c1:C1UniformGrid>
                                            <Rectangle Height="1" HorizontalAlignment="Stretch" Grid.Row="0" VerticalAlignment="Bottom" Fill="{Binding Path=Scheduler.GridLinesBrush}"/>
                                            <c1sched:C1SchedulerPresenter Grid.Row="1" Background="{Binding Path=Scheduler.Background}" ItemContainerStyleSelector="{StaticResource MonthDayStyleSelector}"/>
                                            <c1sched:AppointmentsCoverPane VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                                                Grid.Row="1" c1sched:AppointmentsCoverPane.KeepTimesAtDrop="True"
									            IsDragDropDisabled="{Binding Path=Scheduler.IsDragDropDisabled}" CoverElementsMargin="4" />
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <c1calendar:C1LoopPanel/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                            <Rectangle Grid.Row="1" Opacity="0.6" Stretch="Fill" RadiusX="2" RadiusY="2"
                                       Visibility="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=Invert}"
                                       StrokeThickness="1" Stroke="{ThemeResource ButtonDisabledBorderThemeBrush}"
                                       Fill="{ThemeResource ButtonDisabledBackgroundThemeBrush}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VisualIntervalPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <c1:C1UniformGrid Columns="7" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ThreeWeekStyle" TargetType="c1sched:C1Scheduler" BasedOn="{StaticResource FiveWeekMonthStyle}">
        <Setter Property="VisualTimeSpan" Value="21" />
    </Style>

</ResourceDictionary>
