<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="AppControlManager.Pages.MergePolicies"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppControlManager.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:controls="using:CommunityToolkit.WinUI.Controls"
    mc:Ignorable="d">

    <Page.Resources>
        <!--  These styles can be referenced to create a consistent SettingsPage layout  -->

        <!--  Spacing between cards  -->
        <x:Double x:Key="SettingsCardSpacing">4</x:Double>

        <!--  Style (inc. the correct spacing) of a section header  -->
        <Style x:Key="SettingsSectionHeaderTextBlockStyle"
       BasedOn="{StaticResource BodyStrongTextBlockStyle}"
       TargetType="TextBlock">
            <Style.Setters>
                <Setter Property="Margin" Value="1,30,0,6" />
            </Style.Setters>
        </Style>
    </Page.Resources>

    <ScrollViewer>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>


            <controls:WrapPanel Grid.Row="0" VerticalSpacing="4" HorizontalSpacing="4" Orientation="Vertical" Margin="6,10,6,10">

                <TextBlock
TextWrapping="WrapWholeWords"
Style="{StaticResource BodyTextBlockStyle}">

<Span>
    Merge <Italic>App Control for Business</Italic>
        <Run Foreground="{ThemeResource SystemAccentColor}">policies</Run>
    and deduplicate them. You can select <Bold>the same policy twice</Bold> in order to deduplicate its rules.
</Span>
                </TextBlock>

                <HyperlinkButton Content="Guide" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/wiki/Merge-App-Control-Policies" />

            </controls:WrapPanel>



            <StackPanel HorizontalAlignment="Stretch"
                        Spacing="{StaticResource SettingsCardSpacing}" Grid.Row="1" Margin="0,40,0,0">

                <win:StackPanel.ChildrenTransitions>
                    <win:EntranceThemeTransition FromVerticalOffset="50" />
                    <win:RepositionThemeTransition IsStaggeringEnabled="False" />
                </win:StackPanel.ChildrenTransitions>


                <controls:SettingsExpander x:Name="MergePoliciesSettings"
                           Description="Merge App Control Policies"
                           Header="Merge"
                           IsExpanded="True"
                           HeaderIcon="{ui:FontIcon Glyph=&#xEA3C;}">

                    <controls:SettingsExpander.ItemsHeader>
                        <InfoBar x:Name="PolicyMergerInfoBar"
                            Title="Current Status"
                            BorderThickness="0"
                            CornerRadius="0"
                            IsIconVisible="True"
                            IsOpen="False"
                            IsClosable="False"
                            Severity="Informational">
                        </InfoBar>
                    </controls:SettingsExpander.ItemsHeader>

                    <controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="6" VerticalSpacing="10">

                        <Button x:Name="MergeButton" Content="Merge"
                             Style="{StaticResource AccentButtonStyle}" Margin="0,0,15,0" Click="MergeButton_Click" />

                        <ToggleButton x:Name="DeployToggleButton" Content="Deploy" Click="DeployToggleButton_Click" Margin="0,0,15,0" />

                        <ProgressRing IsIndeterminate="True" Visibility="Collapsed" x:Name="MergeProgressRing" />

                        <TeachingTip x:Name="MergeButtonTeachingTip" Target="{x:Bind MergeButton}" />


                    </controls:WrapPanel>

                    <controls:SettingsExpander.Items>

                        <controls:SettingsCard Description="Browse for the path to the main policy XML file." IsClickEnabled="True"
                               Header="Select Main Policy" x:Name="MainPolicySettingsCard" Click="MainPolicySettingsCard_Click" IsActionIconVisible="False">

                            <Button Content="Browse" x:Name="MainPolicyBrowseButton" Click="MainPolicyBrowseButton_Click">

                                <Button.Flyout>
                                    <Flyout x:Name="MainPolicy_Flyout">

                                        <controls:WrapPanel Orientation="Vertical" HorizontalSpacing="15" VerticalSpacing="15">

                                            <Button Content="Clear" Click="MainPolicy_Flyout_ClearButton" />

                                            <TextBlock Text="View the Main policy you selected." TextWrapping="WrapWholeWords" />

                                            <TextBox x:Name="MainPolicy_Flyout_TextBox"
                                                TextWrapping="Wrap" AcceptsReturn="True" IsSpellCheckEnabled="False"
                                                SelectionHighlightColor="Pink" MinWidth="400" IsReadOnly="True" />

                                        </controls:WrapPanel>

                                    </Flyout>
                                </Button.Flyout>

                            </Button>

                        </controls:SettingsCard>

                        <controls:SettingsCard Description="Select other policies to merge with the main policy" IsClickEnabled="True"
                            Header="Select other policies" x:Name="OtherPoliciesSettingsCard" Click="OtherPoliciesSettingsCard_Click" IsActionIconVisible="False">

                            <Button Content="Browse" x:Name="OtherPoliciesBrowseButton" Click="OtherPoliciesBrowseButton_Click">

                                <Button.Flyout>
                                    <Flyout x:Name="OtherPolicies_Flyout">

                                        <controls:WrapPanel Orientation="Vertical" HorizontalSpacing="15" VerticalSpacing="15">

                                            <Button Content="Clear" Click="OtherPolicies_Flyout_ClearButton" />

                                            <TextBlock Text="View the other policies you selected." TextWrapping="WrapWholeWords" />

                                            <TextBox x:Name="OtherPolicies_Flyout_TextBox"
                                                TextWrapping="Wrap" AcceptsReturn="True" IsSpellCheckEnabled="False"
                                                SelectionHighlightColor="Pink" MinWidth="400" IsReadOnly="True" />

                                        </controls:WrapPanel>

                                    </Flyout>
                                </Button.Flyout>

                            </Button>

                        </controls:SettingsCard>

                    </controls:SettingsExpander.Items>

                </controls:SettingsExpander>

            </StackPanel>
        </Grid>

    </ScrollViewer>

</Page>
