<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.AddFastFlagDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
        xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
        xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
        xmlns:resources="clr-namespace:Bloxstrap.Resources"
        xmlns:converters="clr-namespace:Bloxstrap.UI.Converters"
        mc:Ignorable="d"
        Title="{x:Static resources:Strings.Dialog_AddFastFlag_Title}" 
        MinHeight="0"
        Width="480"
        SizeToContent="Height"
        ResizeMode="NoResize"
        Background="{ui:ThemeResource ApplicationBackgroundBrush}"
        ExtendsContentIntoTitleBar="True"
        WindowStartupLocation="CenterScreen">
    <ui:UiWindow.Resources>
        <converters:RangeConverter x:Key="ValidationConverter" From="0" />
    </ui:UiWindow.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" Title="{x:Static resources:Strings.Dialog_AddFastFlag_Title}" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" />

        <TabControl x:Name="Tabs" Grid.Row="1" Margin="16">
            <TabItem Header="{x:Static resources:Strings.Common_AddSingle}">
                <Grid Grid.Row="1" Margin="16">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" MinWidth="100" Text="{x:Static resources:Strings.Common_Name}" Margin="0,0,0,12" />
                    <TextBox Grid.Row="0" Grid.Column="1" Name="FlagNameTextBox" Margin="0,0,0,12" />

                    <TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" MinWidth="100" Text="{x:Static resources:Strings.Common_Value}" />
                    <TextBox Grid.Row="1" Grid.Column="1" Name="FlagValueTextBox" />
                </Grid>
            </TabItem>
            <TabItem Header="{x:Static resources:Strings.Common_ImportJson}">
                <Grid Margin="11">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <TextBox Grid.Row="0" x:Name="JsonTextBox" Margin="5" AcceptsTab="True" AcceptsReturn="True" MinHeight="80" MaxHeight="480" />
                    <TextBlock Grid.Row="0" IsHitTestVisible="False" Margin="18,14,0,0" Foreground="DarkGray" Text="{}{&#10;    &quot;FFlagDebugDisplayFPS&quot;: &quot;True&quot;&#10;}">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Text, ElementName=JsonTextBox}" Value="">
                                        <Setter Property="Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    <ui:Button Grid.Row="1" Margin="4" Icon="DocumentArrowUp16" Content="{x:Static resources:Strings.Common_ImportFromFile}" HorizontalAlignment="Stretch" Click="ImportButton_Click" />
                </Grid>
            </TabItem>
        </TabControl>

        <Border Grid.Row="2" Margin="0,10,0,0" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}">
            <StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
                <Button MinWidth="100" Content="{x:Static resources:Strings.Common_OK}" Click="OKButton_Click">
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
                            <Style.Triggers>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding ElementName=Tabs, Path=SelectedIndex}" Value="0" />
                                        <Condition Binding="{Binding ElementName=FlagNameTextBox, Path=Text.Length, Converter={StaticResource ValidationConverter}}" Value="True" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="IsEnabled" Value="True" />
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding ElementName=Tabs, Path=SelectedIndex}" Value="1" />
                                        <Condition Binding="{Binding ElementName=JsonTextBox, Path=Text.Length, Converter={StaticResource ValidationConverter}}" Value="True" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="IsEnabled" Value="True" />
                                </MultiDataTrigger>
                            </Style.Triggers>
                            <Setter Property="IsEnabled" Value="False" />
                        </Style>
                    </Button.Style>
                </Button>
                <Button MinWidth="100" Margin="12,0,0,0" Content="{x:Static resources:Strings.Common_Cancel}" IsCancel="True" />
            </StackPanel>
        </Border>
    </Grid>
</base:WpfUiWindow>
