<ui:Page xmlns:props="clr-namespace:Ink_Canvas.Properties" x:Class="Ink_Canvas.Windows.SettingsViews.Pages.WhiteboardTipsPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews.Pages"
      xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
      xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
      xmlns:sys="clr-namespace:System;assembly=mscorlib"
      xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
      xmlns:c="clr-namespace:Ink_Canvas.Converter"
      mc:Ignorable="d"
      Title="{x:Static props:NavStrings.Nav_WhiteboardTips}">

    <ScrollViewer PanningMode="VerticalFirst">
        <Grid Margin="59,0,59,0">
            <FrameworkElement.Resources>
                <sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
                <c:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
                    <c:BooleanToInverseBooleanConverter x:Key="BooleanToInverseBooleanConverter" />
                <Style x:Key="IconButtonStyle" TargetType="Button"
                       BasedOn="{StaticResource {x:Static ui:ThemeKeys.DefaultButtonStyleKey}}">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="BorderBrush" Value="Transparent"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="Padding" Value="6,4"/>
                </Style>
                <Style x:Key="SettingsSectionHeaderTextBlockStyle"
                    BasedOn="{StaticResource BodyStrongTextBlockStyle}"
                    TargetType="TextBlock">
                    <Style.Setters>
                        <Setter Property="Margin" Value="1,30,0,6" />
                    </Style.Setters>
                </Style>
            </FrameworkElement.Resources>
            <Grid HorizontalAlignment="Stretch">
                <ikw:SimpleStackPanel MaxWidth="1000"
                    HorizontalAlignment="Stretch"
                    Spacing="{StaticResource SettingsCardSpacing}">

                    <!-- Section 1: 全局设置 (Global Settings) -->
                    <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
                        Text="{x:Static props:ThemeStrings.Theme_Tips_GlobalSettings}" />

                    <controls:LabeledSettingsCard x:Name="CardEnableChickenSoupInWhiteboardMode"
                            Header="{x:Static props:ThemeStrings.Theme_ShowQuoteInWhiteboard}"
                            Icon="{x:Static ui:SegoeFluentIcons.Message}"
                            SwitchName="ToggleSwitchEnableChickenSoupInWhiteboardMode"
                            Toggled="ToggleSwitchEnableChickenSoupInWhiteboardMode_Toggled" />

                    <ui:SettingsCard x:Name="CardQuotePosition" Header="{x:Static props:ThemeStrings.Theme_QuotePosition}">
                        <ui:SettingsCard.HeaderIcon>
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.POI}" />
                        </ui:SettingsCard.HeaderIcon>
                        <ComboBox x:Name="ComboBoxChickenSoupPosition"
                                  MinWidth="180"
                                  SelectionChanged="ComboBoxChickenSoupPosition_SelectionChanged">
                            <ComboBoxItem Content="{x:Static props:ThemeStrings.Theme_QuotePosition_TopRight}" Tag="TopRight" />
                            <ComboBoxItem Content="{x:Static props:ThemeStrings.Theme_QuotePosition_TopLeft}" Tag="TopLeft" />
                            <ComboBoxItem Content="{x:Static props:ThemeStrings.Theme_QuotePosition_BottomRight}" Tag="BottomRight" />
                            <ComboBoxItem Content="{x:Static props:ThemeStrings.Theme_QuotePosition_BottomLeft}" Tag="BottomLeft" />
                        </ComboBox>
                    </ui:SettingsCard>

                    <controls:LabeledSettingsCard x:Name="CardEnableAutoRotation"
                            Header="{x:Static props:ThemeStrings.Theme_Tips_AutoRotation}"
                            Description="{x:Static props:ThemeStrings.Theme_Tips_AutoRotationHint}"
                            Icon="{x:Static ui:SegoeFluentIcons.Sync}"
                            SwitchName="ToggleSwitchEnableAutoRotation"
                            Toggled="ToggleSwitchEnableAutoRotation_Toggled" />

                    <ui:SettingsCard x:Name="CardRotationInterval"
                            Header="{x:Static props:ThemeStrings.Theme_Tips_RotationInterval}"
                            Description="{x:Static props:ThemeStrings.Theme_Tips_RotationIntervalHint}">
                        <ui:SettingsCard.HeaderIcon>
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Sync}" />
                        </ui:SettingsCard.HeaderIcon>
                        <ComboBox x:Name="ComboBoxRotationInterval"
                                  IsEditable="True"
                                  MinWidth="120"
                                  SelectionChanged="ComboBoxRotationInterval_SelectionChanged">
                            <ComboBoxItem Content="10" />
                            <ComboBoxItem Content="15" />
                            <ComboBoxItem Content="20" />
                            <ComboBoxItem Content="30" />
                            <ComboBoxItem Content="60" />
                            <ComboBoxItem Content="120" />
                            <ComboBoxItem Content="180" />
                            <ComboBoxItem Content="300" />
                        </ComboBox>
                    </ui:SettingsCard>

                    <!-- Section 2: 信仰の源出自 Where? -->
                    <Grid Margin="1,30,0,6">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Style="{StaticResource BodyStrongTextBlockStyle}"
                                   Text="{x:Static props:ThemeStrings.Theme_QuoteSource}" />
                            <ikw:SimpleStackPanel Grid.Column="1" Orientation="Horizontal" Spacing="8">
                            <Button x:Name="BtnCustomizeHitokoto" Content="{x:Static props:ThemeStrings.Theme_Hitokoto_CustomizeTitle}"
                                    Padding="14,4" Click="BtnCustomizeHitokoto_Click" />
                            <Button x:Name="BtnImport" Content="{x:Static props:ThemeStrings.Theme_Tips_Import}"
                                    Padding="14,4" Click="BtnImport_Click" />
                            <Button x:Name="BtnCreate" Content="{x:Static props:ThemeStrings.Theme_Tips_Create}"
                                    Padding="14,4" Click="BtnCreate_Click"
                                    Style="{DynamicResource AccentButtonStyle}" />
                        </ikw:SimpleStackPanel>
                    </Grid>

                    <Border BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
                            BorderThickness="1"
                            CornerRadius="8"
                            Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
                            Padding="8">
                        <ui:ListView x:Name="ListViewSchemes"
                                  Background="Transparent"
                                  BorderThickness="0"
                                  MinHeight="200"
                                  MaxHeight="400"
                                  HorizontalAlignment="Stretch"
                                  HorizontalContentAlignment="Stretch"
                                  SelectionChanged="ListViewSchemes_SelectionChanged">
                            <ui:ListView.Template>
                                <ControlTemplate TargetType="ui:ListView">
                                    <Border Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}">
                                        <ScrollViewer HorizontalScrollBarVisibility="Disabled"
                                                      VerticalScrollBarVisibility="Auto">
                                            <ItemsPresenter HorizontalAlignment="Stretch" />
                                        </ScrollViewer>
                                    </Border>
                                </ControlTemplate>
                            </ui:ListView.Template>
                            <ui:ListView.ItemContainerStyle>
                                <Style TargetType="ui:ListViewItem">
                                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                    <Setter Property="Padding" Value="8,4" />
                                    <Setter Property="MinHeight" Value="36" />
                                </Style>
                            </ui:ListView.ItemContainerStyle>
                            <ui:ListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel />
                                </ItemsPanelTemplate>
                            </ui:ListView.ItemsPanel>
                            <ui:ListView.ItemTemplate>
                                <DataTemplate>
                                    <Grid HorizontalAlignment="Stretch">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <CheckBox Grid.Column="0" IsChecked="{Binding IsEnabled}"
                                                  Checked="SchemeCheckBox_Changed" Unchecked="SchemeCheckBox_Changed"
                                                  VerticalAlignment="Center" Margin="0,0,8,0" />
                                        <TextBlock Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left" />
                                        <ui:FontIcon Grid.Column="2" Glyph="&#xE72E;"
                                                     Visibility="{Binding IsPreset, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                     FontSize="14" VerticalAlignment="Center" Margin="0,0,8,0" />
                                        <Button Grid.Column="3" Click="BtnExport_Click"
                                                Style="{StaticResource IconButtonStyle}" VerticalAlignment="Center"
                                                ToolTip="{x:Static props:ThemeStrings.Theme_Tips_Export}">
                                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Download}" FontSize="14" />
                                        </Button>
                                        <Button Grid.Column="4" Click="BtnEdit_Click" VerticalAlignment="Center"
                                                ToolTip="{x:Static props:ThemeStrings.Theme_Tips_Edit}">
                                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" FontSize="14" />
                                            <Button.Style>
                                                <Style TargetType="Button" BasedOn="{StaticResource IconButtonStyle}">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding IsPreset}" Value="True">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Button.Style>
                                        </Button>
                                        <Button Grid.Column="5" Click="BtnDeleteScheme_Click" VerticalAlignment="Center"
                                                ToolTip="Delete">
                                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" FontSize="14" />
                                            <Button.Style>
                                                <Style TargetType="Button" BasedOn="{StaticResource IconButtonStyle}">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding IsPreset}" Value="True">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Button.Style>
                                        </Button>
                                    </Grid>
                                </DataTemplate>
                            </ui:ListView.ItemTemplate>
                        </ui:ListView>
                    </Border>

                    <Rectangle Height="48" />
                </ikw:SimpleStackPanel>
            </Grid>
        </Grid>
    </ScrollViewer>
</ui:Page>
