<UserControl x:Class="_1RM.View.Editor.Forms.LocalAppFormView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:argument="clr-namespace:_1RM.View.Editor.Forms.Argument"
             xmlns:controls="clr-namespace:_1RM.Controls"
             xmlns:system="clr-namespace:System;assembly=System.Runtime"
             xmlns:forms="clr-namespace:_1RM.View.Editor.Forms"
             xmlns:s="https://github.com/canton7/Stylet"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance forms:LocalAppFormViewModel}"
             d:DesignHeight="1450" d:DesignWidth="800">
    <UserControl.Resources>
        <GridLength x:Key="RowHeight1">30</GridLength>
        <GridLength x:Key="RowHeight2">20</GridLength>
        <system:Double x:Key="InputHeight">30</system:Double>
        <system:Double x:Key="WidthName">100</system:Double>
        <system:Double x:Key="WidthKey">100</system:Double>
        <system:Double x:Key="WidthValue">300</system:Double>
    </UserControl.Resources>
    <StackPanel>

        <StackPanel>
            <TextBlock Style="{StaticResource EditorGroupTextBlockTitle}" Text="{DynamicResource 'Exe path'}"></TextBlock>
            <Grid Style="{StaticResource EditorRowGrid}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource 'Exe path'}"></TextBlock>
                    <Grid Style="{StaticResource EditorRowGridInput}">
                        <TextBox Tag="e.g. C:/vnc/viewer.exe or %VNC%/viewer.exe"
                                 LostFocus="TextBoxExePath_OnLostFocus"
                                 Text="{Binding ExePath, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 ></TextBox>
                    </Grid>
                    <Button Style="{StaticResource ButtonPrimaryStyle}" 
                            Margin="5 0 0 0"
                            Content="{DynamicResource Select}" 
                            Command="{Binding CmdSelectExePath}"></Button>
                </StackPanel>
            </Grid>

            <Grid Style="{StaticResource EditorRowGrid}" ToolTip="{DynamicResource 'Hosting this exe in 1 tab view?'}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource 'Hosting'}"></TextBlock>
                    <CheckBox IsChecked="{Binding New.RunWithHosting}">
                        <TextBlock Style="{StaticResource TextBlockBase}" Foreground="Red" Text="{DynamicResource 'Caution: some exe can not be hosted in 1Remote.'}" TextWrapping="Wrap"></TextBlock>
                    </CheckBox>
                </StackPanel>
            </Grid>
        </StackPanel>

        <Grid Style="{StaticResource EditorRowGrid}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource Protocol}"></TextBlock>
                <Grid Style="{StaticResource EditorRowGridInput}">
                    <TextBox Tag="{DynamicResource Optional}"
                             Text="{Binding New.AppProtocolDisplayName, UpdateSourceTrigger=PropertyChanged}"></TextBox>
                </Grid>
            </StackPanel>
        </Grid>


        <StackPanel>

            <TextBlock Style="{StaticResource EditorGroupTextBlockTitle}" Text="{DynamicResource 'Connection Info'}"></TextBlock>

            <StackPanel Orientation="Horizontal" MinHeight="{StaticResource InputHeight}"  Margin="0 0 0 15"
                        Visibility="{Binding RequiredHostName, Converter={StaticResource ConverterBool2Visible}}">
                <Grid>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource Hostname}"></TextBlock>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" 
                               VerticalAlignment="Top"
                               Opacity="0.5" FontSize="{DynamicResource GlobalFontSizeSmall}" Margin="0 25 30 0"
                               Text="%1RM_HOSTNAME%"></TextBlock>
                </Grid>
                <Grid Style="{StaticResource EditorRowGridInput}">
                    <TextBox Text="{Binding Address, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                             Tag="{Binding HintHostName}"
                             Height="{StaticResource InputHeight}" 
                    ></TextBox>
                </Grid>
            </StackPanel>


            <StackPanel Orientation="Horizontal" MinHeight="{StaticResource InputHeight}"  Margin="0 0 0 15"
                        Visibility="{Binding RequiredPort, Converter={StaticResource ConverterBool2Visible}}">
                <Grid>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource Port}"></TextBlock>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" 
                               VerticalAlignment="Top"
                               Opacity="0.5" FontSize="{DynamicResource GlobalFontSizeSmall}" Margin="0 25 30 0" 
                               Text="%1RM_PORT%"></TextBlock>
                </Grid>
                <Grid Style="{StaticResource EditorRowGridInput}">
                    <TextBox Text="{Binding Port, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                             Tag="{Binding HintPort}"
                             Height="{StaticResource InputHeight}" 
                    ></TextBox>
                </Grid>
            </StackPanel>


            <StackPanel Orientation="Horizontal" MinHeight="{StaticResource InputHeight}"  Margin="0 0 0 15"
                        Visibility="{Binding RequiredUserName, Converter={StaticResource ConverterBool2Visible}}">
                <Grid>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource User}"></TextBlock>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" 
                               VerticalAlignment="Top"
                               Opacity="0.5" FontSize="{DynamicResource GlobalFontSizeSmall}" Margin="0 25 30 0" 
                               Text="%1RM_USERNAME%"></TextBlock>
                </Grid>
                <Grid Style="{StaticResource EditorRowGridInput}">
                    <TextBox Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                             Tag="{Binding HintUserName}"
                             Height="{StaticResource InputHeight}" 
                    ></TextBox>
                </Grid>
            </StackPanel>


            <StackPanel Orientation="Horizontal" MinHeight="{StaticResource InputHeight}" Margin="0 0 0 15" 
                        Visibility="{Binding RequiredPassword, Converter={StaticResource ConverterBool2Visible}}">
                <Grid>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource Password}"></TextBlock>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" 
                               VerticalAlignment="Top"
                               Opacity="0.5" FontSize="{DynamicResource GlobalFontSizeSmall}" Margin="0 25 30 0" 
                               Text="%1RM_PASSWORD%"></TextBlock>
                </Grid>
                <Grid Style="{StaticResource EditorRowGridInput}">
                    <controls:PasswordInput Height="{StaticResource InputHeight}" 
                                            Tag="{Binding HintPassword}"
                                            Password="{Binding Password, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                            />
                </Grid>
            </StackPanel>




            <StackPanel Orientation="Horizontal" MinHeight="{StaticResource InputHeight}" Margin="0 0 0 15" 
                        Visibility="{Binding RequiredPrivateKey, Converter={StaticResource ConverterBool2Visible}}">
                <Grid>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" Text="{DynamicResource 'Private key'}"></TextBlock>
                    <TextBlock Style="{StaticResource EditorRowGridTitle}" 
                               VerticalAlignment="Top"
                               Opacity="0.5" FontSize="{DynamicResource GlobalFontSizeSmall}" Margin="0 25 30 0" 
                               Text="%1RM_PRIVATE_KEY_PATH%"></TextBlock>
                </Grid>
                <Grid Style="{StaticResource EditorRowGridInput}" Height="{StaticResource InputHeight}">
                    <TextBox Name="TbPrivateKey" Text="{Binding PrivateKey}" 
                             Tag="{Binding HintPrivateKey}"></TextBox>
                </Grid>
                <Button Style="{StaticResource ButtonPrimaryStyle}" 
                        Margin="5"
                        Content="{DynamicResource Select}" 
                        Click="ButtonOpenPrivateKey_OnClick" 
                        HorizontalAlignment="Right"
                        VerticalAlignment="Stretch">
                </Button>
            </StackPanel>

            <ContentControl s:View.Model="{Binding AlternativeCredentialListViewModel}">
                <ContentControl.Style>
                    <Style TargetType="ContentControl">
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding Address}" Value=""></Condition>
                                    <Condition Binding="{Binding UserName}" Value=""></Condition>
                                    <Condition Binding="{Binding Port}" Value=""></Condition>
                                    <Condition Binding="{Binding Password}" Value=""></Condition>
                                </MultiDataTrigger.Conditions>
                                <MultiDataTrigger.Setters>
                                    <Setter Property="Visibility" Value="Collapsed"></Setter>
                                </MultiDataTrigger.Setters>
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </ContentControl.Style>
            </ContentControl>
        </StackPanel>

        <argument:ArgumentListControl></argument:ArgumentListControl>

    </StackPanel>
</UserControl>