<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="AppControlManager.Pages.Update"
    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:controls="using:CommunityToolkit.WinUI.Controls"
    xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
    xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    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="Auto"/>
                <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>
    Check for <Run Foreground="{ThemeResource SystemAccentColor}">updates</Run> in this page. You can also enable automatic update check which will happen once at startup and you will be notified whenever a new version is available.
</Span>
                </TextBlock>

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

            </controls:WrapPanel>


            <InfoBar
                x:Name="UpdateStatusInfoBar"
                IsOpen="False"
                IsIconVisible="True"
                IsClosable="False"
                Title="Update Status"
                Grid.Row="1">
                <InfoBar.ActionButton>
                    <HyperlinkButton Content="More info" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/wiki/AppControl-Manager" />
                </InfoBar.ActionButton>
            </InfoBar>

            <InfoBar Grid.Row="2" x:Name="WhatsNewInfoBar"
    Title="Release Notes"
    Message="Check out the GitHub releases for full release notes"
                     IsOpen="False"
                     Severity="Success"
                     IsClosable="True">
                <InfoBar.IconSource>
                    <FontIconSource Glyph="&#xE8A7;"/>
                </InfoBar.IconSource>
                <InfoBar.ActionButton>
                    <HyperlinkButton Content="See What's New" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/releases" HorizontalAlignment="Right"/>
                </InfoBar.ActionButton>
            </InfoBar>

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

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

                <controls:SettingsCard x:Name="CheckForUpdate"
                           Description="Once the updates are downloaded and installed, the next time you open the AppControl Manager you will use the new version."
                           Header="Check for AppControl Manager update"
                           HeaderIcon="{ui:FontIcon Glyph=&#xF83E;}" IsClickEnabled="True" Click="CheckForUpdate_Click">

                    <controls:WrapPanel Orientation="Horizontal">

                        <ProgressRing Visibility="Collapsed" x:Name="DownloadProgressRingForMSIXFile" Width="60" Height="60" Margin="5,5,15,5" Value="0" IsIndeterminate="False" Minimum="0" Maximum="100"/>

                        <Button x:Name="CheckForUpdateButton"
            Style="{StaticResource AccentButtonStyle}" Margin="0,0,15,0"
                                Click="CheckForUpdateButton_Click"
                                ToolTipService.ToolTip="Will download and install the latest version from the GitHub repository. The time it takes depends on your network connection. Approxmitate download size is 85 MB."/>

                    </controls:WrapPanel>

                </controls:SettingsCard>


                <controls:SettingsCard Description="Automatically checks for update when the app launches and notify you if a new version is available so you can use this page to install it."
Header="Auto Update Check" HeaderIcon="{ui:FontIcon Glyph=&#xE774;}" IsClickEnabled="True" Click="AutoUpdateCheckToggleSettingsCard_Click" IsActionIconVisible="False">
                    <ToggleSwitch x:Name="AutoUpdateCheckToggle" Toggled="AutoUpdateCheckToggle_Toggled"/>
                </controls:SettingsCard>

                <controls:SettingsCard Description="When this option is enabled, the temporary private key of the on-device generated certificate will be linked to the user's account, requiring confirmation of prompts before it can be used for signing."
Header="Hardened Update Procedure" HeaderIcon="{ui:FontIcon Glyph=&#xF552;}" IsClickEnabled="True" IsActionIconVisible="False" Click="HardenedUpdateProcedureToggleSettingsCard_Click">
                    <ToggleSwitch x:Name="HardenedUpdateProcedureToggle" Toggled="HardenedUpdateProcedureToggle_Toggled" />
                </controls:SettingsCard>

            </StackPanel>

        </Grid>

    </ScrollViewer>

</Page>
