<Page
    x:Class="LightViews.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:LightViews"
    xmlns:c1="using:C1.Xaml.Schedule"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.BottomAppBar>
        <CommandBar IsOpen="false" ClosedDisplayMode="Minimal" RequestedTheme="Dark" >
            <AppBarButton x:Name="ViewButton" Icon="Switch" Click="View_Click" Visibility="Collapsed"/>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <c1:C1Scheduler x:Name="sched1" Grid.Row="1"
                        OneDayStyle="{StaticResource OneDayStyle}"
                        WeekStyle="{StaticResource WeekStyle}"
                        WorkingWeekStyle="{StaticResource WorkingWeekStyle}"
                        MonthStyle="{StaticResource MonthStyle}"/>

        <StackPanel x:Name="toolsPanel" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="1">
            <StackPanel.Resources>
                <Style TargetType="Button" x:Key="btnStyle">
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="FontSize" Value="{ThemeResource TextStyleLargeFontSize}"/>
                    <Setter Property="Opacity" Value="0.85"/>
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Foreground" Value="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderThemeBrush}"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="Height" Value="44"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Button">
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal"/>
                                            <VisualState x:Name="PointerOver">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Border">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPointerOverBackgroundThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Border">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedBackgroundThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonPressedForegroundThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Border">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBackgroundThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Border">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledBorderThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
                                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonDisabledForegroundThemeBrush}"/>
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="FocusStates">
                                            <VisualState x:Name="Focused">
                                                <Storyboard>
                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualWhite"/>
                                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualBlack"/>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Unfocused"/>
                                            <VisualState x:Name="PointerFocused"/>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="2">
                                        <ContentPresenter x:Name="ContentPresenter" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                    </Border>
                                    <Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1"/>
                                    <Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="0.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </StackPanel.Resources>
            <Button Click="DayClick" Style="{StaticResource btnStyle}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="&#xe161;" FontFamily="Segoe UI Symbol" FontSize="22" VerticalAlignment="Center"/>
                        <TextBlock Text="1 Day" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button x:Name="WorkWeekButton" Click="WorkWeekClick" Style="{StaticResource btnStyle}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="&#xe162;" FontFamily="Segoe UI Symbol" FontSize="22" VerticalAlignment="Center"/>
                        <TextBlock Text="Work Week" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button x:Name="WeekButton" Click="WeekClick" Style="{StaticResource btnStyle}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="&#xe162;" FontFamily="Segoe UI Symbol" FontSize="22" VerticalAlignment="Center"/>
                        <TextBlock Text="Week" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button Click="MonthClick" Style="{StaticResource btnStyle}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="&#xe163;" FontFamily="Segoe UI Symbol" FontSize="22" VerticalAlignment="Center"/>
                        <TextBlock Text="Month" VerticalAlignment="Center"/>
                    </StackPanel>
                </Button.Content>
            </Button>
        </StackPanel>

        <VisualStateManager.VisualStateGroups>
            <!-- Visual states reflect the application's window size -->
            <VisualStateGroup>
                <VisualState x:Name="WideLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="1240" />
                    </VisualState.StateTriggers>
                </VisualState>

                <VisualState x:Name="MiddleLayout1">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="1024" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="toolsPanel.(Grid.Row)" Value="0" />
                    </VisualState.Setters>
                </VisualState>

                <VisualState x:Name="MiddleLayout2">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="640" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="toolsPanel.(Grid.Row)" Value="0" />
                    </VisualState.Setters>
                </VisualState>

                <VisualState x:Name="NarrowLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="WorkWeekButton.Visibility" Value="Collapsed" />
                        <Setter Target="WeekButton.Visibility" Value="Collapsed" />
                        <Setter Target="ViewButton.Visibility" Value="Visible" />
                        <Setter Target="toolsPanel.(Grid.Row)" Value="0" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Page>
