<!--
Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->

<UserControl x:Class="WPinternals.BackupView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WPinternals"
             mc:Ignorable="d" 
             d:DesignWidth="700">
    <UserControl.Resources>
        <local:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter" />
    </UserControl.Resources>
    <StackPanel VerticalAlignment="Center">
        <Border BorderThickness="1" BorderBrush="#FFD4D4D4" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0,0,0,20">
            <StackPanel>
                <local:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,0,20,0" VerticalScrollBarVisibility="Auto" >
                    <FlowDocument FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left">
                        <FlowDocument.Resources>
                            <!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
                            <Style TargetType="{x:Type Paragraph}">
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                            <Style TargetType="{x:Type Section}">
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                        </FlowDocument.Resources>
                        <local:Paragraph>
                            <Run Text="Backup to archive" FontSize="18" FontWeight="Bold" Foreground="#FF3753A6" />
                            <LineBreak />
                            <LineBreak />
                            <Run Text="Before you can make a backup of the phone, you need to have Mass Storage mode " />
                            <Hyperlink NavigateUri="UnlockBoot">unlocked</Hyperlink>
                            <Run Text=" on the phone first. Make sure you don't have any Windows Phone disks or partitions mounted before you continue to Mass Storage Mode. While in Mass Storage Mode, the phone-battery will not charge. Creating a backup of the phone in Mass Storage Mode will even drain your battery quite fast. Before you continue, make sure the phone is fully charged, or else the phone may reboot before the backup is complete." />
                            <LineBreak />
                            <LineBreak />
                            <local:FilePicker Caption="Archive: " SelectionText="Select the target-file for backup..." Path="{Binding ArchivePath, Mode=TwoWay}" DefaultFileName="Backup.zip" SaveDialog="True" HorizontalAlignment="Stretch" PathChanged="FilePicker_PathChanged"/>
                            <LineBreak />
                            <LineBreak />
                            <local:CollapsibleRun Text="You have to connect your phone before you can continue." IsVisible="{Binding IsPhoneDisconnected, Mode=OneWay}"/>
                            <local:CollapsibleRun Text="When you continue, the phone will be switched to Mass Storage mode and then a backup will be made from the selected partitions." IsVisible="{Binding IsPhoneInOtherMode, Mode=OneWay}"/>
                            <local:CollapsibleRun Text="The phone is in Mass Storage mode. You can continue to make a backup." IsVisible="{Binding IsPhoneInMassStorage, Mode=OneWay}"/>
                        </local:Paragraph>
                    </FlowDocument>
                </local:FlowDocumentScrollViewerNoMouseWheel>
                <StackPanel Orientation="Horizontal" Width="Auto" Height="Auto" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,40,25">
                    <Button Command="{Binding Path=BackupArchiveCommand, Mode=OneWay}" Content="Backup phone" Width="120" Height="Auto" Padding="0,5" />
                </StackPanel>
            </StackPanel>
        </Border>
        <Border BorderThickness="1" BorderBrush="#FFD4D4D4" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0,0,0,0">
            <StackPanel>
                <local:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,0,20,0" VerticalScrollBarVisibility="Auto" >
                    <FlowDocument FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left">
                        <FlowDocument.Resources>
                            <!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
                            <Style TargetType="{x:Type Paragraph}">
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                            <Style TargetType="{x:Type Section}">
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                        </FlowDocument.Resources>
                        <local:Paragraph>
                            <Run Text="Backup separate partitions" FontSize="18" FontWeight="Bold" Foreground="#FF3753A6" />
                            <LineBreak />
                            <LineBreak />
                            <Run Text="When you experiment with the OS or flash Custom ROM's you can make a backup of the MainOS partition and Data partition, so you can revert to an earlier state. Remember that the MainOS partition and Data partition are tied together. So you always need to backup or restore the MainOS partition and Data partition together. Select one or more target-files for backup." />
                            <LineBreak />
                            <LineBreak />
                            <local:FilePicker Caption="EFIESP: " SelectionText="Select the target-file for backup of the EFIESP partition..." Path="{Binding EFIESPPath, Mode=TwoWay}" AllowNull="True" SaveDialog="True" DefaultFileName="EFIESP.bin" HorizontalAlignment="Stretch" PathChanged="FilePicker_PathChanged"/>
                            <LineBreak />
                            <LineBreak />
                            <local:FilePicker Caption="MainOS: " SelectionText="Select the target-file for backup of the MainOS partition..." Path="{Binding MainOSPath, Mode=TwoWay}" AllowNull="True" SaveDialog="True" DefaultFileName="MainOS.bin" HorizontalAlignment="Stretch" PathChanged="FilePicker_PathChanged"/>
                            <LineBreak />
                            <LineBreak />
                            <local:FilePicker Caption="Data: " SelectionText="Select the target-file for backup of the Data partition..." Path="{Binding DataPath, Mode=TwoWay}" AllowNull="True" SaveDialog="True" DefaultFileName="Data.bin" HorizontalAlignment="Stretch" PathChanged="FilePicker_PathChanged"/>
                            <LineBreak />
                            <LineBreak />
                            <local:CollapsibleRun Text="You have to connect your phone before you can continue." IsVisible="{Binding IsPhoneDisconnected, Mode=OneWay}"/>
                            <local:CollapsibleRun Text="When you continue, the phone will be switched to Mass Storage mode and then a backup will be made from the selected partitions." IsVisible="{Binding IsPhoneInOtherMode, Mode=OneWay}"/>
                            <local:CollapsibleRun Text="The phone is in Mass Storage mode. You can continue to make a backup." IsVisible="{Binding IsPhoneInMassStorage, Mode=OneWay}"/>
                        </local:Paragraph>
                    </FlowDocument>
                </local:FlowDocumentScrollViewerNoMouseWheel>
                <StackPanel Orientation="Horizontal" Width="Auto" Height="Auto" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,40,25">
                    <Button Command="{Binding Path=BackupCommand, Mode=OneWay}" Content="Backup phone" Width="120" Height="Auto" Padding="0,5" />
                </StackPanel>
            </StackPanel>
        </Border>
    </StackPanel>
</UserControl>
