<Window x:Class="NSwagStudio.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viewModels="clr-namespace:NSwagStudio.ViewModels"
        xmlns:views="clr-namespace:NSwagStudio.Views"
        xmlns:controls="clr-namespace:NSwagStudio.Controls"
        Title="NSwagStudio: The Swagger API toolchain for .NET and TypeScript"
        MinHeight="650" MinWidth="1000" UseLayoutRounding="True"
        WindowStartupLocation="CenterScreen"
        Height="650" Width="1000">

    <Window.Resources>
        <viewModels:MainWindowModel x:Key="ViewModel" />
    </Window.Resources>

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

        <Menu>
            <MenuItem Header="_File">
                <MenuItem Header="_New" Command="{Binding CreateDocumentCommand}" InputGestureText="Ctrl-N" />
                <MenuItem Header="_Open" Command="{Binding OpenDocumentCommand}" InputGestureText="Ctrl-O" />
                <MenuItem Header="_Close" InputGestureText="Ctrl-W"
                          Command="{Binding CloseDocumentCommand}"
                          CommandParameter="{Binding SelectedDocument}" />
                <MenuItem Header="Close A_ll" InputGestureText="Ctrl+Shift-W"
                          Command="{Binding CloseAllDocumentsCommand}"
                          CommandParameter="{Binding Documents}" />
                <MenuItem Header="_Save" InputGestureText="Ctrl-S"
                          Command="{Binding SaveDocumentCommand}"
                          CommandParameter="{Binding SelectedDocument}" />
                <MenuItem Header="Save _All" InputGestureText="Ctrl+Shift-S"
                          Command="{Binding SaveAllDocumentsCommand}"
                          CommandParameter="{Binding Documents}" />
                <MenuItem Header="Save _As" Command="{Binding SaveAsDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
            </MenuItem>
        </Menu>

        <TabControl Grid.Row="1" TabStripPlacement="Left" Margin="8,8,0,0">
            <!-- Documents -->
            <TabItem Header="Documents" HeaderTemplate="{StaticResource RotatedTabItem}">
                <TabControl ItemsSource="{Binding Documents}" controls:TabContent.IsCached="True"
                            SelectedItem="{Binding SelectedDocument, Mode=TwoWay}"
                            Margin="8">
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <Grid ToolTip="{Binding Document.Path}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <TextBlock Text="{Binding Document.Name}" VerticalAlignment="Center" Margin="0,2,0,0">
                                    <TextBlock.InputBindings>
                                        <MouseBinding
                                            CommandParameter="{Binding}"
                                            Command="{Binding CloseDocumentCommand, Source={StaticResource ViewModel}}"
                                            Gesture="MiddleClick" />
                                    </TextBlock.InputBindings>
                                </TextBlock>
                                <Button Grid.Column="1"
                                        Content="X" Padding="6,2,6,2" Margin="8,3,0,2"
                                        CommandParameter="{Binding}"
                                        Command="{Binding CloseDocumentCommand, Source={StaticResource ViewModel}}" />
                            </Grid>
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <controls:TabContent.Template>
                        <DataTemplate>
                            <views:DocumentView Document="{Binding}" Margin="8" />
                        </DataTemplate>
                    </controls:TabContent.Template>
                </TabControl>
            </TabItem>
            <!-- About -->
            <TabItem Header="About" HeaderTemplate="{StaticResource RotatedTabItem}">
                <StackPanel Margin="8">
                    <TextBlock Margin="0,0,0,8" FontSize="16" FontWeight="Bold">
                        <Hyperlink NavigateUri="http://nswag.org" Click="OnOpenHyperlink">NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Hyperlink>
                    </TextBlock>
                    <TextBlock Margin="0,0,0,8" FontSize="14" TextWrapping="Wrap">
                        NSwag is a Swagger 2.0 API toolchain for .NET, TypeScript and other platforms, written in C#.
                        The OpenAPI/Swagger specification uses JSON and JSON Schema to describe a RESTful web API. 
                        The project provides tools to automatically generate client code from these Swagger
                        specifications and integrate this generation into existing processes.
                    </TextBlock>
                    <TextBlock Margin="0,0,0,8" FontSize="14">
                        NSwag and NSwagStudio have been developed by
                        <Hyperlink NavigateUri="http://www.rsuter.com" Click="OnOpenHyperlink">Rico Suter</Hyperlink> and other contributors.
                    </TextBlock>
                    <TextBlock Margin="0,0,0,8">
                        NSwag Version: <Run Text="{Binding NSwagVersion, Mode=OneWay}" /> <LineBreak />
                        NJsonSchema Version: <Run Text="{Binding NJsonSchemaVersion, Mode=OneWay}" />
                    </TextBlock>
                    <TextBlock Margin="0,0,0,8">
                        License: <Hyperlink NavigateUri="https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md" Click="OnOpenHyperlink">MIT</Hyperlink>
                    </TextBlock>
                </StackPanel>
            </TabItem>
        </TabControl>
    </Grid>
</Window>

