mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2025-08-16 23:31:43 +02:00
BackupEssentials
Backup
Controls
Data
Pages
HomeSub
About.xaml
About.xaml.cs
Backup.xaml
Backup.xaml.cs
BackupDrop.xaml
BackupDrop.xaml.cs
BackupEdit.xaml
BackupEdit.xaml.cs
History.xaml
History.xaml.cs
Home.xaml
Home.xaml.cs
IPageDragDrop.cs
IPageResetUI.cs
IPageShowData.cs
IPageSwitchHandler.cs
Settings.xaml
Settings.xaml.cs
Properties
Resources
Sys
Utils
App.xaml
App.xaml.cs
AppPageManager.cs
BackupEssentials.csproj
BackupReportWindow.xaml
BackupReportWindow.xaml.cs
BackupWindow.xaml
BackupWindow.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
TestingWindow.xaml
TestingWindow.xaml.cs
.gitignore
BackupEssentials.sln
LICENSE
README.md
76 lines
2.8 KiB
C#
76 lines
2.8 KiB
C#
using BackupEssentials.Backup.Data;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace BackupEssentials.Pages{
|
|
public partial class BackupDrop : Page, IPageShowData{
|
|
private Type PrevPageType;
|
|
private string[] FileList;
|
|
private bool CompatMode;
|
|
private bool Running;
|
|
|
|
public BackupDrop(){
|
|
InitializeComponent();
|
|
|
|
LocationsListView.Items.Clear();
|
|
LocationsListView.ItemsSource = DataStorage.BackupLocationList;
|
|
}
|
|
|
|
void IPageShowData.OnShow(object data){
|
|
Object[] array = (Object[])data;
|
|
FileList = (string[])array[0];
|
|
PrevPageType = (Type)array[1];
|
|
CompatMode = array.Length >= 3 && (bool)array[2];
|
|
|
|
if (CompatMode)PrevPageType = typeof(Home);
|
|
}
|
|
|
|
private void ListViewSelectionChanged(object sender, SelectionChangedEventArgs e){
|
|
ButtonBackup.IsEnabled = LocationsListView.SelectedItems.Count == 1;
|
|
}
|
|
|
|
private void ClickBackup(object sender, RoutedEventArgs e){
|
|
if (FileList.Length == 0 || Running)return;
|
|
|
|
if (FileList.Length == 1 && FileList[0].EndsWith(@":\",StringComparison.Ordinal)){
|
|
if (MessageBox.Show(App.Window,Sys.Settings.Default.Language["BackupDrop.DriveBackupWarning",Path.GetFileName(DataStorage.BackupLocationList[LocationsListView.SelectedIndex].Directory)],Sys.Settings.Default.Language["BackupDrop.DriveBackupWarning.Title"],MessageBoxButton.YesNo,MessageBoxImage.Asterisk) != MessageBoxResult.Yes)return;
|
|
}
|
|
|
|
for(int a = 0; a < FileList.Length; a++){
|
|
if (FileList[a][FileList[a].Length-1] == '\\')FileList[a] += '\\';
|
|
}
|
|
|
|
Process newProcess = new Process();
|
|
newProcess.StartInfo.Arguments = "-runshell -nohide -locid "+LocationsListView.SelectedIndex+" -src \""+string.Join("\" \"",FileList)+"\"";
|
|
newProcess.StartInfo.FileName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
|
|
newProcess.EnableRaisingEvents = true;
|
|
newProcess.Start();
|
|
|
|
if (CompatMode){
|
|
MainWindow.Instance.Close();
|
|
return;
|
|
}
|
|
|
|
newProcess.Exited += (sender2, args2) => {
|
|
if (newProcess.ExitCode == 0){
|
|
Dispatcher.Invoke(new Action(() => {
|
|
MainWindow.Instance.ShowPage(PrevPageType,MainWindow.IgnoreShowData);
|
|
}));
|
|
}
|
|
|
|
Running = false;
|
|
};
|
|
|
|
Running = true;
|
|
}
|
|
|
|
private void ClickCancel(object sender, RoutedEventArgs e){
|
|
MainWindow.Instance.ShowPage(PrevPageType,MainWindow.IgnoreShowData);
|
|
}
|
|
}
|
|
}
|