private void CheckAlgorithmSize(object sender, RoutedEventArgs e) { var dialog = new MyDialog(); if (dialog.ShowDialog() == true) { if (CheckBoxSize.IsChecked == true) { _size = Convert.ToDouble(dialog.ResponseText); } } }
private void CheckAlgorithmDate(object sender, RoutedEventArgs e) { var dialog = new MyDialog(); if (dialog.ShowDialog() == true) { if (CheckBoxDate.IsChecked == true) { _seconds = Convert.ToInt32(dialog.ResponseText); } } }
private void DeletePointsByDate(object sender, RoutedEventArgs e) { string sub = BackupList.SelectedItem.ToString(); int id = GetSelectedID(sub); var dialog = new MyDialog(); if (dialog.ShowDialog() == true) { var ids = _backups[id].DeletePointsByDate( DateTime.Now.AddSeconds(-Convert.ToInt32(dialog.ResponseText))); // Для наглядности try { _backups[id].DeletePoints(ids); } catch (Exception ex) { MessageBox.Show(ex.Message); int idNotToDelete = Convert.ToInt32( MySubString(ex.Message, ex.Message.IndexOf(':') + 1, ex.Message.Length)); for (int i = 0; i < ids.Count; i++) { if (ids[i] == idNotToDelete) { ids.Remove(ids[i]); break; } } } foreach (var i in ids) // Удалить физические копии { Regex pattern = new Regex($@"RestorePoint_{i}(\w*)"); var files = Directory.GetFiles($"{App.DESTINATION_PATH}_{id + 1}") .Where(path => pattern.IsMatch(path)); foreach (var f in files) { if (File.Exists(f)) { File.Delete(f); } } } } }