<UserControl x:Class="NSwagStudio.Views.SwaggerGenerators.AspNetCoreToSwaggerGeneratorView"
             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:swaggerGenerators="clr-namespace:NSwagStudio.ViewModels.SwaggerGenerators"
             xmlns:converters="clr-namespace:NSwagStudio.Converters"
             xmlns:dialogs="clr-namespace:MyToolkit.Dialogs;assembly=MyToolkit.Extended"
             xmlns:converters1="clr-namespace:MyToolkit.Converters;assembly=MyToolkit.Extended"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <swaggerGenerators:AspNetCoreToSwaggerGeneratorViewModel x:Key="ViewModel" />
        <converters:NumberAdditionConverter x:Key="NumberAdditionConverter" />
        <converters:StringArrayConverter x:Key="StringArrayConverter" />
        <converters1:NotConverter x:Key="NotConverter" />
        <converters1:VisibilityConverter x:Key="VisibilityConverter" />
    </UserControl.Resources>

    <ScrollViewer DataContext="{StaticResource ViewModel}" x:Name="ScrollViewer" 
                  VerticalScrollBarVisibility="Visible" 
                  HorizontalScrollBarVisibility="Hidden">
        <StackPanel Margin="8" Width="{Binding ElementName=ScrollViewer, Path=ActualWidth, Converter={StaticResource NumberAdditionConverter}, ConverterParameter=-32}">
            <TextBlock Text="Project file path" FontWeight="Bold" Margin="0,0,0,6" />
            <dialogs:FileOpenPicker ToolTip="Project" Margin="0,0,0,12" 
                            FilePath="{Binding Command.Project, Mode=TwoWay}"
                            DefaultExtension=".csproj"
                            Filter="C# Project (.csproj)|*.csproj"/>

            <TextBlock Text="MSBuildProjectExtensionsPath" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.MSBuildProjectExtensionsPath, Mode=TwoWay}" 
                     ToolTip="MSBuildProjectExtensionsPath" Height="52" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Margin="0,0,0,12" />

            <TextBlock Text="Configuration" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.Configuration, Mode=TwoWay}" 
                     ToolTip="Configuration" Margin="0,0,0,12" />

            <TextBlock Text="Runtime" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.Runtime, Mode=TwoWay}" 
                     ToolTip="Runtime" Margin="0,0,0,12" />

            <TextBlock Text="TargetFramework" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.TargetFramework, Mode=TwoWay}" 
                     ToolTip="TargetFramework" Margin="0,0,0,12" />

            <TextBlock Text="MSBuildOutputPath" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.MSBuildOutputPath, Mode=TwoWay}"
                     ToolTip="MSBuildOutputPath" Margin="0,0,0,12" />

            <CheckBox IsChecked="{Binding Command.NoBuild, Mode=TwoWay}" Margin="0,0,0,12" ToolTip="NoBuild">
                <TextBlock Text="NoBuild" TextWrapping="Wrap" />
            </CheckBox>

            <CheckBox IsChecked="{Binding Command.Verbose, Mode=TwoWay}" Margin="0,0,0,12" ToolTip="Verbose">
                <TextBlock Text="Verbose" TextWrapping="Wrap" />
            </CheckBox>

            <TextBlock Text="Working Directory (optional, i.e. directory of appsettings.json)" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.WorkingDirectory, Mode=TwoWay}"
                     ToolTip="WorkingDirectory"
                     Margin="0,0,0,12" />

            <TextBlock Text="The ASPNETCORE_ENVIRONMENT environment variable (empty = use default)" FontWeight="Bold" Margin="0,0,0,6" />
            <TextBox Text="{Binding Command.AspNetCoreEnvironment, Mode=TwoWay}"
                     ToolTip="WorkingDirectory"
                     Margin="0,0,0,12" />


            <StackPanel>
                <GroupBox Header="Swagger Information" Margin="0,0,0,8">
                    <StackPanel Margin="4,8,4,-8">
                        <TextBlock Text="Document Template" FontWeight="Bold" Margin="0,0,0,6" />
                        <dialogs:FileOpenPicker ToolTip="DocumentTemplate" Margin="0,0,0,12" 
                                                FilePath="{Binding Command.DocumentTemplate, Mode=TwoWay}"
                                                Filter="OpenAPI Specification JSON (.json)|*.json|Swagger Specification YAML (.yaml)|*.yaml"
                                                DefaultExtension=".json"/>

                        <TextBlock Text="Service host (optional, use '.' to remove the hostname)" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.ServiceHost, Mode=TwoWay}"
                                 ToolTip="ServiceHost"
                                 Margin="0,0,0,12" />

                        <TextBlock Text="Service schemes (optional, 'http', 'https', 'ws', 'wss', multiple on separate lines)" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.ServiceSchemes, Mode=TwoWay, Converter={StaticResource StringArrayConverter}}" 
                                 ToolTip="ServiceSchemes"
                                 Height="52" AcceptsReturn="True" 
                                 VerticalScrollBarVisibility="Visible" 
                                 Margin="0,0,0,12" />

                        <TextBlock Text="Service base path (optional)" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.ServiceBasePath, Mode=TwoWay}"
                                 ToolTip="ServiceBasePath"
                                 Margin="0,0,0,12" />
                    </StackPanel>
                </GroupBox>

                <GroupBox Header="Type Extensions" Margin="0,0,0,8">
                    <StackPanel Margin="4,8,4,-8">
                        <TextBlock Text="Use type names in the form 'assemblyName:fullTypeName' or 'fullTypeName'" 
                                   TextWrapping="Wrap" Margin="0,0,0,6" />

                        <TextBlock Text="Custom IDocumentProcessor implementations (multiple on separate lines)"  
                                   TextWrapping="Wrap" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.DocumentProcessorTypes, Mode=TwoWay, Converter={StaticResource StringArrayConverter}}" 
                                 ToolTip="DocumentProcessors" Height="52" AcceptsReturn="True" 
                                 VerticalScrollBarVisibility="Visible" Margin="0,0,0,12" />

                        <TextBlock Text="Custom IOperationProcessor implementations (multiple on separate lines)"  
                                   TextWrapping="Wrap" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.OperationProcessorTypes, Mode=TwoWay, Converter={StaticResource StringArrayConverter}}" 
                                 ToolTip="OperationProcessors" Height="52" AcceptsReturn="True" 
                                 VerticalScrollBarVisibility="Visible" Margin="0,0,0,12" />

                        <TextBlock Text="Custom ITypeNameGenerator implementation" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.TypeNameGeneratorType, Mode=TwoWay}" 
                                 ToolTip="TypeNameGeneratorType" Margin="0,0,0,12" />

                        <TextBlock Text="Custom ISchemaNameGenerator implementation" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.SchemaNameGeneratorType, Mode=TwoWay}" 
                                 ToolTip="SchemaNameGeneratorType" Margin="0,0,0,12" />

                        <TextBlock Text="Custom JsonSerializerSettings implementation (deprecated, automatically resolved via DI)" FontWeight="Bold" Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.SerializerSettingsType, Mode=TwoWay}" 
                                ToolTip="SerializerSettingsType" Margin="0,0,0,12" />
                    </StackPanel>
                </GroupBox>
            </StackPanel>

            <TextBlock Text="Output file path (empty: no file output)" FontWeight="Bold" Margin="0,0,0,6" />
            <dialogs:FileSavePicker ToolTip="OutputFilePath" 
                                    Filter="OpenAPI/Swagger Specification JSON (.json)|*.json|OpenAPI/Swagger Specification YAML (.yaml)|*.yaml"
                                    DefaultExtension=".cs" 
                                    Margin="0,0,0,12"
                                    FilePath="{Binding Command.OutputFilePath, Mode=TwoWay}" />

            <TextBlock Margin="0,0,0,6" Text="New Line Behavior" TextWrapping="Wrap" FontWeight="Bold" />
            <ComboBox SelectedItem="{Binding Command.NewLineBehavior, Mode=TwoWay}" ItemsSource="{Binding NewLineBehaviors}" Margin="0,0,0,12" />
        </StackPanel>
    </ScrollViewer>
</UserControl>
