<?xml version="1.0" encoding="utf-8" ?>
<local:DrawSessionControlBase
    x:Class="RodelAgent.UI.Controls.Draw.DrawSessionInput"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:animations="using:CommunityToolkit.WinUI.Animations"
    xmlns:controls="using:RodelAgent.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:RodelAgent.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:RodelAgent.UI.Controls.Draw"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Padding="20,0,20,20">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <!--  输入框  -->
        <TextBox
            x:Name="InputBox"
            MaxHeight="400"
            Padding="12,8,12,12"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            AcceptsReturn="True"
            FontSize="14"
            InputScope="Chat"
            IsEnabled="{x:Bind ViewModel.IsDrawing, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
            IsSpellCheckEnabled="False"
            PlaceholderText="{ext:Locale Name=DrawInputPlaceholder}"
            PreviewKeyDown="OnInputBoxPreviewKeyDownAsync"
            Style="{StaticResource SolidTextBoxStyle}"
            Text="{x:Bind ViewModel.Prompt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
            TextWrapping="Wrap" />

        <!--  底部  -->
        <Grid Grid.Row="1" Padding="0,12,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Orientation="Horizontal"
                Spacing="8"
                Visibility="{x:Bind ViewModel.IsDrawing, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                <ComboBox
                    MinWidth="120"
                    HorizontalAlignment="Left"
                    AutomationProperties.Name="{ext:Locale Name=DrawSize}"
                    FontSize="12"
                    ItemsSource="{x:Bind ViewModel.Sizes}"
                    SelectedItem="{x:Bind ViewModel.Size, Mode=TwoWay}"
                    ToolTipService.ToolTip="{ext:Locale Name=DrawSize}" />
                <Button
                    VerticalAlignment="Center"
                    AutomationProperties.Name="{ext:Locale Name=SessionOptions}"
                    Style="{StaticResource SmallIconButtonStyle}"
                    ToolTipService.ToolTip="{ext:Locale Name=SessionOptions}">
                    <ic:SymbolIcon FontSize="14" Symbol="Wrench" />
                    <Button.Flyout>
                        <Flyout Placement="Top">
                            <local:DrawProviderOptionPanel ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
                        </Flyout>
                    </Button.Flyout>
                </Button>
            </StackPanel>
            <StackPanel
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Orientation="Horizontal"
                Spacing="8"
                Visibility="{x:Bind ViewModel.IsDrawing, Mode=OneWay}">
                <ProgressBar
                    Width="16"
                    VerticalAlignment="Center"
                    IsIndeterminate="True" />
                <TextBlock Style="{StaticResource CaptionTextBlockStyle}" Text="{ext:Locale Name=Generating}" />
                <animations:Implicit.ShowAnimations>
                    <animations:OpacityAnimation
                        From="0"
                        To="1.0"
                        Duration="0:0:0.5" />
                </animations:Implicit.ShowAnimations>
                <animations:Implicit.HideAnimations>
                    <animations:OpacityAnimation
                        From="1"
                        To="0"
                        Duration="0:0:0.5" />
                </animations:Implicit.HideAnimations>
            </StackPanel>
            <StackPanel
                Grid.Column="1"
                Orientation="Horizontal"
                Spacing="12">
                <controls:EnterWrapTip IsEnterSend="{x:Bind ViewModel.IsEnterSend, Mode=OneWay}" />
                <Grid>
                    <SplitButton
                        MinWidth="120"
                        AutomationProperties.Name="{ext:Locale Name=Send}"
                        Command="{x:Bind ViewModel.DrawCommand, Mode=OneWay}"
                        Content="{ext:Locale Name=Send}"
                        Style="{StaticResource AccentSplitButtonStyle}"
                        ToolTipService.ToolTip="{ext:Locale Name=Send}"
                        Visibility="{x:Bind ViewModel.IsDrawing, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                        <SplitButton.Flyout>
                            <MenuFlyout>
                                <ToggleMenuFlyoutItem
                                    x:Name="EnterSendItem"
                                    MinWidth="140"
                                    Click="OnEnterSendItemClick"
                                    Text="{ext:Locale Name=PressEnterToSend}" />
                                <ToggleMenuFlyoutItem
                                    x:Name="CtrlEnterSendItem"
                                    MinWidth="140"
                                    Click="OnCtrlEnterSendItemClick"
                                    Text="{ext:Locale Name=PressCtrlEnterSend}" />
                            </MenuFlyout>
                        </SplitButton.Flyout>
                    </SplitButton>
                    <Button
                        MinWidth="120"
                        AutomationProperties.Name="{ext:Locale Name=Cancel}"
                        Command="{x:Bind ViewModel.CancelDrawCommand, Mode=OneWay}"
                        Style="{StaticResource AccentButtonStyle}"
                        Visibility="{x:Bind ViewModel.IsDrawing, Mode=OneWay}">
                        <StackPanel Orientation="Horizontal" Spacing="8">
                            <ProgressRing
                                Width="16"
                                Height="16"
                                VerticalAlignment="Center"
                                Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}" />
                            <TextBlock VerticalAlignment="Center" Text="{ext:Locale Name=Cancel}" />
                        </StackPanel>
                    </Button>
                </Grid>
            </StackPanel>
        </Grid>
    </Grid>
</local:DrawSessionControlBase>
