Example #1
0
        private void DeleteClick(object sender, RoutedEventArgs e)
        {
            BackupInfo pinfo = (BackupInfo)lbMain.SelectedItem;

            File.Delete(pinfo.BackupPath);
            Paths.RemoveAt(lbMain.SelectedIndex);
            if (Paths.Count == 0)
            {
                lbMain.ItemsSource = null;
                lbMain.Items.Add("There are no backup files to display...");
            }
        }
Example #2
0
        private void RestoreClick(object sender, RoutedEventArgs e)
        {
            string     path  = SaveFileDialogHelper("Restore Backup");
            BackupInfo pinfo = (BackupInfo)lbMain.SelectedItem;

            if (path == null)
            {
                return;
            }
            using (FileStream stream = new FileStream(pinfo.BackupPath, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    _ = reader.ReadInt32();  // dispose of backup flag
                    _ = reader.ReadString(); // dispose of the filename
                    RestoreBackup(stream, path);
                }
            }
            File.Delete(pinfo.BackupPath);
            DeleteClick(null, null);
        }
Example #3
0
        private void RestoreLoad(object sender, RoutedEventArgs e)
        {
            BackupInfo pinfo = (BackupInfo)lbMain.SelectedItem;

            if (!string.IsNullOrEmpty(App.FilePath))
            {
                if (App.Data.Unsaved)
                {
                    bool?result = VisualHelpers.UnsavedDialog();
                    if (result == null)
                    {
                        return;
                    }
                    if (result == true)
                    {
                        SaveData(App.FilePath);
                    }
                }
            }
            Close();
            LoadingAction(pinfo.BackupPath);
        }