<StackPanel x:Class="GameRes.Formats.GUI.WidgetINT"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:s="clr-namespace:GameRes.Formats.Strings"
      xmlns:fmt="clr-namespace:GameRes.Formats.CatSystem"
      xmlns:local="clr-namespace:GameRes.Formats.GUI"
      MaxWidth="280" Orientation="Vertical">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock Name="ExeMessage" Grid.Column="0" Text="{x:Static s:arcStrings.INTMessage1}" TextWrapping="Wrap" Margin="0,0,10,10"/>
        <Button Content="{x:Static s:arcStrings.INTExeButton}" Grid.Column="1" Grid.Row="0" Width="75" Height="25"
                HorizontalAlignment="Left" Margin="0,0,0,10" Click="Check_Click"/>
    </Grid>
    <TextBlock Grid.Column="0" Text="{x:Static s:arcStrings.INTMessage2}" Margin="0,0,0,10" TextWrapping="Wrap"/>
    <Grid>
    <Grid.Resources>
        <local:KeyConverter x:Key="keyConverter"/>
        <Style TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip"
                            Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Grid.Resources>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition MinWidth="130" Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
    </Grid.RowDefinitions>
    <Label Content="{x:Static s:arcStrings.INTLabelNumericKey}" Target="{Binding ElementName=Passkey}"
           Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right"/>
    <TextBox Name="Passkey" Grid.Column="1" Grid.Row="2" Margin="0,3,0,3">
        <TextBox.Text>
            <Binding Path="Key" Converter="{StaticResource keyConverter}" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <local:PasskeyRule/>
                </Binding.ValidationRules>                            
            </Binding>
        </TextBox.Text>
        <Validation.ErrorTemplate>
            <ControlTemplate>
                <DockPanel>
                    <TextBlock DockPanel.Dock="Right" Foreground="Red" FontWeight="Bold" Text="!" VerticalAlignment="Center"/>
                    <Border BorderBrush="Red" BorderThickness="1">
                        <AdornedElementPlaceholder Name="ValidationAdorner" />
                    </Border>
                </DockPanel>
            </ControlTemplate>
        </Validation.ErrorTemplate>
    </TextBox>
    <Label Content="{x:Static s:arcStrings.LabelPassphrase}" Target="{Binding ElementName=Passphrase}"
           Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right"/>
    <TextBox Name="Passphrase" Grid.Column="1" Grid.Row="1" Margin="0,3,0,3"
             Text="{Binding Path=Password}"/>
    <Label Content="{x:Static s:arcStrings.LabelScheme}" Target="{Binding ElementName=EncScheme}"
           Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right"/>
    <ComboBox Name="EncScheme" Grid.Column="1" Grid.Row="0" Margin="0,3,0,0"
              ItemsSource="{Binding Source={x:Static fmt:IntOpener.KnownSchemes}, Path=Keys, Mode=OneWay}"
              Width="{Binding ElementName=Passkey, Path=ActualWidth}"
              SelectedValue="{Binding Path=Scheme}"/>
</Grid>
</StackPanel>