1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-06-01 12:34:07 +02:00

Added a report button to backup window and auto-close

This commit is contained in:
chylex 2015-04-06 12:21:38 +02:00
parent 4fab13e3b5
commit adaf5c82ef
2 changed files with 34 additions and 5 deletions

View File

@ -7,7 +7,7 @@
xmlns:custom="clr-namespace:BackupEssentials.Controls"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
mc:Ignorable="d" x:Class="BackupEssentials.BackupWindow"
Title="Backup in progress..." Height="160" Width="640" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="NoResize" Background="#FF000000" AllowsTransparency="True">
Title="Backup in progress..." Height="132" Width="640" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="NoResize" Background="#FF000000" AllowsTransparency="True">
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
@ -23,9 +23,10 @@
<Label x:Name="LabelInfo" Content="Preparing backup..." HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#FFDDDDDD" FontSize="18"/>
<ProgressBar x:Name="ProgressBar" Margin="8,0" Grid.Row="1"/>
<WrapPanel Grid.Row="2" Orientation="Horizontal" Margin="8" HorizontalAlignment="Right">
<Button x:Name="ButtonEnd" Template="{StaticResource ButtonStyleRedDefault}" Content="Cancel" FontSize="16" Click="ButtonEndClick"/>
<WrapPanel Grid.Row="2" Orientation="Horizontal" Margin="8,12,8,0" HorizontalAlignment="Right">
<Button x:Name="ButtonShowReport" Template="{StaticResource ButtonStyleDefault}" Content="Show report" IsEnabled="False" Margin="0,0,8,0" FontSize="16" Click="ButtonShowReportClick" Width="115"/>
<Button x:Name="ButtonEnd" Template="{StaticResource ButtonStyleRedDefault}" Content="Cancel" FontSize="16" Click="ButtonEndClick" Width="85"/>
</WrapPanel>
</Grid>
</DockPanel>

View File

@ -1,13 +1,16 @@
using BackupEssentials.Backup;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Shell;
using System.Windows.Threading;
namespace BackupEssentials{
public partial class BackupWindow : Window{
private BackupRunner Runner;
private int ActionCount;
private DispatcherTimer CloseTimer;
public BackupWindow(BackupRunner runner){
InitializeComponent();
@ -43,6 +46,7 @@ namespace BackupEssentials{
private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e){
Runner = null;
ButtonShowReport.IsEnabled = true;
ButtonEnd.Content = "Close";
if (e.Error != null){
@ -55,12 +59,36 @@ namespace BackupEssentials{
ProgressBar.Value = 100;
ProgressBar.Value = 99; // progress bar animation hack
ProgressBar.Value = 100;
TaskbarItemInfo.ProgressValue = 100;
TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused;
LabelInfo.Content = "Finished! Updated "+ActionCount+" files and folders.";
CloseTimer = new DispatcherTimer();
CloseTimer.Interval = new TimeSpan(0,0,0,0,250);
CloseTimer.Tick += (sender2, args2) => {
if (TaskbarItemInfo.ProgressValue <= 0)Close();
else TaskbarItemInfo.ProgressValue -= 0.02001D;
};
CloseTimer.Start();
}
private void ButtonEndClick(object sender, RoutedEventArgs e){
if (Runner == null)Close();
if (Runner == null){
CloseTimer.Stop();
Close();
}
else Runner.Cancel();
}
private void ButtonShowReportClick(object sender, RoutedEventArgs e){
if (Runner == null){
if (CloseTimer != null){
CloseTimer.Stop();
TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
}
// TODO
}
}
}
}