<UserControl x:Class="NSwagStudio.Views.SwaggerGenerators.SwaggerInputView"
             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:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:swaggerGenerators1="clr-namespace:NSwagStudio.ViewModels.SwaggerGenerators"
             xmlns:controls="clr-namespace:NSwagStudio.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.Resources>
        <swaggerGenerators1:SwaggerInputViewModel x:Key="ViewModel" />
    </UserControl.Resources>

    <Grid Margin="8" DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel>
            <TextBlock Text="Specification URL:" FontWeight="Bold" Margin="0,0,0,4"  />
            <Grid Margin="0,0,0,8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBox VerticalContentAlignment="Center" Text="{Binding Command.Url, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <Button Content="Create local Copy" 
                        Command="{Binding LoadSwaggerUrlCommand}" 
                        CommandParameter="{Binding Command.Url}"
                        Margin="4,0,0,0" Padding="8,4,8,4" Grid.Column="1" />
            </Grid>

            <TextBlock Text="Specification JSON/YAML (if specified, the URL is ignored): " FontWeight="Bold" Margin="0,0,0,8"  />
        </StackPanel>
        
        <Border Grid.Row="1" Margin="-8,0,-8,-8" BorderThickness="0,1,0,0" BorderBrush="LightGray">
            <avalonedit:TextEditor Padding="8" FontFamily="Consolas" Background="GhostWhite" ShowLineNumbers="True"
                                   SyntaxHighlighting="JavaScript" FontSize="10pt">
                <i:Interaction.Behaviors>
                    <controls:AvalonEditBehavior Text="{Binding Command.Json, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                </i:Interaction.Behaviors>
            </avalonedit:TextEditor>
        </Border>
    </Grid>
</UserControl>
