<UserControl x:Class="Saradomin.View.Controls.SettingsView"
             xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:Saradomin.View.Controls"
             xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
             xmlns:vm="clr-namespace:Saradomin.ViewModel.Controls"
             DataContext="{mvvm:DataContextSource vm:SettingsViewModel}">
    <Grid Margin="0,0,2,2"
          ColumnDefinitions="0.55*,*">
        <DockPanel Grid.Column="0">
            <HeaderedContentControl Classes="GroupBox"
                                    DockPanel.Dock="Top"
                                    Header="launcher settings">
                <StackPanel Orientation="Vertical">
                    <CheckBox Content="Place 'X' button on the left"
                              IsChecked="{Binding Launcher.PlaceCloseButtonOnLeft, Mode=TwoWay}" />

                    <CheckBox Content="Close the launcher after executing the client"
                              IsChecked="{Binding Launcher.ExitAfterLaunchingClient, Mode=TwoWay}"
                              IsEnabled="{Binding !Launcher.AllowMultiboxing, Mode=OneWay}" />

                    <CheckBox Content="Check for client updates on launch"
                              IsChecked="{Binding Launcher.CheckForClientUpdatesOnLaunch, Mode=TwoWay}" />

                    <CheckBox Content="Check for updated server profiles on launch"
                              IsChecked="{Binding Launcher.CheckForServerProfilesOnLaunch, Mode=TwoWay}" />

                    <CheckBox Content="Allow multiple client instances to run"
                              IsChecked="{Binding Launcher.AllowMultiboxing, Mode=TwoWay}" />

                    <Grid Margin="0,2,0,4"
                          ColumnDefinitions="*,Auto"
                          RowDefinitions="Auto,Auto">
                        <TextBlock Grid.Row="0"
                                   Grid.ColumnSpan="2"
                                   Margin="3,0,0,2"
                                   Foreground="{StaticResource DarkForegroundBrush}"
                                   Text="Java executable location" />

                        <TextBox Grid.Row="1"
                                 Grid.Column="0"
                                 Width="300"
                                 Margin="2,0,0,0"
                                 HorizontalAlignment="Left"
                                 IsReadOnly="True"
                                 Classes="NormalTextBox"
                                 Text="{Binding Launcher.JavaExecutableLocation, Mode=TwoWay}"
                                 Watermark="Enter a path to java or java.exe..." />

                        <Button Grid.Row="1"
                                Grid.Column="1"
                                Width="22"
                                Height="24"
                                Margin="2,0,0,0"
                                Classes="OutsideNavigator"
                                Command="{Binding BrowseForJavaExecutable}"
                                Content="..."
                                ToolTip.Tip="Browse..." />
                    </Grid>

                    <Grid Margin="0,0,0,4"
                          RowDefinitions="Auto, Auto">
                        <TextBlock Grid.Row="0"
                                   Margin="3,0,0,2"
                                   HorizontalAlignment="Left"
                                   Foreground="{StaticResource DarkForegroundBrush}"
                                   Text="Server profile" />

                        <ComboBox Grid.Row="1"
                                  Margin="2,0,0,2"
                                  ItemsSource="{Binding ServerProfiles}"
                                  SelectedItem="{Binding ServerProfile, Converter={StaticResource EnumDescriptionConverter}, Mode=TwoWay}">
                            <ComboBox.Styles>
                                <Style Selector="ComboBoxItem">
                                    <Setter Property="ToolTip.Tip" Value="{x:Null}" />
                                </Style>
                            </ComboBox.Styles>
                        </ComboBox>
                    </Grid>
                </StackPanel>
            </HeaderedContentControl>

            <HeaderedContentControl Margin="2,2,0,0"
                                    Classes="GroupBox"
                                    DockPanel.Dock="Top"
                                    Header="about this project">
                <HeaderedContentControl.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock HorizontalAlignment="Center"
                                   Text="{Binding Header}" />
                    </DataTemplate>
                </HeaderedContentControl.HeaderTemplate>

                <StackPanel HorizontalAlignment="Center"
                            VerticalAlignment="Center">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock HorizontalAlignment="Center"
                                   Foreground="{StaticResource DarkForegroundBrush}"
                                   Text="Made with ❤ by vddCore of " />
                        <Button Classes="Hyperlink"
                                Command="{Binding LaunchScapeWebsite}"
                                Content="2009scape." />
                    </StackPanel>

                    <TextBlock Text=" " />

                    <TextBlock HorizontalAlignment="Center"
                               Foreground="{StaticResource DarkForegroundBrush}"
                               Text="{Binding VersionString}" />

                    <Button Margin="0,0,0,4"
                            HorizontalAlignment="Center"
                            Classes="Hyperlink"
                            Command="{Binding LaunchProjectWebsite}"
                            Content="visit project website" />
                </StackPanel>
            </HeaderedContentControl>
        </DockPanel>

        <DockPanel Grid.Column="1"
                   DockPanel.Dock="Top">
            <HeaderedContentControl Classes="GroupBox"
                                    DockPanel.Dock="Top"
                                    Header="client settings">
                <Grid RowDefinitions="Auto,*"
                      Margin="0,0,0,4">
                    <Grid Grid.Row="0" ColumnDefinitions="Auto, *">
                        <Grid Grid.Column="0"
                              RowDefinitions="Auto, Auto">
                            <TextBlock Grid.Row="0"
                                       Grid.Column="0"
                                       Margin="0,0,4,0"
                                       Foreground="{StaticResource DarkForegroundBrush}"
                                       Text="UI scale" />

                            <NumericUpDown Grid.Row="1"
                                           Grid.Column="0"
                                           Width="55"
                                           Height="28"
                                           Margin="0,2,0,0"
                                           HorizontalAlignment="Left"
                                           HorizontalContentAlignment="Right"
                                           AllowSpin="True"
                                           Classes="NormalNumericUpDown"
                                           ClipValueToMinMax="True"
                                           FormatString="0.00"
                                           Maximum="4"
                                           Minimum="1"
                                           ParsingNumberStyle="Integer"
                                           ShowButtonSpinner="True"
                                           Value="{Binding Client.UiScale, Mode=TwoWay}" />
                        </Grid>

                        <Grid Grid.Column="1"
                              RowDefinitions="Auto, Auto">
                            <TextBlock Grid.Row="0"
                                       Grid.Column="0"
                                       Margin="0,0,4,0"
                                       Foreground="{StaticResource DarkForegroundBrush}"
                                       Text="Target FPS (0=auto)" />

                            <NumericUpDown Grid.Row="1"
                                           Grid.Column="0"
                                           Width="55"
                                           Height="28"
                                           Margin="0,2,0,0"
                                           HorizontalAlignment="Left"
                                           HorizontalContentAlignment="Right"
                                           AllowSpin="True"
                                           Classes="NormalNumericUpDown"
                                           ClipValueToMinMax="True"
                                           FormatString="0"
                                           Maximum="1000"
                                           Minimum="0"
                                           ParsingNumberStyle="Integer"
                                           ShowButtonSpinner="True"
                                           Value="{Binding Client.Fps, Mode=TwoWay}" />
                        </Grid>
                    </Grid>
                </Grid>
            </HeaderedContentControl>
            
            <HeaderedContentControl Classes="GroupBox"
                                    Header="plugin management"
                                    DockPanel.Dock="Top">
                <controls:PluginManagerView MaxHeight="346"/>
            </HeaderedContentControl>
        </DockPanel>
        
    </Grid>
</UserControl>
