Beispiel #1
0
        private void SetVehicleMarkersSelectionState(
            MapMarkerSelectionStates selectionState,
            IEnumerable <string> excludeVehicles = null)
        {
            foreach (var vehicleId in _vehicles.Keys)
            {
                VehicleViewModel vehicleVM = null;
                _vehicles.TryGetValue(vehicleId, out vehicleVM);
                if (vehicleVM == null || (excludeVehicles != null && excludeVehicles.Contains(vehicleId)))
                {
                    continue;
                }

                vehicleVM.SelectionState = selectionState;
            }
        }
Beispiel #2
0
 private void UpdateVehicles(IEnumerable <VehicleLocationUpdate> updates)
 {
     foreach (var vehicleUpdate in updates)
     {
         VehicleViewModel vehicleVM = null;
         _vehicles.TryGetValue(vehicleUpdate.Vehicle.Id, out vehicleVM);
         if (vehicleVM != null)
         {
             this.UpdateVehicleVM(vehicleVM, vehicleUpdate);
         }
         else
         {
             var vm = this.CreateVehicleVM(vehicleUpdate);
             if (vm != null)
             {
                 _vehicles.Add(vehicleUpdate.Vehicle.Id, vm);
             }
         }
     }
 }
Beispiel #3
0
        private void SelectVehicle(string vehicleId)
        {
            if (string.IsNullOrEmpty(vehicleId))
            {
                _selectedVehicle = null;
                this.SetVehicleMarkersSelectionState(MapMarkerSelectionStates.NoSelection, null);
            }

            VehicleViewModel vehicleVM;

            _vehicles.TryGetValue(vehicleId, out vehicleVM);
            if (vehicleVM == null)
            {
                return;
            }

            _selectedVehicle = vehicleVM;
            _selectedVehicle.SelectionState = MapMarkerSelectionStates.SelectionSelected;

            this.SetVehicleMarkersSelectionState(MapMarkerSelectionStates.SelectionNotSelected, new[] { _selectedVehicle.Model.Id });

            var requestedBy = new MvxRequestedBy(MvxRequestedByType.UserAction, "map_tap");
            var navParams   = new
            {
                id               = _selectedVehicle.VehicleId,
                carPlate         = _selectedVehicle.CarPlate,
                vehicleType      = _selectedVehicle.VehicleType,
                routeId          = _selectedVehicle.Model.RouteInfo.RouteId,
                routeNumber      = _selectedVehicle.Model.RouteInfo.RouteNumber,
                routeDisplayName = _selectedVehicle.Model.RouteInfo.DisplayName,
                runUpdates       = true
            };

            this.ShowViewModel <VehicleForecastViewModel>(navParams, null, requestedBy);

            //TODO: center map view on vehicle
            //this.CenterMap(_selectedVehicle.Location.Position);
        }
 public VehicleSelectedEventArgs(VehicleViewModel vehicle)
 {
     this.Vehicle = vehicle;
 }
Beispiel #5
0
 private void UpdateVehicleVM(VehicleViewModel vehicleVM, VehicleLocationUpdate locationUpdate)
 {
     vehicleVM.AnimateMovement = this.IsAnimationEnabled(this.Zoom);
     vehicleVM.Update(locationUpdate);
 }