|
|
@@ -34,6 +34,7 @@ namespace barry
|
|
|
|
|
|
bkp = current_bkp;
|
|
|
|
|
|
+ lbl_drive.Content = methods.current_drive_letter();
|
|
|
txt_path.Text = bkp.dir_path;
|
|
|
txt_subdir.Text = bkp.local_subdir;
|
|
|
for (int i = 0; i < cb_bkptype.Items.Count; i++)
|
|
|
@@ -48,6 +49,12 @@ namespace barry
|
|
|
|
|
|
private void btn_save_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
+ string diag = bkp.checkup();
|
|
|
+ if (diag.Length > 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show(diag, "Check-Up", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
|
+ return;
|
|
|
+ }
|
|
|
methods.save_this_cpu(bkp);
|
|
|
Close();
|
|
|
}
|
|
|
@@ -92,72 +99,14 @@ namespace barry
|
|
|
|
|
|
private void btn_explorecpu_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var dlg = new CommonOpenFileDialog();
|
|
|
- dlg.Title = "Select a directory on your computer";
|
|
|
- dlg.IsFolderPicker = true;
|
|
|
- dlg.InitialDirectory = "";
|
|
|
- dlg.EnsurePathExists = true;
|
|
|
- dlg.ShowPlacesList = true;
|
|
|
-
|
|
|
- if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
|
|
|
- {
|
|
|
- var folder = dlg.FileName;
|
|
|
- Console.WriteLine(folder + " - " + methods.current_drive_letter() + " - " + is_subdir(folder, methods.current_drive_letter()));
|
|
|
- if (is_subdir(folder, methods.current_drive_letter()))
|
|
|
- {
|
|
|
- MessageBox.Show("This directory should NOT be on your usb device", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- txt_path.Text = folder;
|
|
|
- }
|
|
|
- }
|
|
|
+ txt_path.Text = methods.select_directory_dialog("Select a directory on your computer");
|
|
|
}
|
|
|
|
|
|
private void btn_exploredevice_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var dlg = new CommonOpenFileDialog();
|
|
|
- dlg.Title = "Select a directory on your device";
|
|
|
- dlg.IsFolderPicker = true;
|
|
|
- dlg.InitialDirectory = "";
|
|
|
- dlg.EnsurePathExists = true;
|
|
|
- dlg.ShowPlacesList = true;
|
|
|
-
|
|
|
- if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
|
|
|
- {
|
|
|
- var folder = dlg.FileName;
|
|
|
- if (!is_subdir(folder, methods.current_drive_letter()))
|
|
|
- {
|
|
|
- MessageBox.Show("This directory should be on your usb device", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- txt_subdir.Text = folder;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ txt_subdir.Text = methods.select_directory_dialog("Select a directory on your device");
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// is dir1 a subdir of dir2
|
|
|
- /// </summary>
|
|
|
- /// <param name="dir1"></param>
|
|
|
- /// <param name="dir2"></param>
|
|
|
- private bool is_subdir(string dir1, string dir2)
|
|
|
- {
|
|
|
- DirectoryInfo di1 = new DirectoryInfo(dir1);
|
|
|
- DirectoryInfo di2 = new DirectoryInfo(dir2);
|
|
|
- while (di1.Parent != null)
|
|
|
- {
|
|
|
- if (di1.Parent.FullName == di2.FullName)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- else di1 = di1.Parent;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
}
|