<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:DodoSSH.Client.Shell.ViewModels"
             x:Class="DodoSSH.Client.App.Views.SettingsPreferencesPage"
             x:DataType="vm:MainWindowViewModel">

  <!--
    v5c: Preferences, against Settings-Preferences.dc.html — the old PreferencesScreen.axaml's real content,
    restyled into the settings page idiom and split across two pages rather than one.

    THIS MACHINE moved to the Security page whole: Windows Hello's register/"stop unlocking here" pair and
    the no-TPM explanation are Security's UNLOCKING card now, one home rather than two — see the cross-
    reference row at the foot of this page. Device name is not one of the rows that moved; it never existed
    here at all, because there is no device-name setting to move. Logs record the machine name on their own.

    TERMINAL keeps its one real setting, text size, and drops the design's other five — font, cursor,
    scrollback, copy on select, terminal bell — which the renderer hard-codes. KEYCHAIN keeps Lock now,
    Sync now/Sign in, and the importer row exactly as the old screen had them; the design's own SECURITY
    card (clipboard-clear delay, confirm-run-on-insert) has nothing behind either row and is not drawn here.
  -->

  <ScrollViewer>
    <StackPanel MaxWidth="1100" Margin="40" HorizontalAlignment="Stretch">

      <TextBlock Classes="settingstitle" Text="Preferences" />

      <TextBlock Classes="settingssection" Text="TERMINAL" />

      <Border Classes="settingscard">
        <StackPanel>

          <Border Classes="settingsrow last">
            <Grid ColumnDefinitions="*,Auto">
              <StackPanel Grid.Column="0" Spacing="6" Margin="0,0,16,0">
                <TextBlock Classes="settingsrowtitle" Text="Text size" />
                <TextBlock Classes="settingsrowcaption"
                           Text="How large a terminal draws, in pixels. Ctrl+plus and Ctrl+minus do the same while a terminal has focus, and Ctrl+0 puts it back. It resizes the grid rather than magnifying it, so the remote is told how many columns it now has — which is also why it stops before the columns run out." />
              </StackPanel>
              <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="10" VerticalAlignment="Top">
                <Button Width="36" Height="36" Classes="ghost" Padding="0"
                        Command="{Binding ShrinkTerminalFontCommand}"
                        IsEnabled="{Binding CanShrinkTerminalFont}"
                        ToolTip.Tip="Smaller · Ctrl+minus">
                  <TextBlock FontFamily="{StaticResource IconFont}" Text="&#xE15B;" FontSize="15" />
                </Button>
                <TextBlock Classes="mono" FontSize="13.5" MinWidth="46" VerticalAlignment="Center"
                           TextAlignment="Center" Foreground="{StaticResource Text}"
                           Text="{Binding TerminalFontSize, StringFormat={}{0} px}" />
                <Button Width="36" Height="36" Classes="ghost" Padding="0"
                        Command="{Binding EnlargeTerminalFontCommand}"
                        IsEnabled="{Binding CanEnlargeTerminalFont}"
                        ToolTip.Tip="Larger · Ctrl+plus">
                  <TextBlock FontFamily="{StaticResource IconFont}" Text="&#xE145;" FontSize="15" />
                </Button>
                <Button Classes="ghost" Height="36" Content="RESET"
                        Command="{Binding ResetTerminalFontCommand}"
                        ToolTip.Tip="Back to the size it ships at · Ctrl+0" />
              </StackPanel>
            </Grid>
          </Border>

        </StackPanel>
      </Border>

      <TextBlock Classes="settingssection" Text="KEYCHAIN" />

      <Border Classes="settingscard">
        <StackPanel>

          <Border Classes="settingsrow">
            <Grid ColumnDefinitions="*,Auto">
              <StackPanel Grid.Column="0" Spacing="6" Margin="0,0,16,0">
                <TextBlock Classes="settingsrowtitle" Text="Lock the keychain" />
                <TextBlock Classes="settingsrowcaption"
                           Text="Closes the keychain and forgets every key it held. Shells you have open keep running and reappear when you unlock — locked describes the keychain, not this machine's access to your hosts." />
              </StackPanel>
              <Button Grid.Column="1" Classes="ghost" Height="38" Content="LOCK NOW"
                      Command="{Binding LockCommand}" />
            </Grid>
          </Border>

          <Border Classes="settingsrow">
            <Grid ColumnDefinitions="*,Auto">
              <StackPanel Grid.Column="0" Spacing="6" Margin="0,0,16,0">
                <TextBlock Classes="settingsrowtitle" Text="Synchronise" />
                <TextBlock Classes="settingsrowcaption"
                           Text="Runs a pass now. One runs on its own when the keychain opens, straight after any change, and every minute while it stays open." />
              </StackPanel>
              <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="8">
                <Button Classes="ghost" Height="38" Content="SIGN IN" Command="{Binding SignInCommand}"
                        IsVisible="{Binding !IsOnline}"
                        ToolTip.Tip="Opens your browser. Only needed when there is no remembered session to resume." />
                <Button Classes="ghost" Height="38" Content="SYNC NOW" Command="{Binding Vault.SyncCommand}" />
              </StackPanel>
            </Grid>
          </Border>

          <Border Classes="settingsrow last">
            <Grid ColumnDefinitions="*,Auto">
              <StackPanel Grid.Column="0" Spacing="6" Margin="0,0,16,0">
                <TextBlock Classes="settingsrowtitle" Text="Import SSH config" />
                <TextBlock Classes="settingsrowcaption"
                           Text="Reads this machine's ~/.ssh/config, shows what it found, and imports only what you approve. Nothing is stored during the scan, and no private key is read — where a key file is named, the path is recorded as a note." />
              </StackPanel>
              <Button Grid.Column="1" Classes="ghost" Height="38" Content="OPEN IMPORTER"
                      Command="{Binding ShowScreenCommand}"
                      CommandParameter="{x:Static vm:ShellScreen.Import}" />
            </Grid>
          </Border>

        </StackPanel>
      </Border>

      <TextBlock Classes="settingssection" Text="NOT BUILT YET" />

      <Border Classes="settingscard">
        <StackPanel Margin="24,20" Spacing="10">
          <TextBlock Classes="settingsrowcaption"
                     Text="Unlocking with Windows Hello moved to Security — it registers this machine rather than a preference of this screen's, and Security is where the rest of this machine's trust facts live." />
          <TextBlock Classes="settingsrowcaption"
                     Text="Terminal font, cursor and scrollback — the renderer hard-codes those three. Text size above is the one that is not." />
          <TextBlock Classes="settingsrowcaption"
                     Text="Copy on select and the terminal bell — neither is wired to anything the renderer does." />
          <TextBlock Classes="settingsrowcaption"
                     Text="Clearing the clipboard after copying a secret, and confirming a snippet that runs on insert — neither exists; a copied secret stays on the clipboard until something else replaces it." />
          <TextBlock Classes="settingsrowcaption"
                     Text="A device name — there is no such setting. Logs record this machine's own name on their own." />
        </StackPanel>
      </Border>

    </StackPanel>
  </ScrollViewer>

</UserControl>
