private void RestoreLastBackup(object parameter) { try { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to restore the last backup?\nYou will loose current windows & sortcuts.", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { string backupFileName = BackupIO.RestoreLastBackup(); if (!string.IsNullOrEmpty(backupFileName)) { // Displaying the result to the user string shortcutsBackupPath = Helper.GetShortcutsBackupPath(); string resultMessage = ""; resultMessage += "Backup " + backupFileName + "\n"; resultMessage += "restored successfully.\n\n"; resultMessage += "To see backups, open \"Restore shortcuts...\" from MDSHO window title context menu."; MessageBox.Show(resultMessage, "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { // If the returnValue from the BackupIO.RestoreLastBackup() was null or empty then there is no backup created yet. string resultMessage = ""; resultMessage += "There are no backups created yet.\n"; resultMessage += "There is nothing to restore from.\n\n"; resultMessage += "To see backups, open \"Restore shortcuts...\" from MDSHO window title context menu."; MessageBox.Show(resultMessage, "Info", MessageBoxButton.OK, MessageBoxImage.Information); } } } catch (Exception ex) { Error.ShowDialog(ex); } }
private void DeleteSpecificBackup(object parameter) { try { string confirmationMessage = "Backup " + FileName + ".\n"; confirmationMessage += "Are you sure you want to delete this backup?\n\n"; confirmationMessage += "This process cannot be undo."; MessageBoxResult messageBoxResult = MessageBox.Show(confirmationMessage, "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { BackupIO.DeleteSpecificBackup(FileName); // Displaying the result to the user string shortcutsBackupPath = Helper.GetShortcutsBackupPath(); string backupFilePath = Path.Combine(shortcutsBackupPath, FileName); if (!File.Exists(backupFilePath)) { // Refresh the datasource ShortcutsVM shortcutsVM = ((App)Application.Current).DataContext; shortcutsVM.BackupVMs = new ObservableCollection <BackupVM>(); shortcutsVM.BackupVMs = BackupIO.GetBackupVMs(); } } } catch (Exception ex) { Error.ShowDialog(ex); } }
private void SetBackups() { try { // Clear old BackupVMs DataContext.BackupVMs = new ObservableCollection <BackupVM>(); // Get backup file names DataContext.BackupVMs = BackupIO.GetBackupVMs(); } catch (Exception ex) { Error.ShowDialog(ex); } }
private void RestoreSpecificBackup(object parameter) { string resultMessage = ""; try { MessageBoxResult messageBoxResult = MessageBox.Show("Backup " + FileName + "\n" + "Are you sure you want to restore to this backup?\n\n" + "You will loose current windows & sortcuts.", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { BackupIO.RestoreSpecificBackup(FileName); // Displaying the result to the user resultMessage += "Backup " + FileName + "\n"; resultMessage += "restored successfully."; MessageBox.Show(resultMessage, "Information", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Error.ShowDialog(ex); } }
private void BackupShortcuts(object parameter) { try { string backupFileName = BackupIO.BackupShortcuts(); string shortcutsBackupPath = Helper.GetShortcutsBackupPath(); string backupFilePath = Path.Combine(shortcutsBackupPath, backupFileName); // Displaying the result to the user if (File.Exists(backupFilePath)) { string resultMessage = ""; resultMessage += "Backup " + backupFileName + "\n"; resultMessage += "created successfully.\n\n"; resultMessage += "To see backups, open \"Restore shortcuts...\" from MDSHO window title context menu."; MessageBox.Show(resultMessage, "Information", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Error.ShowDialog(ex); } }