Example #1
0
        // Update
        public bool FinishTrip(double counterEnd, double counterEndDecimal)
        {
            bool success = false;

            Debug.WriteLine("TMVM: Finishing trip...");

            if (counterEndDecimal <= 0)
            {
                counterEndDecimal = 0;
            }


            string counterString = counterEnd + "." + counterEndDecimal;
            double counter       = Convert.ToDouble(counterString, CultureInfo.InvariantCulture);

            counter = Math.Round(counter, 1);

            if (counter > currentTrip.CounterStart)
            {
                counterEnd             = Math.Round(counter, 1);
                currentTrip.CounterEnd = counter;
                tripManager.Update(currentTrip);
                currentTrip = null;
                success     = true;
            }
            else
            {
                // Give error
                f**k.ShowErrorDialog("Message-WrongAmount");
            }

            return(success);
        }
Example #2
0
        // Add
        public void AddNewTrip(int carId, double counterStart, double counterStartDecimal)
        {
            Debug.WriteLine("TMVM: Add new trip...");
            TripViewModel tripViewModel = new TripViewModel();

            // Get Car ID and add that to the trip
            tripViewModel.CarId = carId;

            if (counterStartDecimal <= 0)
            {
                counterStartDecimal = 0;
            }

            string counterString = counterStart + "." + counterStartDecimal;
            double counter       = Convert.ToDouble(counterString, CultureInfo.InvariantCulture);

            counter = Math.Round(counter, 1);
            tripViewModel.CounterStart = counter;

            tripManager.Add(tripViewModel);
            this._Trips.Add(tripViewModel);
            this._SelectedIndex = this._Trips.IndexOf(tripViewModel);

            tripViewModel.PropertyChanged += Trip_OnNotifyPropertyChanged;

            // Update Total distance
            Debug.WriteLine("Trip ID: " + tripViewModel.TripId);
            Debug.WriteLine("GrandTotalDistance: " + this.TotalDistance.ToString());
        }
Example #3
0
 // Delete all trips
 public void DeleteAll()
 {
     try
     {
         foreach (TripViewModel trip in _Trips)
         {
             tripManager.Delete(trip);
         }
         _Trips.Clear();
         currentTrip = null;
         Debug.WriteLine("TMVM: Deleted all trips!");
     }
     catch { Debug.WriteLine("TMVM: Coudn't delete all trips :("); }
 }
Example #4
0
        public void GetTrips(int carId)
        {
            tripManager    = new TripManager(carId);
            _SelectedIndex = -1;

            _Trips.Clear();
            foreach (var trip in tripManager.Trips)
            {
                var newTrip = new TripViewModel(trip);
                newTrip.PropertyChanged += Trip_OnNotifyPropertyChanged;

                // Check whether the End-Distance has been filled in. If not, don't add it to the list, but add is as current car
                if (newTrip.CounterEnd != 0)
                {
                    _Trips.Add(newTrip);
                }
                else
                {
                    currentTrip = newTrip;
                }
            }
        }
Example #5
0
        // Delete single trip from list
        public bool Delete(TripViewModel tripToDelete)
        {
            bool success = false;

            Debug.WriteLine("TMVM: Delete single Trip - Starting attempt");

            try
            {
                this.tripManager.Delete(tripToDelete);
                this._Trips.Remove(tripToDelete);
                this._SelectedIndex = -1;
                Debug.WriteLine("TMVM: Delete single Trip - Successful");
                success = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("TMVM: Delete single Trip - Failed");
                Debug.WriteLine("Error: " + ex);
            }


            return(success);
        }