<codeGenerators:CodeGeneratorViewBase x:Class="NSwagStudio.Views.CodeGenerators.SwaggerToCSharpControllerGeneratorView"
                                      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:converters="clr-namespace:MyToolkit.Converters;assembly=MyToolkit.Extended"
                                      xmlns:localConverters="clr-namespace:NSwagStudio.Converters"
                                      xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
                                      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                                      xmlns:viewModels="clr-namespace:NSwagStudio.ViewModels.CodeGenerators"
                                      xmlns:controls="clr-namespace:NSwagStudio.Controls"
                                      xmlns:dialogs="clr-namespace:MyToolkit.Dialogs;assembly=MyToolkit.Extended"
                                      xmlns:codeGenerators="clr-namespace:NSwagStudio.Views.CodeGenerators"
                                      xmlns:views="clr-namespace:NSwagStudio.Views.CodeGenerators.Views"
                                      mc:Ignorable="d" 
                                      d:DesignHeight="800" d:DesignWidth="800">

    <UserControl.Resources>
        <viewModels:SwaggerToCSharpControllerGeneratorViewModel x:Key="ViewModel" />
        <converters:VisibilityConverter x:Key="VisibilityConverter" />
        <converters:NotConverter x:Key="NotConverter" />
        <localConverters:NumberAdditionConverter x:Key="NumberAdditionConverter" />
        <localConverters:StringArrayConverter x:Key="StringArrayConverter" />
    </UserControl.Resources>

    <TabControl TabStripPlacement="Left" Margin="8" Name="TabControl" DataContext="{StaticResource ViewModel}">
        <TabItem Header="Settings" HeaderTemplate="{StaticResource RotatedTabItem}">
            <ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Visible" 
                          HorizontalScrollBarVisibility="Hidden"
                          IsEnabled="{Binding IsLoading, Converter={StaticResource NotConverter}}">
                <StackPanel Margin="8,8,8,0" Width="{Binding ElementName=ScrollViewer, Path=ActualWidth, Converter={StaticResource NumberAdditionConverter}, ConverterParameter=-32}">
                    <TextBlock Text="CSharp Controller Settings" FontSize="15" FontWeight="Bold" Margin="0,0,0,12" />

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

                    <TextBlock Text="Additional Namespace Usages (comma separated)" FontWeight="Bold" Margin="0,0,0,6" />
                    <TextBox Text="{Binding Command.AdditionalNamespaceUsages, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                             Margin="0,0,0,12" />

                    <GroupBox Header="Controller" Margin="0,0,0,12">
                        <StackPanel Margin="4,8,4,-8">
                            <TextBlock Text="Controller Style" FontWeight="Bold" Margin="0,0,0,6" />
                            <ComboBox SelectedItem="{Binding Command.ControllerStyle, Mode=TwoWay}" 
                                      ToolTip="ControllerStyle"
                                      ItemsSource="{Binding ControllerStyles}" Margin="0,0,0,12" />

                            <TextBlock Text="Controller Target" FontWeight="Bold" Margin="0,0,0,6" />
                            <ComboBox SelectedItem="{Binding Command.ControllerTarget, Mode=TwoWay}" 
                                      ToolTip="ControllerTarget"
                                      ItemsSource="{Binding ControllerTargets}" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.UseActionResultType, Mode=TwoWay}" 
                                      ToolTip="UseActionResultType"
                                      Content="Use ASP.Net Core (2.1) ActionResult type as return type" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.UseCancellationToken, Mode=TwoWay}" 
                                      ToolTip="UseCancellationToken"
                                      Content="Add cancellation token to controller methods" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.GenerateModelValidationAttributes, Mode=TwoWay}" 
                                      ToolTip="GenerateModelValidationAttributes"
                                      Content="Add model validation attributes" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.WrapResponses, Mode=TwoWay}" 
                                      ToolTip="WrapResponses"
                                      Content="Wrap success responses to allow full response access" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.GenerateOptionalParameters, Mode=TwoWay}" 
                                      ToolTip="GenerateOptionalParameters"
                                      Content="Generate optional parameters (reorder parameters (required first, optional at the end) and generate optional parameters)" Margin="0,0,0,12" />

                            <TextBlock Text="Excluded Parameter Names (comma separated)." FontWeight="Bold" Margin="0,0,0,12" />
                            <TextBox ToolTip="ExcludedParameterNames" 
                                     Text="{Binding Command.ExcludedParameterNames, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                                     Margin="0,0,0,12" />

                            <TextBlock Text="Route Naming Strategy" FontWeight="Bold" Margin="0,0,0,6" />
                            <ComboBox SelectedItem="{Binding Command.RouteNamingStrategy, Mode=TwoWay}" 
                                      ToolTip="RouteNamingStrategy"
                                      ItemsSource="{Binding RouteNamingStrategies}" Margin="0,0,0,12" />

                            <StackPanel Visibility="{Binding Command.WrapResponses, Converter={StaticResource VisibilityConverter}}">
                                <TextBlock Text="Methods where responses are wrapped (empty for all, 'ControllerName.MethodName', comma separated)" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox ToolTip="WrapResponseMethods" 
                                         Text="{Binding Command.WrapResponseMethods, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                                         Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.GenerateResponseClasses, Mode=TwoWay}" 
                                  Content="Generate response classes (when disabled, response classes must be imported)" Margin="0,0,0,6" />

                                <StackPanel Visibility="{Binding Command.GenerateResponseClasses, Converter={StaticResource VisibilityConverter}}">
                                    <TextBlock Text="Response class name (may contain the '{controller}' placeholder)" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ResponseClass, Mode=TwoWay}" Margin="0,0,0,12" />
                                </StackPanel>
                            </StackPanel>

                            <GroupBox Header="Web API Controller" Margin="0,0,0,12">
                                <StackPanel Margin="4,8,4,-8">
                                    <TextBlock Text="BasePath override (RoutePrefix)" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.BasePath, Mode=TwoWay}" Margin="0,0,0,12" />
                                    
                                    <TextBlock Text="Controller Class Name" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ClassName, Mode=TwoWay}" Margin="0,0,0,12" />

                                    <TextBlock Text="Controller Base Class Name (optional, use 'Microsoft.AspNetCore.Mvc.Controller' for ASP.NET Core)" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ControllerBaseClass, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,12" />

                                    <TextBlock Margin="0,0,0,6" TextWrapping="Wrap">
                                    <Run Text="Operation Generation Mode" FontWeight="Bold" />
                                    <LineBreak />
                                        The {controller} placeholder of the Class Name is replaced by generated client name (depends on the OperationGenerationMode strategy).
                                    </TextBlock>
                                    <ComboBox SelectedItem="{Binding Command.OperationGenerationMode, Mode=TwoWay}" 
                                              ItemsSource="{Binding OperationGenerationModes}" Margin="0,0,0,12" />
                                    
                                    <TextBlock Text="Included Operation IDs (comma separated)." FontWeight="Bold" Margin="0,0,0,12" />
                                    <TextBox ToolTip="IncludedOperationIds" 
                                            Text="{Binding Command.IncludedOperationIds, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                                            Margin="0,0,0,12" />
                                    
                                    <TextBlock Text="Excluded Operation IDs (comma separated)." FontWeight="Bold" Margin="0,0,0,12" />
                                    <TextBox ToolTip="ExcludedOperationIds" 
                                            Text="{Binding Command.ExcludedOperationIds, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                                            Margin="0,0,0,12" />
                                </StackPanel>
                            </GroupBox>

                            <GroupBox Header="Parameter Types" Margin="0,0,0,12">
                                <StackPanel Margin="4,8,4,-8">
                                    <TextBlock Text="Generic Array Type" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ParameterArrayType, Mode=TwoWay}" ToolTip="ParameterArrayType" Margin="0,0,0,12" />

                                    <TextBlock Text="Generic Dictionary Type" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ParameterDictionaryType, Mode=TwoWay}" ToolTip="ParameterDictionaryType" Margin="0,0,0,12" />
                                </StackPanel>
                            </GroupBox>

                            <GroupBox Header="Response Types" Margin="0,0,0,12">
                                <StackPanel Margin="4,8,4,-8">
                                    <TextBlock Text="Generic Array Type" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ResponseArrayType, Mode=TwoWay}" ToolTip="ResponseArrayType" Margin="0,0,0,12" />

                                    <TextBlock Text="Generic Dictionary Type" FontWeight="Bold" Margin="0,0,0,6" />
                                    <TextBox Text="{Binding Command.ResponseDictionaryType, Mode=TwoWay}" ToolTip="ResponseDictionaryType" Margin="0,0,0,12" />
                                </StackPanel>
                            </GroupBox>
                        </StackPanel>
                    </GroupBox>

                    <views:CSharpSettingsView />

                    <GroupBox Header="Templating" Margin="0,0,0,12">
                        <StackPanel Margin="4,8,4,-8">
                            <TextBlock Text="Template directory" FontWeight="Bold" Margin="0,0,0,6" />
                            <TextBox Text="{Binding Command.TemplateDirectory, Mode=TwoWay}"
                                     ToolTip="TemplateDirectory"
                                     Margin="0,0,0,12" />
                        </StackPanel>
                    </GroupBox>

                    <GroupBox Header="Output" Margin="0,0,0,12">
                        <StackPanel Margin="4,8,4,-8">
                            <TextBlock Text="Output file path (empty: no file output)" FontWeight="Bold" Margin="0,0,0,6" />
                            <dialogs:FileSavePicker DefaultExtension=".cs" Filter="CSharp Files (.cs)|*.cs"
                                            FilePath="{Binding Command.OutputFilePath, Mode=TwoWay}" 
                                            Margin="0,0,0,12" />

                            <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>
                    </GroupBox>
                </StackPanel>
            </ScrollViewer>
        </TabItem>
        <TabItem Header="Output" HeaderTemplate="{StaticResource RotatedTabItem}">
            <Border Margin="-2">
                <avalonedit:TextEditor Background="GhostWhite" FontFamily="Consolas" IsReadOnly="True" ShowLineNumbers="True"
                                   SyntaxHighlighting="C#" FontSize="10pt" Padding="8">
                    <i:Interaction.Behaviors>
                        <controls:AvalonEditBehavior Text="{Binding ClientCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    </i:Interaction.Behaviors>
                </avalonedit:TextEditor>
            </Border>
        </TabItem>
    </TabControl>
</codeGenerators:CodeGeneratorViewBase>