<?xml version="1.0" encoding="utf-8" ?>
<local:DanmakuControlBase
    x:Class="BiliCopilot.UI.Controls.Danmaku.DanmakuSendOptions"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Richasy.BiliKernel.Models"
    xmlns:converters="using:BiliCopilot.UI.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:local="using:BiliCopilot.UI.Controls.Danmaku"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <UserControl.Resources>
        <converters:DanmakuLocationConverter x:Key="DanmakuLocationConverter" />
    </UserControl.Resources>

    <StackPanel
        Width="240"
        Padding="8,4"
        Spacing="12">
        <StackPanel Spacing="4">
            <TextBlock Text="{ext:Locale Name=FontSize}" />
            <StackPanel
                HorizontalAlignment="Left"
                Orientation="Horizontal"
                Spacing="16">
                <RadioButton
                    x:Name="StandardItem"
                    MinWidth="0"
                    Click="OnSizeItemClick"
                    Content="{ext:Locale Name=Standard}"
                    IsChecked="{x:Bind ViewModel.IsStandardSize, Mode=OneWay}"
                    Tag="Standard" />
                <RadioButton
                    x:Name="SmallItem"
                    MinWidth="0"
                    Click="OnSizeItemClick"
                    Content="{ext:Locale Name=Small}"
                    IsChecked="{x:Bind ViewModel.IsStandardSize, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
                    Tag="Small" />
            </StackPanel>
        </StackPanel>
        <ComboBox
            x:Name="DanmakuLocationComboBox"
            HorizontalAlignment="Stretch"
            Header="{ext:Locale Name=Location}"
            ItemsSource="{x:Bind ViewModel.Locations, Mode=OneWay}"
            SelectedItem="{x:Bind ViewModel.Location, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate x:DataType="app:DanmakuLocation">
                    <TextBlock Text="{x:Bind Converter={StaticResource DanmakuLocationConverter}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <StackPanel Spacing="12">
            <TextBlock Text="{ext:Locale Name=Color}" />
            <Grid Margin="0,-4,0,0" ColumnSpacing="8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBox
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    IsReadOnly="True"
                    Text="{x:Bind ViewModel.Color, Mode=OneWay, Converter={StaticResource ColorTextConverter}}" />
                <Rectangle
                    Grid.Column="1"
                    Width="80"
                    Fill="{x:Bind ViewModel.Color, Mode=OneWay, Converter={StaticResource BrushConverter}}"
                    RadiusX="4"
                    RadiusY="4" />
            </Grid>
            <ItemsRepeater
                x:Name="ColorRepeater"
                HorizontalAlignment="Stretch"
                ItemsSource="{x:Bind ViewModel.Colors, Mode=OneWay}">
                <ItemsRepeater.Layout>
                    <UniformGridLayout
                        ItemsStretch="Fill"
                        MinColumnSpacing="8"
                        MinItemHeight="32"
                        MinItemWidth="32"
                        MinRowSpacing="8" />
                </ItemsRepeater.Layout>
                <ItemsRepeater.ItemTemplate>
                    <DataTemplate x:DataType="Color">
                        <Rectangle
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            DataContext="{x:Bind}"
                            Fill="{x:Bind Converter={StaticResource BrushConverter}}"
                            RadiusX="4"
                            RadiusY="4"
                            Tapped="OnColorItemTapped" />
                    </DataTemplate>
                </ItemsRepeater.ItemTemplate>
            </ItemsRepeater>
        </StackPanel>
    </StackPanel>
</local:DanmakuControlBase>
