<codeGenerators:CodeGeneratorViewBase x:Class="NSwagStudio.Views.CodeGenerators.SwaggerToCSharpClientGeneratorView"
                                      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:SwaggerToCSharpClientGeneratorViewModel 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 Client 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}" 
                             ToolTip="Namespace"
                             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=','}" 
                             ToolTip="AdditionalNamespaceUsages" 
                             Margin="0,0,0,12" />

                    <CheckBox IsChecked="{Binding Command.GenerateContractsOutput, Mode=TwoWay}" 
                              ToolTip="GenerateContractsOutput"
                              Content="Generate contracts output" 
                              Margin="0,0,0,12" />

                    <CheckBox IsChecked="{Binding Command.GenerateNativeRecords, Mode=TwoWay}"
                              ToolTip="GenerateNativeRecords"
                              Content="Generate record types"
                              Margin="0,0,0,12" />

                    <StackPanel Visibility="{Binding Command.GenerateContractsOutput, Converter={StaticResource VisibilityConverter}}">
                        <TextBlock Text="Contracts Namespace"
                                   FontWeight="Bold" 
                                   Margin="0,0,0,6" />
                        <TextBox Text="{Binding Command.ContractsNamespace, Mode=TwoWay}"
                                 ToolTip="ContractsNamespace"
                                 Margin="0,0,0,12" />

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

                    <CheckBox IsChecked="{Binding Command.GenerateExceptionClasses, Mode=TwoWay}" 
                              Content="Generate exception classes (when disabled, exception classes must be imported)" 
                              ToolTip="GenerateExceptionClasses"
                              Margin="0,0,0,12" />

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

                    <GroupBox Header="Client" Margin="0,0,0,12">
                        <StackPanel Margin="4,8,4,-8">
                            <CheckBox IsChecked="{Binding Command.GenerateClientClasses, Mode=TwoWay}" 
                                      ToolTip="GenerateClientClasses"
                                      Content="Generate Client Classes" Margin="0,0,0,12" />

                            <CheckBox IsChecked="{Binding Command.SuppressClientClassesOutput, Mode=TwoWay}" 
                                      ToolTip="SuppressClientClassesOutput"
                                      Content="Suppress output of generated Client Classes" Margin="0,0,0,12" />

                            <StackPanel Visibility="{Binding Command.GenerateClientClasses, Converter={StaticResource VisibilityConverter}}">
                                <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}" 
                                          ToolTip="OperationGenerationMode"
                                          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" />

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

                                <TextBlock Text="Client class access modifier" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox Text="{Binding Command.ClientClassAccessModifier, Mode=TwoWay}" 
                                         ToolTip="ClientClassAccessModifier" Margin="0,0,0,12" />

                                <TextBlock Text="Methods with a protected access modifier to use in partial methods ('classname.methodname', comma separated)" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox Text="{Binding Command.ProtectedMethods, Mode=TwoWay, Converter={StaticResource StringArrayConverter}, ConverterParameter=','}" 
                                         ToolTip="ProtectedMethods" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.UseBaseUrl, Mode=TwoWay}" 
                                          Content="Use the base URL for the request" 
                                          ToolTip="UseBaseUrl" Margin="0,0,0,12" />
                                
                                <CheckBox IsChecked="{Binding Command.GenerateBaseUrlProperty, Mode=TwoWay}" 
                                          Visibility="{Binding Command.UseBaseUrl, Converter={StaticResource VisibilityConverter}}"
                                          Content="Generate the BaseUrl property (must be defined on the base class otherwise)" 
                                          ToolTip="GenerateBaseUrlProperty" 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" />

                                <CheckBox IsChecked="{Binding Command.GenerateSyncMethods, Mode=TwoWay}" 
                                          Content="Generate synchronous methods (not recommended)" 
                                          ToolTip="GenerateSyncMethods" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.GeneratePrepareRequestAndProcessResponseAsAsyncMethods, Mode=TwoWay}" 
                                          Content="Generate PrepareRequest and ProcessResponse as asynchronous methods (if selected, methods must be defined in the base class or in the partial class)" 
                                          ToolTip="GeneratePrepareRequestAndProcessResponseAsAsyncMethods" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.ExposeJsonSerializerSettings, Mode=TwoWay}" 
                                          Content="Expose the JsonSerializerSettings property" 
                                          ToolTip="ExposeJsonSerializerSettings" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.InjectHttpClient, Mode=TwoWay}" 
                                          ToolTip="InjectHttpClient"
                                          Content="Inject HttpClient via constructor (life cycle is managed by the caller)" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.DisposeHttpClient, Mode=TwoWay}" 
                                          ToolTip="DisposeHttpClient"
                                          Visibility="{Binding Command.InjectHttpClient, Converter={StaticResource NotConverter}}"
                                          Content="Dispose the HttpClient (life cycle must be handled by the base class and CreateHttpClientAsync())" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.GenerateClientInterfaces, Mode=TwoWay}" 
                                          ToolTip="GenerateClientInterfaces"
                                          Content="Generate interfaces for Client classes" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.SuppressClientInterfacesOutput, Mode=TwoWay}" 
                                          ToolTip="SuppressClientInterfacesOutput"
                                          Content="Suppress output of generated interfaces for Client classes" Margin="0,0,0,12" />

                                <TextBlock Text="Base interface for Client Interfaces (optional)" FontWeight="Bold" Margin="0,0,0,6"
                                           Visibility="{Binding Command.GenerateClientInterfaces, Converter={StaticResource VisibilityConverter}}" />
                                <TextBox Text="{Binding Command.ClientBaseInterface, Mode=TwoWay}"
                                         Visibility="{Binding Command.GenerateClientInterfaces, Converter={StaticResource VisibilityConverter}}"
                                         ToolTip="ClientBaseInterface" Margin="0,0,0,12" />

                                <CheckBox IsChecked="{Binding Command.SerializeTypeInformation, Mode=TwoWay}" 
                                          ToolTip="SerializeTypeInformation"
                                          Content="Serialize the type information in a $type property (not recommended, also sets TypeNameHandling = Auto)" Margin="0,0,0,12" />

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

                                <TextBlock Text="DateTime format for method parameters" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox Text="{Binding Command.ParameterDateTimeFormat, Mode=TwoWay}" ToolTip="ParameterDateTimeFormat" Margin="0,0,0,12" />

                                <TextBlock Text="Date format for method parameters" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox Text="{Binding Command.ParameterDateFormat, Mode=TwoWay}" ToolTip="ParameterDateFormat" Margin="0,0,0,12" />

                                <TextBlock Text="Null value used for query parameters which are null" FontWeight="Bold" Margin="0,0,0,6" />
                                <TextBox Text="{Binding Command.QueryNullValue, Mode=TwoWay}" 
                                         ToolTip="QueryNullValue" Margin="0,0,0,12" />

                                <GroupBox Header="Base Class and Configuration Class" Margin="0,0,0,12">
                                    <StackPanel Margin="4,8,4,-8">
                                        <TextBlock Text="Base Class Name (optional)" FontWeight="Bold" Margin="0,0,0,6" />
                                        <TextBox Text="{Binding Command.ClientBaseClass, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                                 ToolTip="ClientBaseClass" Margin="0,0,0,12" />

                                        <StackPanel Visibility="{Binding Command.ClientBaseClass, Converter={StaticResource VisibilityConverter}}">
                                            <CheckBox IsChecked="{Binding Command.UseHttpClientCreationMethod, Mode=TwoWay}" Margin="0,0,0,12" 
                                                        Visibility="{Binding Command.InjectHttpClient, Converter={StaticResource NotConverter}}"
                                                        ToolTip="UseHttpClientCreationMethod">
                                                <TextBlock Text="Call the CreateHttpClientAsync method on the client base class to create a new HttpClient instance" TextWrapping="Wrap" />
                                            </CheckBox>

                                            <CheckBox IsChecked="{Binding Command.UseHttpRequestMessageCreationMethod, Mode=TwoWay}"
                                                        ToolTip="UseHttpRequestMessageCreationMethod" Margin="0,0,0,12">
                                                <TextBlock Text="Call the CreateHttpRequestMessageAsync method on the client base class to create a new HttpRequestMessage instance" TextWrapping="Wrap" />
                                            </CheckBox>

                                            <CheckBox IsChecked="{Binding Command.GenerateUpdateJsonSerializerSettingsMethod, Mode=TwoWay}" 
                                                        Content="Generate the UpdateJsonSerializerSettings method (must be implemented in the base class otherwise)." 
                                                        ToolTip="GenerateUpdateJsonSerializerSettingsMethod"
                                                        Margin="0,0,0,12" />

                                            <TextBlock Text="Configuration Class Name (passed to base class ctor, optional)" FontWeight="Bold" Margin="0,0,0,6" />
                                            <TextBox Text="{Binding Command.ConfigurationClass, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                        ToolTip="ConfigurationClass" Margin="0,0,0,12" />
                                        </StackPanel>
                                    </StackPanel>
                                </GroupBox>

                                <GroupBox Header="Response Wrapping" Margin="0,0,0,12">
                                    <StackPanel Margin="4,8,4,-8">
                                        <CheckBox IsChecked="{Binding Command.WrapDtoExceptions, Mode=TwoWay}" 
                                              ToolTip="WrapDtoExceptions"
                                              Content="Wrap DTO exceptions in a SwaggerException instance" 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" />

                                        <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}" 
                                                  ToolTip="GenerateResponseClasses"
                                                  Content="Generate response classes (when disabled, response classes must be imported)" Margin="0,0,0,12" />

                                            <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}" ToolTip="ResponseClass" Margin="0,0,0,12" />
                                            </StackPanel>
                                        </StackPanel>
                                    </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>
                        </StackPanel>
                    </GroupBox>

                    <views:CSharpSettingsView />

                    <GroupBox Header="Swagger Information" Margin="0,0,0,12">
                        <StackPanel Margin="4,8,4,-8">
                            <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" />
                        </StackPanel>
                    </GroupBox>

                    <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}" 
                                            ToolTip="Output"
                                            Margin="0,0,0,12" />

                            <StackPanel Visibility="{Binding Command.GenerateContractsOutput, Converter={StaticResource VisibilityConverter}}">
                                <TextBlock Text="Contracts output file path (empty: single output file output)" FontWeight="Bold" Margin="0,0,0,6" />
                                <dialogs:FileSavePicker DefaultExtension=".cs" Filter="CSharp Files (.cs)|*.cs"
                                                FilePath="{Binding Command.ContractsOutputFilePath, Mode=TwoWay}" 
                                                ToolTip="ContractsOutput"
                                                Margin="0,0,0,12" />
                            </StackPanel>

                            <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>