<Page
    x:Class="WslSettings.Views.Settings.OptionalFeaturesPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctControls="using:CommunityToolkit.WinUI.Controls"
    xmlns:behaviors="using:WslSettings.Behaviors"
    xmlns:controls="using:WslSettings.Controls"
    behaviors:NavigationViewHeaderBehavior.HeaderMode="Never">

    <Grid Margin="{ThemeResource ContentPageMargin}"
          IsTabStop="True"
		  AutomationProperties.LandmarkType="Main"
		  x:Name="OptionalFeaturesPageRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBlock x:Uid="Settings_OptionalFeaturesPageTitle" Style="{ThemeResource PageHeaderTextBlockStyle}" Margin="{StaticResource MediumSmallBottomMargin}" HorizontalAlignment="Left" AutomationProperties.HeadingLevel="Level1"/>
        <TextBlock x:Uid="Settings_ErrorTryAgainLater" x:Name="Settings_ErrorTryAgainLater" Grid.Row="1" HorizontalAlignment="Left" AutomationProperties.LiveSetting="Assertive"
            Visibility="{x:Bind ViewModel.ErrorVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto"
            Visibility="{x:Bind ViewModel.SettingsContentVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityConverter}}">
            <StackPanel Spacing="{StaticResource SettingsCardSpacing}">
                <ctControls:SettingsCard x:Uid="Settings_AutoMemoryReclaim">
                    <ComboBox x:Uid="Settings_AutoMemoryReclaimComboBox" Style="{StaticResource ComboBoxSettingStyle}" HorizontalAlignment="Right"
                        ItemsSource="{x:Bind ViewModel.MemoryReclaimModes}" SelectedIndex="{x:Bind ViewModel.MemoryReclaimModeSelected, Mode=TwoWay}"/>
                </ctControls:SettingsCard>
                <ctControls:SettingsCard x:Uid="Settings_GUIApplications">
                    <ctControls:SettingsCard.Description>
                        <controls:HyperlinkTextBlock x:Uid="Settings_GUIApplicationsDescription"/>
                    </ctControls:SettingsCard.Description>
                    <ToggleSwitch x:Uid="Settings_GUIApplicationsToggleSwitch" HorizontalAlignment="Right" IsOn="{x:Bind ViewModel.IsOnGUIApplications, Mode=TwoWay}"/>
                </ctControls:SettingsCard>
                <ctControls:SettingsCard x:Uid="Settings_NestedVirtualization">
                    <ToggleSwitch x:Uid="Settings_NestedVirtualizationToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnNestedVirtualization, Mode=TwoWay}"/>
                </ctControls:SettingsCard>
                <ctControls:SettingsCard x:Uid="Settings_SafeMode">
                    <ToggleSwitch x:Uid="Settings_SafeModeToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnSafeMode, Mode=TwoWay}"/>
                </ctControls:SettingsCard>
                <ctControls:SettingsCard x:Uid="Settings_SparseVHD">
                    <ToggleSwitch x:Uid="Settings_SparseVHDToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnSparseVHD, Mode=TwoWay}"/>
                </ctControls:SettingsCard>
                <ctControls:SettingsExpander x:Name="VMIdleTimeoutExpander" x:Uid="Settings_VMIdleTimeout">
                    <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.VMIdleTimeout, Mode=OneWay, Converter={StaticResource MillisecondsStringConverter}}"/>
                    <ctControls:SettingsExpander.Items>
                        <ctControls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left" Margin="{StaticResource SettingsExpanderItemMargin}">
                            <StackPanel Orientation="Horizontal">
                                <TextBox x:Name="VMIdleTimeoutTextBox" x:Uid="Settings_VMIdleTimeoutTextBox" Style="{StaticResource TextBoxFilePathStyle}" Margin="{StaticResource InputControlSpacingMargin}"
                                    Text="{x:Bind ViewModel.VMIdleTimeout, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextChanged="VMIdleTimeoutTextBox_TextChanged"/>
                                <Button x:Uid="Settings_VMIdleTimeoutResetButton" Style="{StaticResource ButtonSettingStyle}" Margin="{StaticResource InputControlSpacingMargin}"
                                    Command="{x:Bind ViewModel.VMIdleTimeout_ResetCommand}" IsEnabled="{x:Bind ViewModel.VMIdleTimeout_ResetEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    Click="Settings_ResetButton_Click"/>
                            </StackPanel>
                        </ctControls:SettingsCard>
                    </ctControls:SettingsExpander.Items>
                </ctControls:SettingsExpander>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>
