<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="using:VeloeMinecraftLauncher.ViewModels"
		  	 xmlns:utils="using:VeloeMinecraftLauncher.Utils"
		  	 xmlns:controls="using:VeloeMinecraftLauncher.Controls"
			 mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="320"
             x:Class="VeloeMinecraftLauncher.Views.SettingsView">
	<UserControl.Styles>
		<Style Selector="TabItem">
			<Setter Property="FontSize" Value="16"/>
		</Style>
	</UserControl.Styles>
	<Design.DataContext>
		<vm:SettingsViewModel/>
	</Design.DataContext>
	<Panel>
		<DockPanel>
			<TabControl
				HorizontalAlignment="Stretch"
				DockPanel.Dock="Top">
				<TabItem
					Header="Game"
					VerticalContentAlignment="Center">
					<Grid
						Margin="10 0 10 5"
						ShowGridLines="false"
						RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="250"></ColumnDefinition>
							<ColumnDefinition Width="*"></ColumnDefinition>
							<ColumnDefinition Width="70"></ColumnDefinition>
						</Grid.ColumnDefinitions>

						<CheckBox
							Grid.Row="1" Grid.Column="0"
							IsChecked="true"
							IsEnabled="False">
							Set path to minecraft folder
						</CheckBox>
						<TextBox
							Grid.Row="1" Grid.Column="1"
							Margin="5"
							Text="{Binding MinecraftFolderPath}"
							IsEnabled="{Binding SetMinecraftFolder}"/>
						<Button
							Grid.Row="1" Grid.Column="2"
							Content="Open"
							Command="{Binding OpenMinecraftPathDialog}"
							CommandParameter="{Binding $parent[Window]}"
							HorizontalAlignment="Stretch"
							HorizontalContentAlignment="Center"/>

						<CheckBox
							Grid.Row="2"
							Grid.Column="0"
							IsChecked="{Binding UseCustomJava}">
							Use custom java
						</CheckBox>
						<TextBox
							Grid.Row="2" Grid.Column="1"
							Margin="5"
							Text="{Binding JavaPath, Mode=TwoWay}"
							IsEnabled="{Binding UseCustomJava}" />
						<Button
							Grid.Row="2" Grid.Column="2"
							Content="Open"
							Command="{Binding OpenJavaPathDialog}"
							CommandParameter="{Binding $parent[Window]}"
							IsEnabled="{Binding UseCustomJava}"
							HorizontalAlignment="Stretch"
							HorizontalContentAlignment="Center"/>

						<CheckBox Grid.Row="3" Grid.Column="0"
									IsChecked="{Binding FullScreen}">Fullscreen mode</CheckBox>

						<CheckBox
							Grid.Row="4" Grid.Column="0"
							IsChecked="{Binding CustomSize}">Set game resolution</CheckBox>

						<StackPanel
							Grid.Row="4" Grid.Column="1"
							Orientation="Horizontal">
							<NumericUpDown
								Margin="5"
								Name="GameWidthEdit"
								Value="{Binding ClientWidth}"
								MaxWidth="200"
								ParsingNumberStyle="Integer"
								Minimum="1280"
								Maximum="{Binding $parent[Window].MaxGameWidth}"
								Theme="{StaticResource FixDataValidation}"
								ClipValueToMinMax ="True"
								ShowButtonSpinner="False"
								HorizontalAlignment="Left"
								VerticalAlignment="Top">
								<NumericUpDown.IsEnabled>
									<MultiBinding Converter="{x:Static utils:Converters.BoolConjuctionConventer}">
										<Binding Path="!FullScreen"/>
										<Binding Path="CustomSize"/>
									</MultiBinding>
								</NumericUpDown.IsEnabled>
							</NumericUpDown>
							<TextBlock VerticalAlignment="Center">x</TextBlock>
							<NumericUpDown
								Margin="5"
								Name="GameHeightEdit"
								Value="{Binding ClientHeight}"
								MaxWidth="200"
								ParsingNumberStyle="Integer"
								Minimum="720"
								Maximum="{Binding $parent[Window].MaxGameHeight}"
								Theme="{StaticResource FixDataValidation}"
								ClipValueToMinMax ="True"
								ShowButtonSpinner="False"
								HorizontalAlignment="Left"
								VerticalAlignment="Top">
								<NumericUpDown.IsEnabled>
									<MultiBinding Converter="{x:Static utils:Converters.BoolConjuctionConventer}">
										<Binding Path="!FullScreen"/>
										<Binding Path="CustomSize"/>
									</MultiBinding>
								</NumericUpDown.IsEnabled>
							</NumericUpDown>
						</StackPanel>

						<CheckBox
							Grid.Row="5" Grid.Column="0" IsChecked="{Binding SetMaxRam}">Set max RAM</CheckBox>
						<StackPanel
							Grid.Row="5" Grid.Column="1"
							Orientation="Horizontal">
							<NumericUpDown
								Grid.Row="5" Grid.Column="1"
								Margin="5"
								Name="MaxRamEdit"
								Value="{Binding MaxRam}"
								ParsingNumberStyle="Integer"
								MaxWidth="200"
								Minimum="256"
								Maximum="{Binding $parent[Window].MaxRam}"
								Theme="{StaticResource FixDataValidation}"
								ClipValueToMinMax ="True"
								ShowButtonSpinner="False"
								IsEnabled="{Binding SetMaxRam}"
								HorizontalAlignment="Left"
								VerticalAlignment="Top"/>
							<TextBlock VerticalAlignment="Center">MB</TextBlock>
						</StackPanel>
						<CheckBox
							Grid.Row="6" Grid.ColumnSpan="2"
							IsChecked="{Binding CheckAssets}"
							IsEnabled="True">
							Check vanilla game files before start
						</CheckBox>
						<CheckBox
							Grid.Row="7" Grid.ColumnSpan="2"
							IsChecked="{Binding HideLauncher}"
							IsEnabled="True">
							Hide launcher on game start
						</CheckBox>
						<Button
							Grid.Row="7" Grid.Column="2"
							HorizontalAlignment="Right"
							Content="Save"
							Command="{Binding SaveSettings}"
							IsEnabled="{Binding IsValid}"/>
					</Grid>
				</TabItem>
				<TabItem
					Header="Log"
					VerticalContentAlignment="Center">
					<Grid
						Margin="10 0 10 5"
						ShowGridLines="false"
						RowDefinitions="Auto, Auto, Auto, Auto, Auto, *">

						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="250"></ColumnDefinition>
							<ColumnDefinition Width="*"></ColumnDefinition>
							<ColumnDefinition Width="70"></ColumnDefinition>
						</Grid.ColumnDefinitions>

						<TextBlock
							Grid.Row="1" Grid.Column="0"
							VerticalAlignment="Center" Text="Console log event level"/>
						<ComboBox
							Grid.Row="1" Grid.Column="1"
							Margin="5"
							ItemsSource="{Binding LogEventLevels}"
							PlaceholderText="Select level"
							SelectedItem="{Binding ConsoleLogEventLevel}"
							HorizontalAlignment="Stretch"/>

						<TextBlock
							Grid.Row="2" Grid.Column="0"
							VerticalAlignment="Center">File log event level</TextBlock>
						<ComboBox
							Grid.Row="2" Grid.Column="1"
							Margin="5"
							ItemsSource="{Binding LogEventLevels}"
							PlaceholderText="Select level"
							SelectedItem="{Binding FileLogEventLevel}"
							HorizontalAlignment="Stretch"/>

						<CheckBox
							Grid.Row="3" Grid.Column="0"
							IsChecked="{Binding SetMaxLog}">Set max log size</CheckBox>
						<StackPanel
							Grid.Row="3" Grid.Column="1"
							Orientation="Horizontal">
							<NumericUpDown
								Margin="5"
								Name="MaxLogEdit"
								Value="{Binding MaxLog}"
								MaxWidth="200"
								ParsingNumberStyle="Integer"
								IsEnabled="{Binding SetMaxLog}"
								Minimum="1"
								Maximum="1048576"
								Theme="{StaticResource FixDataValidation}"
								ClipValueToMinMax ="True"
								ShowButtonSpinner="False"
								HorizontalAlignment="Left"
								VerticalAlignment="Top"/>
							<TextBlock VerticalAlignment="Center">KB</TextBlock>
						</StackPanel>
						<DockPanel
							Grid.Row="4" Grid.ColumnSpan="3">
							<Button
								DockPanel.Dock="Right"
								Content="Open log"
								Command="{Binding OpenLogFile}"/>
							<CheckBox
								DockPanel.Dock="Left"
								IsChecked="{Binding GameLogToLauncher}">Show game log in launcher (performace issues)</CheckBox>
						</DockPanel>
						<DockPanel
							Grid.Row="5" Grid.ColumnSpan="3">
							<Button
								DockPanel.Dock="Right"
								Content="Save"
								Command="{Binding SaveSettings}"
								IsEnabled="{Binding IsValid}"
								VerticalAlignment="Bottom"/>
							<TextBlock
								DockPanel.Dock="Left"
								Text="{Binding LauncherVersion}"
								HorizontalAlignment="Left"
								VerticalAlignment="Bottom"/>			
						</DockPanel>
					</Grid>
				</TabItem>
			</TabControl>
		</DockPanel>
	</Panel>
</UserControl>
