예제 #1
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());
        }