private void OnAddUnitConfigExecute(object obj) { IUnitConfigEditViewModel unitConfigEditVm = _unitConfigEditViewModelCreator(); UnitConfigEditViewModels.Add(unitConfigEditVm); unitConfigEditVm.Load(); SelectedUnitConfigEditViewModel = unitConfigEditVm; }
// @@ Method is not used, so clean up public void OnClosing(CancelEventArgs e) { if (UnitConfigEditViewModels.Any(u => u.UnitConfig.IsChanged)) { var result = messageDialogService.ShowYesNoDialog("Close application?", "You'll lose your changes if you close this application. Close it?", MessageDialogResult.No); e.Cancel = result == MessageDialogResult.No; } }
private void OnUnitConfigDeleted(int unitConfigId) { IUnitConfigEditViewModel unitConfigDetailVmToClose = UnitConfigEditViewModels.SingleOrDefault(u => u.UnitConfig.Id == unitConfigId); if (unitConfigDetailVmToClose != null) { UnitConfigEditViewModels.Remove(unitConfigDetailVmToClose); } }
public bool IsUnsavedChanges() { bool isUnsavedChanges = false; if (UnitConfigEditViewModels.Any(u => u.UnitConfig.IsChanged)) { isUnsavedChanges = true; } return(isUnsavedChanges); }
private void OnOpenUnitConfigTab(int unitConfigId) { IUnitConfigEditViewModel unitConfigEditVm = UnitConfigEditViewModels.SingleOrDefault(vm => vm.UnitConfig.Id == unitConfigId); if (unitConfigEditVm == null) { unitConfigEditVm = _unitConfigEditViewModelCreator(); UnitConfigEditViewModels.Add(unitConfigEditVm); unitConfigEditVm.Load(unitConfigId); } SelectedUnitConfigEditViewModel = unitConfigEditVm; }
private void OnCloseUnitConfigTabExecute(object parameter) { var unitConfigEditVmToClose = parameter as IUnitConfigEditViewModel; if (unitConfigEditVmToClose != null) { if (unitConfigEditVmToClose.UnitConfig.IsChanged) { var result = messageDialogService.ShowYesNoDialog("Close tab?", "You'll lose your changes if you close this tab. Close it?", MessageDialogResult.No); if (result == MessageDialogResult.No) { return; } } UnitConfigEditViewModels.Remove(unitConfigEditVmToClose); } }