<UserControl
    x:Class="Bili.App.Controls.Danmaku.DanmakuSendOptions"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Bili.Models.Enums.App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    d:DesignHeight="300"
    d:DesignWidth="400"
    IsFocusEngagementEnabled="True"
    RequiresPointer="WhenEngaged"
    mc:Ignorable="d">

    <StackPanel
        Width="240"
        Padding="16,12"
        Spacing="12">
        <StackPanel Spacing="4">
            <TextBlock Text="{loc:Locale Name=FontSize}" />
            <StackPanel
                HorizontalAlignment="Left"
                Orientation="Horizontal"
                Spacing="16">
                <RadioButton
                    x:Name="StandardItem"
                    MinWidth="0"
                    Click="OnSizeItemClick"
                    Content="{loc:Locale Name=Standard}"
                    IsChecked="{x:Bind ViewModel.IsStandardSize, Mode=OneWay}" />
                <RadioButton
                    x:Name="SmallItem"
                    MinWidth="0"
                    Click="OnSizeItemClick"
                    Content="{loc:Locale Name=Small}"
                    IsChecked="{x:Bind ViewModel.IsStandardSize, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}" />
            </StackPanel>
        </StackPanel>
        <ComboBox
            x:Name="DanmakuLocationComboBox"
            HorizontalAlignment="Stretch"
            Header="{loc:Locale Name=Location}"
            ItemsSource="{x:Bind ViewModel.LocationCollection, 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="{loc: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}" />
                <Rectangle
                    Grid.Column="1"
                    Width="80"
                    Fill="{x:Bind ViewModel.Color, Mode=OneWay, Converter={StaticResource BrushConverter}}"
                    RadiusX="4"
                    RadiusY="4" />
            </Grid>
            <muxc:ItemsRepeater HorizontalAlignment="Stretch" ItemsSource="{x:Bind ViewModel.ColorCollection}">
                <muxc:ItemsRepeater.Layout>
                    <muxc:UniformGridLayout
                        ItemsStretch="Fill"
                        MinColumnSpacing="8"
                        MinItemHeight="32"
                        MinItemWidth="32"
                        MinRowSpacing="8" />
                </muxc:ItemsRepeater.Layout>
                <muxc:ItemsRepeater.ItemTemplate>
                    <DataTemplate>
                        <local:CardPanel
                            AutomationProperties.Name="{Binding Key}"
                            Background="{Binding Value, Converter={StaticResource BrushConverter}}"
                            BorderThickness="0"
                            Click="OnColorItemClick"
                            PointerOverBackground="{Binding Value, Converter={StaticResource BrushConverter}}"
                            PressedBackground="{Binding Value, Converter={StaticResource BrushConverter}}"
                            ToolTipService.ToolTip="{Binding Key}" />
                    </DataTemplate>
                </muxc:ItemsRepeater.ItemTemplate>
            </muxc:ItemsRepeater>
        </StackPanel>
    </StackPanel>
</UserControl>
