<!--
    Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
    the MIT License. See LICENSE in the project root for license information.
-->
<Page x:Class="Microsoft.Terminal.Settings.Editor.Profiles_Advanced"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:Microsoft.Terminal.Settings.Editor"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:model="using:Microsoft.Terminal.Settings.Model"
      xmlns:mtu="using:Microsoft.Terminal.UI"
      xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
      mc:Ignorable="d">

    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="CommonResources.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <DataTemplate x:Key="EnumComboBoxTemplate"
                          x:DataType="local:EnumEntry">
                <TextBlock Text="{x:Bind EnumName, Mode=OneWay}" />
            </DataTemplate>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBlock x:Uid="Profile_BaseLayerDisclaimer"
                   Style="{StaticResource DisclaimerStyle}"
                   Visibility="{x:Bind Profile.IsBaseLayer}" />
        <StackPanel Grid.Row="1"
                    Style="{StaticResource SettingsStackStyle}">
            <!--  Antialiasing Mode  -->
            <local:SettingContainer x:Uid="Profile_AntialiasingMode"
                                    ClearSettingValue="{x:Bind Profile.ClearAntialiasingMode}"
                                    HasSettingValue="{x:Bind Profile.HasAntialiasingMode, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.AntialiasingModeOverrideSource, Mode=OneWay}">
                <ComboBox AutomationProperties.AccessibilityView="Content"
                          ItemTemplate="{StaticResource EnumComboBoxTemplate}"
                          ItemsSource="{x:Bind Profile.AntiAliasingModeList, Mode=OneWay}"
                          SelectedItem="{x:Bind Profile.CurrentAntiAliasingMode, Mode=TwoWay}"
                          Style="{StaticResource ComboBoxSettingStyle}" />
            </local:SettingContainer>

            <!--  AltGr Aliasing  -->
            <local:SettingContainer x:Uid="Profile_AltGrAliasing"
                                    ClearSettingValue="{x:Bind Profile.ClearAltGrAliasing}"
                                    HasSettingValue="{x:Bind Profile.HasAltGrAliasing, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.AltGrAliasingOverrideSource, Mode=OneWay}">
                <ToggleSwitch IsOn="{x:Bind Profile.AltGrAliasing, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  Snap On Input  -->
            <local:SettingContainer x:Uid="Profile_SnapOnInput"
                                    ClearSettingValue="{x:Bind Profile.ClearSnapOnInput}"
                                    HasSettingValue="{x:Bind Profile.HasSnapOnInput, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.SnapOnInputOverrideSource, Mode=OneWay}">
                <ToggleSwitch IsOn="{x:Bind Profile.SnapOnInput, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  History Size  -->
            <local:SettingContainer x:Uid="Profile_HistorySize"
                                    ClearSettingValue="{x:Bind Profile.ClearHistorySize}"
                                    HasSettingValue="{x:Bind Profile.HasHistorySize, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.HistorySizeOverrideSource, Mode=OneWay}">
                <muxc:NumberBox x:Uid="Profile_HistorySizeBox"
                                LargeChange="100"
                                Minimum="0"
                                SmallChange="10"
                                Style="{StaticResource NumberBoxSettingStyle}"
                                Value="{x:Bind Profile.HistorySize, Mode=TwoWay}" />
            </local:SettingContainer>

            <!--  Close On Exit  -->
            <local:SettingContainer x:Uid="Profile_CloseOnExit"
                                    ClearSettingValue="{x:Bind Profile.ClearCloseOnExit}"
                                    HasSettingValue="{x:Bind Profile.HasCloseOnExit, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.CloseOnExitOverrideSource, Mode=OneWay}">
                <ComboBox AutomationProperties.AccessibilityView="Content"
                          ItemTemplate="{StaticResource EnumComboBoxTemplate}"
                          ItemsSource="{x:Bind Profile.CloseOnExitModeList, Mode=OneWay}"
                          SelectedItem="{x:Bind Profile.CurrentCloseOnExitMode, Mode=TwoWay}"
                          Style="{StaticResource ComboBoxSettingStyle}" />
            </local:SettingContainer>

            <!--  Bell Style  -->
            <local:SettingContainer x:Uid="Profile_BellStyle"
                                    ClearSettingValue="{x:Bind Profile.ClearBellStyle}"
                                    CurrentValue="{x:Bind Profile.BellStylePreview, Mode=OneWay}"
                                    HasSettingValue="{x:Bind Profile.HasBellStyle, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.BellStyleOverrideSource, Mode=OneWay}"
                                    Style="{StaticResource ExpanderSettingContainerStyle}">
                <StackPanel>
                    <CheckBox x:Uid="Profile_BellStyleAudible"
                              IsChecked="{x:Bind Profile.IsBellStyleFlagSet(1), BindBack=Profile.SetBellStyleAudible, Mode=TwoWay}" />
                    <CheckBox x:Uid="Profile_BellStyleWindow"
                              IsChecked="{x:Bind Profile.IsBellStyleFlagSet(2), BindBack=Profile.SetBellStyleWindow, Mode=TwoWay}" />
                    <CheckBox x:Uid="Profile_BellStyleTaskbar"
                              IsChecked="{x:Bind Profile.IsBellStyleFlagSet(4), BindBack=Profile.SetBellStyleTaskbar, Mode=TwoWay}" />
                </StackPanel>
            </local:SettingContainer>

            <!--  Bell Sound  -->
            <local:SettingContainer x:Uid="Profile_BellSound"
                                    ClearSettingValue="{x:Bind Profile.ClearBellSound}"
                                    CurrentValue="{x:Bind Profile.BellSoundPreview, Mode=OneWay}"
                                    HasSettingValue="{x:Bind Profile.HasBellSound, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.BellSoundOverrideSource, Mode=OneWay}"
                                    Style="{StaticResource ExpanderSettingContainerStyle}">
                <StackPanel Spacing="10">
                    <TextBlock x:Uid="Profile_BellSoundInfo"
                               Style="{StaticResource DisclaimerStyle}" />
                    <ItemsControl ItemsSource="{x:Bind Profile.CurrentBellSounds, Mode=OneWay}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Spacing="4" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate x:DataType="local:BellSoundViewModel">
                                <Grid TabFocusNavigation="Local">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="300" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <!--  standard UI for bell sound entry  -->
                                    <StackPanel Grid.Column="0"
                                                Visibility="{x:Bind FileExists, Mode=OneWay}">
                                        <TextBlock Style="{StaticResource TextBlockSettingStyle}"
                                                   Text="{x:Bind DisplayPath, Mode=OneWay}" />
                                        <TextBlock Foreground="{ThemeResource SubgroupHeaderBrush}"
                                                   Style="{StaticResource CaptionTextBlockStyle}"
                                                   Text="{x:Bind SubText, Mode=OneWay}"
                                                   Visibility="{x:Bind ShowDirectory, Mode=OneWay}" />
                                    </StackPanel>
                                    <!--  When a file is not found, we use this UI  -->
                                    <StackPanel Grid.Column="0"
                                                Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(FileExists), Mode=OneWay}">
                                        <TextBlock Style="{StaticResource TextBlockSettingStyle}"
                                                   Text="{x:Bind DisplayPath, Mode=OneWay}"
                                                   TextDecorations="Strikethrough" />
                                        <TextBlock Foreground="{ThemeResource SubgroupHeaderBrush}"
                                                   Style="{StaticResource CaptionTextBlockStyle}"
                                                   Text="{x:Bind SubText, Mode=OneWay}" />
                                    </StackPanel>
                                    <Button x:Uid="Profile_BellSoundAudioPreview"
                                            Grid.Column="1"
                                            Margin="4,0,0,0"
                                            VerticalAlignment="Stretch"
                                            Click="BellSoundAudioPreview_Click"
                                            IsEnabled="{x:Bind FileExists, Mode=OneWay}"
                                            Style="{StaticResource BrowseButtonStyle}"
                                            Tag="{Binding Mode=OneWay}">
                                        <FontIcon FontSize="{StaticResource StandardIconSize}"
                                                  Glyph="&#xE767;" />
                                    </Button>
                                    <Button x:Uid="Profile_BellSoundDelete"
                                            Grid.Column="2"
                                            Margin="4,0,0,0"
                                            VerticalAlignment="Stretch"
                                            Click="BellSoundDelete_Click"
                                            Style="{StaticResource DeleteButtonStyle}"
                                            Tag="{Binding Mode=OneWay}">
                                        <FontIcon FontSize="{StaticResource StandardIconSize}"
                                                  Glyph="&#xE74D;" />
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                    <Button x:Name="AddBellSoundButton"
                            Click="BellSoundAdd_Click">
                        <StackPanel Orientation="Horizontal">
                            <FontIcon FontSize="{StaticResource StandardIconSize}"
                                      Glyph="&#xE948;" />
                            <TextBlock x:Uid="Profile_AddBellSound"
                                       Margin="8,0,0,0" />
                        </StackPanel>
                    </Button>
                </StackPanel>
            </local:SettingContainer>

            <!--  RightClickContextMenu  -->
            <local:SettingContainer x:Uid="Profile_RightClickContextMenu"
                                    ClearSettingValue="{x:Bind Profile.ClearRightClickContextMenu}"
                                    HasSettingValue="{x:Bind Profile.HasRightClickContextMenu, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.RightClickContextMenuOverrideSource, Mode=OneWay}">
                <ToggleSwitch IsOn="{x:Bind Profile.RightClickContextMenu, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  ShowMarks  -->
            <local:SettingContainer x:Uid="Profile_ShowMarks"
                                    ClearSettingValue="{x:Bind Profile.ClearShowMarks}"
                                    HasSettingValue="{x:Bind Profile.HasShowMarks, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.ShowMarksOverrideSource, Mode=OneWay}"
                                    Visibility="{x:Bind Profile.ShowMarksAvailable}">
                <ToggleSwitch IsOn="{x:Bind Profile.ShowMarks, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  AutoMarkPrompts  -->
            <local:SettingContainer x:Uid="Profile_AutoMarkPrompts"
                                    ClearSettingValue="{x:Bind Profile.ClearAutoMarkPrompts}"
                                    HasSettingValue="{x:Bind Profile.HasAutoMarkPrompts, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.AutoMarkPromptsOverrideSource, Mode=OneWay}"
                                    Visibility="{x:Bind Profile.AutoMarkPromptsAvailable}">
                <ToggleSwitch IsOn="{x:Bind Profile.AutoMarkPrompts, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  ReloadEnvVars  -->
            <local:SettingContainer x:Uid="Profile_ReloadEnvVars"
                                    ClearSettingValue="{x:Bind Profile.ClearReloadEnvironmentVariables}"
                                    HasSettingValue="{x:Bind Profile.HasReloadEnvironmentVariables, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.ReloadEnvironmentVariablesOverrideSource, Mode=OneWay}">
                <ToggleSwitch IsOn="{x:Bind Profile.ReloadEnvironmentVariables, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  RepositionCursorWithMouse  -->
            <local:SettingContainer x:Uid="Profile_RepositionCursorWithMouse"
                                    ClearSettingValue="{x:Bind Profile.ClearRepositionCursorWithMouse}"
                                    HasSettingValue="{x:Bind Profile.HasRepositionCursorWithMouse, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.RepositionCursorWithMouseOverrideSource, Mode=OneWay}"
                                    Visibility="{x:Bind Profile.RepositionCursorWithMouseAvailable}">
                <ToggleSwitch IsOn="{x:Bind Profile.RepositionCursorWithMouse, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  RainbowSuggestions  -->
            <local:SettingContainer x:Uid="Profile_RainbowSuggestions"
                                    ClearSettingValue="{x:Bind Profile.ClearRainbowSuggestions}"
                                    HasSettingValue="{x:Bind Profile.HasRainbowSuggestions, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.RainbowSuggestionsOverrideSource, Mode=OneWay}">
                <ToggleSwitch IsOn="{x:Bind Profile.RainbowSuggestions, Mode=TwoWay}"
                              Style="{StaticResource ToggleSwitchInExpanderStyle}" />
            </local:SettingContainer>

            <!--  Path Translation  -->
            <local:SettingContainer x:Uid="Profile_PathTranslationStyle"
                                    ClearSettingValue="{x:Bind Profile.ClearPathTranslationStyle}"
                                    HasSettingValue="{x:Bind Profile.HasPathTranslationStyle, Mode=OneWay}"
                                    SettingOverrideSource="{x:Bind Profile.PathTranslationStyleOverrideSource, Mode=OneWay}">
                <ComboBox AutomationProperties.AccessibilityView="Content"
                          ItemTemplate="{StaticResource EnumComboBoxTemplate}"
                          ItemsSource="{x:Bind Profile.PathTranslationStyleList, Mode=OneWay}"
                          SelectedItem="{x:Bind Profile.CurrentPathTranslationStyle, Mode=TwoWay}"
                          Style="{StaticResource ComboBoxSettingStyle}" />
            </local:SettingContainer>

        </StackPanel>
    </Grid>
</Page>
