Beispiel #1
0
        private VehicleViewModel CreateVehicleVM(VehicleLocationUpdate locationUpdate)
        {
            try
            {
                var vehicleVM = Mvx.IocConstruct <VehicleViewModel>();
                vehicleVM.Model           = locationUpdate.Vehicle;
                vehicleVM.MarkerSize      = _markerSize;
                vehicleVM.AnimateMovement = this.IsAnimationEnabled(this.Zoom);
                vehicleVM.IsTitleVisible  = this.IsVehicleTitleMarkerVisible(this.Zoom);

                if (_selectedVehicle != null)
                {
                    vehicleVM.SelectionState = MapMarkerSelectionStates.SelectionNotSelected;
                }
                else
                {
                    vehicleVM.SelectionState = MapMarkerSelectionStates.NoSelection;
                }

                return(vehicleVM);
            }
            catch (Exception e)
            {
                Insights.Report(e);
                return(null);
            }
        }
Beispiel #2
0
        public void Update(VehicleLocationUpdate update)
        {
            lock (_animationLock)
            {
                if (_lastUpdate > 0)
                {
                    if (update.Waypoints != null && update.Waypoints.Waypoints.Any())
                    {
                        _path.Enqueue(
                            new PathSegment
                        {
                            Duration      = TimeSpan.FromSeconds(update.Waypoints.Waypoints[0].Fraction * SegmentTravelTime),
                            StartLocation = this.Location,
                            FinalLocation = update.Waypoints.Waypoints[0].Location
                        });

                        for (var i = 0; i < update.Waypoints.Waypoints.Count - 1; i++)
                        {
                            _path.Enqueue(
                                new PathSegment
                            {
                                Duration      = TimeSpan.FromSeconds(update.Waypoints.Waypoints[i + 1].Fraction * SegmentTravelTime),
                                StartLocation = update.Waypoints.Waypoints[i].Location,
                                FinalLocation = update.Waypoints.Waypoints[i + 1].Location
                            });
                        }
                        ;
                    }
                    else
                    {
                        if (!this.Location.Equals(GeoLocation.Empty))
                        {
                            _path.Enqueue(
                                new PathSegment
                            {
                                Duration      = TimeSpan.FromSeconds(SegmentTravelTime),
                                StartLocation = this.Location,
                                FinalLocation = update.Vehicle.Location
                            });
                        }
                    }
                }
            }

            _lastUpdate = update.LastUpdated.Ticks;
            this.RaisePropertyChanged(() => this.LastUpdate);
            this.SetLocation(update.Vehicle.Location);

            this.RunAnimation();
        }
Beispiel #3
0
 private void UpdateVehicleVM(VehicleViewModel vehicleVM, VehicleLocationUpdate locationUpdate)
 {
     vehicleVM.AnimateMovement = this.IsAnimationEnabled(this.Zoom);
     vehicleVM.Update(locationUpdate);
 }