private void OnDeleted() { selectedEvent = null; buttonEdit.IsEnabled = false; buttonRemove.IsEnabled = false; LoadEvents(); }
private void OnRemindDateUnchecked(object sender, RoutedEventArgs e) { VehicleEventViewModel viewModel = DataContext as VehicleEventViewModel; viewModel.RedMileage = null; }
private bool RequiresAttention(VehicleEventViewModel eventViewModel, int threshold) { if (!eventViewModel.UseRecurring) { return(false); } int mileageToReplace = eventViewModel.Mileage + eventViewModel.MileageUntilChange; int currentVehicleMileage = eventViewModel.CurrentVehicleMileage; TimeSpan leftUntilNextChange = eventViewModel.Date + TimeSpan. FromDays(eventViewModel.NextReplacementPeriod) - DateTime.Now; double daysLeftUntilNextChange = leftUntilNextChange.TotalDays; if (mileageToReplace - threshold <= currentVehicleMileage || daysLeftUntilNextChange < 30) { if (!allEvents.Any(e => e.Model.Type == eventViewModel.Model.Type && e.Date > eventViewModel.Date)) { return(true); } } return(false); }
private void EventPersisted() { VehicleEventViewModel vm = DataContext as VehicleEventViewModel; vm.CheckingInProgress = false; DialogResult = true; }
private void CheckAndAddIfRequiresAttention( VehicleEventViewModel eventViewModel, int threshold) { if (RequiresAttention(eventViewModel, threshold)) { eventsRequireAttention.Add(eventViewModel); } }
private void EditClicked(object sender, RoutedEventArgs e) { VehicleEventViewModel vm = new VehicleEventViewModel( selectedEvent.Model, selectedVehicle.Model); VehicleEventWindow w = new VehicleEventWindow(vm); w.Closed += DialogWindowStatus.OnDialogClosed; w.Show(); }
private void Error(Exception e, string msg) { VehicleEventViewModel vm = DataContext as VehicleEventViewModel; vm.CheckingInProgress = false; ErrorWindow wnd = new ErrorWindow(e, msg); wnd.Closed += DialogWindowStatus.OnDialogClosed; wnd.Show(); }
private void OnAllItemsGridSelectionChanged( object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) { selectedEvent = null; buttonEdit.IsEnabled = false; buttonRemove.IsEnabled = false; return; } selectedEvent = e.AddedItems[0] as VehicleEventViewModel; buttonEdit.IsEnabled = true; buttonRemove.IsEnabled = true; }
private void OnAllLoaded(List <VehicleEvent> events) { allEvents.Clear(); eventsRequireAttention.Clear(); foreach (VehicleEvent vehicleEvent in events) { VehicleEventViewModel eventViewModel = new VehicleEventViewModel( vehicleEvent, selectedVehicle.Model); allEvents.Add(eventViewModel); CheckAndAddIfRequiresAttention(eventViewModel, 2000); } progressBarCircular.Visibility = Visibility.Collapsed; buttonCreateNew.IsEnabled = true; }
private void OnSaveClicked(object sender, RoutedEventArgs e) { VehicleEventViewModel vm = DataContext as VehicleEventViewModel; vm.CheckingInProgress = true; if (vm.CheckDataConsistency()) { VehicleEventsPersistency po = new VehicleEventsPersistency( EventPersisted, Error); if (vm.Model.Id == 0) { po.Persist(vm.Model); } else { po.Persist(vm.Model); } } }
public VehicleEventWindow(VehicleEventViewModel vm) : this() { DataContext = vm; }