private void saveNewTask(object parameter) { Tasks.Add(new Task { Title = _addWindow.titleTB.Text, TaskDescription = _addWindow.descTB.Text, Periodicity = (Periodicity)Enum.Parse(typeof(Periodicity), _addWindow.periodicityCB.Text), TaskCategory = (Category)Enum.Parse(typeof(Category), _addWindow.categoryCB.Text), TaskPriority = (Priority)Enum.Parse(typeof(Priority), _addWindow.priorityCB.Text) }); _fileIOService.SaveData(Tasks); _addWindow.Close(); }
//Методи, що відповідають за те, що роблять команди, та чи можуть вони виконуватися private void OnOpenSaveDialogAppCommandExecuted(object p) { SaveFile = new SaveFileDialog(); SaveFile.ShowDialog(); fileio = new FileIOService(SaveFile.FileName + ".json"); fileio.SaveData(Data.GetDataCopy()); }
public void SetTheAlarmClick(object obj) { var service = new FileIOService(path); var alarms = service.LoadData(); alarms.Add(this.alarm); service.SaveData(alarms); MessageBox.Show("New alarm clock added!"); }
private void SetTheAllarm_Click(object sender, RoutedEventArgs e) { var alarmList = fileIOService.LoadData(); alarmList.Add(new Alarm { Days = SelectedDays, Hours = hours, Minutes = minutes }); fileIOService.SaveData(alarmList); MessageBox.Show("New alarm clock added!"); }
static App() { IOService = new FileIOService <UserSettingsViewModel>($"{Environment.CurrentDirectory}\\Settings.json"); UserSettings = IOService.LoadSettings(); if (UserSettings == null) { UserSettings = new UserSettingsViewModel(); IOService.SaveData(UserSettings); } }
public void Save() { try { FileIOService.SaveData(TasksDataDictionary); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void TaskListData_ListChanged(object sender, ListChangedEventArgs e) { try { _fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Environment.Exit(0); } }
private void ToDoList_ListChanged(object sender, ListChangedEventArgs e) { try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
public void AlarmsList_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { FileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void _tradeData_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _fileIOService.SaveData(sender); }catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } } }
private void Recepts_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)//для отслеживания изменений { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { switch (recepts[e.NewStartingIndex].type)//проверяю какого типа новый добавленный рецепт { case "one": recepts_one.Add(recepts[e.NewStartingIndex]); break; case "two": recepts_two.Add(recepts[e.NewStartingIndex]); break; case "salat": recepts_salat.Add(recepts[e.NewStartingIndex]); break; case "desert": recepts_desert.Add(recepts[e.NewStartingIndex]); break; default: break; } _fileIOService.SaveData(recepts); } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { _fileIOService.SaveData(recepts);//сохраняю изменения recepts_one.Clear(); recepts_two.Clear(); recepts_salat.Clear(); recepts_desert.Clear(); sort(); } }
private void ToDoModelsListOnListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemChanged || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemMoved) { try { _fileService.SaveData((BindingList <ToDoModel>)sender); } catch (Exception exception) { MessageBox.Show(exception.Message); this.Close(); } } }
private void _CompareNumDataList_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.PropertyDescriptorDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } } }
private void _schedulerDataList_ListChanged(Object sender, ListChangedEventArgs e) // Обработчик события ListChanged { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } } }
private void SaveCommandMethod() { if (LibraryList != null) { try { fileIOService.SaveData(LibraryList); MessageBox.Show("Сохранено в файл", "Сохранение данных", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void ToReadBookList_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } dgToReadList.ItemsSource = _ToReadBookList; _ToReadBookList.ListChanged += ToReadBookList_ListChanged; } }
/// <summary> /// Подписывается на событие ToDoDataList_CollectionChanged. /// При обновлении информации в списке, вызывается событие /// </summary> /// <param name="sender">Список, который передается в событие</param> /// <param name="e">События</param> private void ToDoDataList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { ///Проверка на выпадение исключения. ///Если cохранить файл не удается, покажется окно с ошибкой и закроется окно try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } } }
private void _toDoDataList_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } } //switch (e.ListChangedType) //{ // case ListChangedType.Reset: // break; // case ListChangedType.ItemAdded: // break; // case ListChangedType.ItemDeleted: // break; // case ListChangedType.ItemMoved: // break; // case ListChangedType.ItemChanged: // break; // case ListChangedType.PropertyDescriptorAdded: // break; // case ListChangedType.PropertyDescriptorDeleted: // break; // case ListChangedType.PropertyDescriptorChanged: // break; // default: // break; //} }
private void btnSave_Click(object sender, EventArgs e) { FileIOService.SaveData(events, PATH); }
private void ToDoData_ListChanged(object sender, ListChangedEventArgs e) { switch (e.ListChangedType) { case ListChangedType.Reset: try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } break; case ListChangedType.ItemAdded: try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } break; case ListChangedType.ItemChanged: try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } break; case ListChangedType.ItemDeleted: try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } break; case ListChangedType.ItemMoved: try { fileIOService.SaveData(sender); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } break; case ListChangedType.PropertyDescriptorAdded: break; case ListChangedType.PropertyDescriptorChanged: break; case ListChangedType.PropertyDescriptorDeleted: break; default: break; } }