<ContentDialog
    x:Class="Microsoft.PowerToys.Settings.UI.Views.ProfileEditorDialog"
    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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:viewmodels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
    Width="486"
    MinWidth="486"
    CloseButtonClick="ContentDialog_CloseButtonClick"
    DefaultButton="Primary"
    IsPrimaryButtonEnabled="{x:Bind ViewModel.CanSave, Mode=OneWay}"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
    Style="{StaticResource DefaultContentDialogStyle}"
    mc:Ignorable="d">

    <Grid MinWidth="486">
        <Grid.Resources>
            <x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
            <x:Double x:Key="SettingsCardWrapNoIconThreshold">0</x:Double>
            <Thickness x:Key="SettingsExpanderItemPadding">0,8,0,8</Thickness>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBox
            x:Name="ProfileNameTextBox"
            x:Uid="PowerDisplay_ProfileEditor_ProfileName"
            Margin="0,0,0,24"
            MaxLength="50"
            Text="{x:Bind ViewModel.ProfileName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

        <!--  Monitors List  -->
        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
            <StackPanel Spacing="16">
                <TextBlock x:Uid="PowerDisplay_ProfileEditor_Description" Style="{StaticResource BodyStrongTextBlockStyle}" />
                <ItemsControl ItemsSource="{x:Bind ViewModel.Monitors, Mode=OneWay}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate x:DataType="viewmodels:MonitorSelectionItem">
                            <tkcontrols:SettingsExpander
                                Margin="0,0,0,8"
                                Description="{x:Bind Monitor.Id, Mode=OneWay}"
                                Header="{x:Bind Monitor.DisplayName, Mode=OneWay}"
                                IsExpanded="True">
                                <tkcontrols:SettingsExpander.HeaderIcon>
                                    <FontIcon Glyph="{x:Bind Monitor.MonitorIconGlyph}" />
                                </tkcontrols:SettingsExpander.HeaderIcon>
                                <ToggleSwitch IsOn="{x:Bind IsSelected, Mode=TwoWay}" />
                                <tkcontrols:SettingsExpander.Items>
                                    <tkcontrols:SettingsCard
                                        Padding="16,8,16,8"
                                        IsEnabled="{x:Bind IsSelected, Mode=OneWay}"
                                        Visibility="{x:Bind Monitor.SupportsBrightness, Converter={StaticResource BoolToVisibilityConverter}}">
                                        <tkcontrols:SettingsCard.Header>
                                            <CheckBox IsChecked="{x:Bind IncludeBrightness, Mode=TwoWay}">
                                                <StackPanel Orientation="Horizontal" Spacing="8">
                                                    <FontIcon FontSize="16" Glyph="&#xE706;" />
                                                    <TextBlock x:Uid="PowerDisplay_ProfileEditor_Brightness" VerticalAlignment="Center" />
                                                </StackPanel>
                                            </CheckBox>
                                        </tkcontrols:SettingsCard.Header>
                                        <Slider
                                            MinWidth="{StaticResource SettingActionControlMinWidth}"
                                            VerticalAlignment="Center"
                                            Maximum="100"
                                            Minimum="0"
                                            Value="{x:Bind Brightness, Mode=TwoWay}" />
                                        <tkcontrols:SettingsCard.Resources>
                                            <x:Double x:Key="SettingsCardLeftIndention">0</x:Double>
                                        </tkcontrols:SettingsCard.Resources>
                                    </tkcontrols:SettingsCard>

                                    <tkcontrols:SettingsCard
                                        Padding="16,8,16,8"
                                        IsEnabled="{x:Bind IsSelected, Mode=OneWay}"
                                        Visibility="{x:Bind Monitor.SupportsContrast, Converter={StaticResource BoolToVisibilityConverter}}">
                                        <tkcontrols:SettingsCard.Header>
                                            <CheckBox IsChecked="{x:Bind IncludeContrast, Mode=TwoWay}">
                                                <StackPanel Orientation="Horizontal" Spacing="8">
                                                    <FontIcon FontSize="16" Glyph="&#xE793;" />
                                                    <TextBlock x:Uid="PowerDisplay_ProfileEditor_Contrast" VerticalAlignment="Center" />
                                                </StackPanel>
                                            </CheckBox>
                                        </tkcontrols:SettingsCard.Header>
                                        <Slider
                                            MinWidth="{StaticResource SettingActionControlMinWidth}"
                                            VerticalAlignment="Center"
                                            Maximum="100"
                                            Minimum="0"
                                            Value="{x:Bind Contrast, Mode=TwoWay}" />
                                    </tkcontrols:SettingsCard>
                                    <tkcontrols:SettingsCard
                                        Padding="16,8,16,8"
                                        IsEnabled="{x:Bind IsSelected, Mode=OneWay}"
                                        Visibility="{x:Bind Monitor.SupportsVolume, Converter={StaticResource BoolToVisibilityConverter}}">
                                        <tkcontrols:SettingsCard.Header>
                                            <CheckBox IsChecked="{x:Bind IncludeVolume, Mode=TwoWay}">
                                                <StackPanel Orientation="Horizontal" Spacing="8">
                                                    <FontIcon FontSize="16" Glyph="&#xE767;" />
                                                    <TextBlock x:Uid="PowerDisplay_ProfileEditor_Volume" VerticalAlignment="Center" />
                                                </StackPanel>
                                            </CheckBox>
                                        </tkcontrols:SettingsCard.Header>
                                        <Slider
                                            MinWidth="{StaticResource SettingActionControlMinWidth}"
                                            VerticalAlignment="Center"
                                            Maximum="100"
                                            Minimum="0"
                                            Value="{x:Bind Volume, Mode=TwoWay}" />
                                    </tkcontrols:SettingsCard>
                                    <tkcontrols:SettingsCard
                                        Padding="16,8,16,8"
                                        IsEnabled="{x:Bind IsSelected, Mode=OneWay}"
                                        Visibility="{x:Bind Monitor.SupportsColorTemperature, Converter={StaticResource BoolToVisibilityConverter}}">
                                        <tkcontrols:SettingsCard.Header>
                                            <CheckBox IsChecked="{x:Bind IncludeColorTemperature, Mode=TwoWay}">
                                                <StackPanel Orientation="Horizontal" Spacing="8">
                                                    <FontIcon FontSize="16" Glyph="&#xE790;" />
                                                    <TextBlock x:Uid="PowerDisplay_ProfileEditor_ColorTemperature" VerticalAlignment="Center" />
                                                </StackPanel>
                                            </CheckBox>
                                        </tkcontrols:SettingsCard.Header>
                                        <ComboBox
                                            x:Uid="PowerDisplay_ProfileEditor_ColorTemperature_ComboBox"
                                            MinWidth="{StaticResource SettingActionControlMinWidth}"
                                            VerticalAlignment="Center"
                                            DisplayMemberPath="DisplayName"
                                            ItemsSource="{x:Bind Monitor.ColorPresetsForDisplay, Mode=OneWay}"
                                            SelectedValue="{x:Bind ColorTemperature, Mode=TwoWay}"
                                            SelectedValuePath="VcpValue" />
                                    </tkcontrols:SettingsCard>
                                </tkcontrols:SettingsExpander.Items>
                            </tkcontrols:SettingsExpander>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>

                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</ContentDialog>
