コード例 #1
0
 private void OnDeleted()
 {
     selectedEvent          = null;
     buttonEdit.IsEnabled   = false;
     buttonRemove.IsEnabled = false;
     LoadEvents();
 }
コード例 #2
0
        private void OnRemindDateUnchecked(object sender, RoutedEventArgs e)
        {
            VehicleEventViewModel viewModel =
                DataContext as VehicleEventViewModel;

            viewModel.RedMileage = null;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private void EventPersisted()
        {
            VehicleEventViewModel vm = DataContext as VehicleEventViewModel;

            vm.CheckingInProgress = false;
            DialogResult          = true;
        }
コード例 #5
0
 private void CheckAndAddIfRequiresAttention(
     VehicleEventViewModel eventViewModel, int threshold)
 {
     if (RequiresAttention(eventViewModel, threshold))
     {
         eventsRequireAttention.Add(eventViewModel);
     }
 }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
 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;
 }
コード例 #9
0
 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;
 }
コード例 #10
0
        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);
                }
            }
        }
コード例 #11
0
 public VehicleEventWindow(VehicleEventViewModel vm)
     : this()
 {
     DataContext = vm;
 }