<ContentDialog
    x:Class="CharacterMap.Controls.CreateCollectionDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:CharacterMap.Controls"
    xmlns:core="using:CharacterMap.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Uid="DigCreateCollection"
    CornerRadius="{StaticResource PopupCornerRadius}"
    IsPrimaryButtonEnabled="{x:Bind TemplateSettings.IsCollectionTitleValid, Mode=OneWay}"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
    PrimaryButtonStyle="{StaticResource DefaultThemeButtonStyle}"
    SecondaryButtonClick="{x:Bind Hide}"
    SecondaryButtonStyle="{StaticResource DefaultThemeButtonStyle}"
    SecondaryButtonText="{core:Localizer Key=Cancel}"
    Style="{StaticResource DefaultThemeContentDialogStyle}"
    mc:Ignorable="d"
    d:PrimaryButtonText="{core:Localizer Key=DigCreateCollection/PrimaryButtonText}"
    d:Title="{core:Localizer Key=DigCreateCollection/Title}">

    <Grid
        MinWidth="{Binding MinWidth}"
        core:Properties.GridDefinitions="c* cAuto"
        DataContext="{x:Bind TemplateSettings}">
        <StackPanel>
            <TextBox
                x:Name="InputBox"
                x:Uid="CreateCollectionEntryBox"
                Text="{Binding CollectionTitle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                d:Header="{core:Localizer Key=CreateCollectionEntryBox/Header}" />

            <controls:AutoGrid
                x:Name="SmartCollectionHeaderContainer"
                x:Load="{x:Bind AllowSmartCollection}"
                Margin="0 12 0 0"
                Definitions="c* cAuto"
                Orientation="Horizontal">
                <CheckBox
                    x:Name="SmartCollectionCheckbox"
                    x:Uid="CreateSmartCollectionCheck"
                    HorizontalAlignment="Stretch"
                    IsChecked="{x:Bind TemplateSettings.IsSmartCollection, Mode=TwoWay}"
                    Style="{StaticResource DefaultThemeCheckBoxStyle}"
                    d:Content="{core:Localizer Key=CreateSmartCollectionCheck/Content}" />
                <controls:UXButton
                    x:Uid="CreateSmartCollectionHint"
                    MinWidth="24"
                    MinHeight="24"
                    Margin="4 0 0 0"
                    Padding="4"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    core:Properties.Cursor="Hand"
                    core:Properties.Hyperlink="https://github.com/character-map-uwp/Character-Map-UWP/wiki/Smart-Collections"
                    CornerRadius="12">
                    <TextBlock
                        FontFamily="{StaticResource SymbolThemeFontFamily}"
                        FontSize="12"
                        Foreground="{ThemeResource AccentFillColorDefaultBrush}"
                        IsTextScaleFactorEnabled="False"
                        Text="&#xE897;" />
                </controls:UXButton>

            </controls:AutoGrid>

            <StackPanel
                x:Name="SmartFilters"
                x:Load="{x:Bind TemplateSettings.IsSmartCollection, Mode=OneWay}"
                Margin="0 12 0 0"
                Spacing="12">
                <TextBox HeaderTemplate="{x:Null}" Text="{Binding FilterFilePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.Header>
                        <StackPanel
                            Margin="0 -2"
                            Orientation="Horizontal"
                            Spacing="4">
                            <TextBlock
                                x:Uid="SmartCollectionFilePathFilter"
                                VerticalAlignment="Center"
                                d:Text="{core:Localizer Key=SmartCollectionFilePathFilter/Text}" />
                            <Border
                                Padding="4 2"
                                VerticalAlignment="Center"
                                Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
                                CornerRadius="4">
                                <TextBlock
                                    FontFamily="Consolas"
                                    FontSize="12"
                                    Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                    Text="{core:Localizer Key=FilePathFilter}" />
                            </Border>
                        </StackPanel>
                    </TextBox.Header>
                </TextBox>
                <TextBox Text="{Binding FilterFoundry, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" d:PlaceholderText="Microsoft">
                    <TextBox.Header>
                        <StackPanel
                            Margin="0 -2"
                            Orientation="Horizontal"
                            Spacing="4">
                            <TextBlock
                                x:Uid="SmartCollectionFoundryFilter"
                                VerticalAlignment="Center"
                                d:Text="{core:Localizer Key=SmartCollectionFoundryFilter/Text}" />
                            <Border
                                Padding="4 2"
                                VerticalAlignment="Center"
                                Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
                                CornerRadius="4">
                                <TextBlock
                                    FontFamily="Consolas"
                                    FontSize="12"
                                    Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                    Text="{core:Localizer Key=FoundryFilter}" />
                            </Border>
                        </StackPanel>
                    </TextBox.Header>
                </TextBox>
                <TextBox Text="{Binding FilterDesigner, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.Header>
                        <StackPanel
                            Margin="0 -2"
                            Orientation="Horizontal"
                            Spacing="4">
                            <TextBlock
                                x:Uid="SmartCollectionDesignerFilter"
                                VerticalAlignment="Center"
                                d:Text="{core:Localizer Key=SmartCollectionDesignerFilter/Text}" />
                            <Border
                                Padding="4 2"
                                VerticalAlignment="Center"
                                Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
                                CornerRadius="4">
                                <TextBlock
                                    FontFamily="Consolas"
                                    FontSize="12"
                                    Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                    Text="{core:Localizer Key=DesignerFilter}" />
                            </Border>
                        </StackPanel>
                    </TextBox.Header>
                </TextBox>
                <TextBox Text="{Binding FilterCharacters, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.Header>
                        <StackPanel
                            Margin="0 -2"
                            Orientation="Horizontal"
                            Spacing="4">
                            <TextBlock
                                x:Uid="SmartCollectionCharacterFilter"
                                VerticalAlignment="Center"
                                d:Text="{core:Localizer Key=SmartCollectionCharacterFilter/Text}" />
                            <Border
                                Padding="4 2"
                                VerticalAlignment="Center"
                                Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
                                CornerRadius="4">
                                <TextBlock
                                    FontFamily="Consolas"
                                    FontSize="12"
                                    Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                    Text="{core:Localizer Key=CharacterFilter}" />
                            </Border>
                        </StackPanel>
                    </TextBox.Header>
                </TextBox>
            </StackPanel>
        </StackPanel>

        <controls:AutoGrid
            x:Name="FilterPreview"
            x:Load="{x:Bind TemplateSettings.IsSmartCollection, Mode=OneWay}"
            Grid.Column="1"
            Width="256"
            Margin="16 0 -8 0"
            Padding="8"
            Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
            CornerRadius="8"
            Definitions="rAuto r* rAuto rs12"
            Orientation="Vertical">

            <TextBlock
                FontStyle="Italic"
                Opacity="0.7"
                Text="{Binding ResultsLabel}"
                TextAlignment="Center"
                d:Text="11 results" />

            <ListView
                MaxHeight="238"
                core:Properties.ToolTipTemplate="{StaticResource FontListToolTipTemplate}"
                ItemTemplate="{StaticResource FontListItemTemplateSimple}"
                ItemsSource="{Binding ResultsPreview}"
                SelectionMode="None">
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListViewItem">
                                    <ContentPresenter Content="{TemplateBinding Content}" />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>
                <d:ListView.Items>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Bahnschrift"
                            Text="Bahnschrift" />
                    </ListViewItem>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Calibri"
                            Text="Calibri" />
                    </ListViewItem>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Cambria"
                            Text="Cambria" />
                    </ListViewItem>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Candara"
                            Text="Candara" />
                    </ListViewItem>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Comic Sans MS"
                            Text="Comic Sans MS" />
                    </ListViewItem>
                    <ListViewItem MinWidth="0" HorizontalAlignment="Center">
                        <TextBlock
                            VerticalAlignment="Center"
                            FontFamily="Consolas"
                            Text="Consolas" />
                    </ListViewItem>
                </d:ListView.Items>
            </ListView>

            <controls:UXButton
                HorizontalAlignment="Stretch"
                Click="{x:Bind TemplateSettings.UpdateResults}"
                Style="{StaticResource DefaultThemeButtonStyle}">
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <FontIcon FontSize="12" Glyph="&#xE72C;" />
                    <TextBlock
                        Margin="0 -2 0 0"
                        VerticalAlignment="Center"
                        Text="{core:Localizer ZuneButton=True, Key='RefreshResultsLabel/Text'}" />
                </StackPanel>
            </controls:UXButton>
        </controls:AutoGrid>
    </Grid>
</ContentDialog>
