<Window
    x:Class="Translumo.MVVM.Views.SettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:common="clr-namespace:Translumo.MVVM.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
    xmlns:system="clr-namespace:System;assembly=System.Runtime"
    xmlns:viewModels="clr-namespace:Translumo.MVVM.ViewModels"
    xmlns:views="clr-namespace:Translumo.MVVM.Views"
    xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
    Name="wSettings"
    Title="{DynamicResource Str.Title.SettingWindow}"
    Width="800"
    Height="550"
    Activated="wSettings_Activated"
    Background="Transparent"
    Deactivated="wSettings_Deactivated"
    FontFamily="{DynamicResource MaterialDesignFont}"
    MouseDown="wSettings_MouseDown"
    ResizeMode="NoResize"
    SourceInitialized="wSettings_SourceInitialized"
    TextElement.FontSize="13"
    TextElement.FontWeight="Regular"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    TextOptions.TextFormattingMode="Ideal"
    TextOptions.TextRenderingMode="Auto"
    mc:Ignorable="d">
    <Window.Resources>
        <DataTemplate DataType="{x:Type viewModels:AppearanceSettingsViewModel}">
            <views:AppearanceSettingsView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type viewModels:HotkeysSettingsViewModel}">
            <views:HotkeysSettingsView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type viewModels:LanguagesSettingsViewModel}">
            <views:LanguagesSettingsView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type viewModels:OcrSettingsViewModel}">
            <views:OcrSettingsView />
        </DataTemplate>
        <common:CaseConverter x:Key="CaseConverter" Case="Upper" />
        <common:BoolBrushConverter
            x:Key="HasUpdatesConverter"
            FalseBrush="{StaticResource PrimaryHueLightBrush}"
            TrueBrush="{StaticResource WarningBrush}" />
        <system:Boolean x:Key="ConfirmationClose">True</system:Boolean>
    </Window.Resources>

    <Border Background="{StaticResource SecondaryHueLightBrush}">
        <materialDesign:DialogHost CloseOnClickAway="{Binding DialogService.AllowCloseOnClickAway}" IsOpen="{Binding DialogService.IsOpen}">
            <materialDesign:DialogHost.DialogContent>
                <views:SimpleDialogView />
            </materialDesign:DialogHost.DialogContent>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0" Background="{StaticResource PrimaryHueDarkBrush}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="68" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="50" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <Image
                        Grid.Row="0"
                        Height="37"
                        Margin="10,0,0,0"
                        HorizontalAlignment="Left"
                        RenderOptions.BitmapScalingMode="HighQuality"
                        Source="../../Resources/Icons/logo_full.png" />
                    <DockPanel Grid.Row="1">
                        <materialDesign:ColorZone Mode="PrimaryDark">
                            <mde:SideNavigation
                                Name="SnMenu"
                                Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
                                IconForeground="{DynamicResource MaterialDesignDarkForeground}"
                                Items="{Binding Path=NavigationItems, Mode=OneTime}"
                                LabelForeground="#FFFAFAFA"
                                Loaded="SnMenu_Loaded"
                                NavigationItemFeedback="{DynamicResource SecondaryHueLightBrush}"
                                NavigationItemSelectedCommand="{Binding NavigationItemSelectedCommand}"
                                SelectionBackground="{DynamicResource MaterialDesignBackground}"
                                SelectionForeground="{DynamicResource MaterialDesignBackground}"
                                Style="{DynamicResource MaterialSideNavigationBlock}" />
                        </materialDesign:ColorZone>
                    </DockPanel>
                    <DockPanel Grid.Row="2" ZIndex="1000">
                        <ListView
                            Margin="8,0,0,0"
                            DockPanel.Dock="Left"
                            ItemContainerStyle="{StaticResource OutlinedListViewItem}"
                            ItemsSource="{Binding AvailableLanguages}"
                            SelectedValue="{Binding SystemConfiguration.ApplicationCulture}"
                            SelectedValuePath="Name">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding TwoLetterISOLanguageName, Converter={StaticResource CaseConverter}}" Style="{StaticResource LightLabel}" />
                                </DataTemplate>
                            </ListView.ItemTemplate>
                            <ListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ListView.ItemsPanel>
                        </ListView>
                        <Button
                            HorizontalAlignment="Right"
                            VerticalAlignment="Top"
                            Command="{Binding AboutDialogOpenedCommand}"
                            DockPanel.Dock="Right"
                            Style="{StaticResource SystemAdditionalButton}">
                            <wpf:PackIcon
                                Foreground="{Binding HasUpdates, Mode=OneWay, Converter={StaticResource HasUpdatesConverter}}"
                                Kind="Information"
                                Style="{StaticResource SystemAdditionalIcon}" />
                        </Button>
                    </DockPanel>
                    <Button
                        Grid.Row="3"
                        Height="105"
                        Padding="0"
                        Background="White"
                        BorderThickness="0,0,1,0"
                        Click="OnLookupperLinkClick"
                        Cursor="Hand">
                        <StackPanel>
                            <TextBlock
                                Margin="12,8,0,0"
                                FontSize="18"
                                Text="{DynamicResource Str.Lookupper.ProjectNote}" />
                            <Image
                                Height="60"
                                Margin="14,8,14,14"
                                HorizontalAlignment="Left"
                                RenderOptions.BitmapScalingMode="HighQuality"
                                Source="../../Resources/Icons/lookupper.png" />
                        </StackPanel>
                    </Button>
                </Grid>

                <ContentControl
                    Grid.Column="1"
                    Margin="25,25,10,10"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Stretch"
                    Content="{Binding SelectedViewModel}" />
            </Grid>
        </materialDesign:DialogHost>
    </Border>
</Window>
