public CarMarker(PointLatLng p, CarMarkerType type) : base(p) { this.Type = type; }
void UpdateSelectionOfCar(bool selected) { if(lastSelectedDriver > 0) { carMarkers[lastSelectedDriver].Type = lastMarkerType; lastSelectedDriver = -1; } if(selected) { var driverId = yTreeViewDrivers.GetSelectedId();; if (carMarkers.ContainsKey(driverId)) { lastSelectedDriver = driverId; lastMarkerType = carMarkers[lastSelectedDriver].Type; carMarkers[lastSelectedDriver].Type = CarMarkerType.BlackCar; } } }
protected CarMarker(SerializationInfo info, StreamingContext context) : base(info, context) { this.type = Extensions.GetStruct <CarMarkerType>(info, "type", CarMarkerType.none); //this.Bearing = Extensions.GetStruct<float>(info, "Bearing", null); }
private bool UpdateCarPosition() { var routesIds = (yTreeViewDrivers.RepresentationModel.ItemsList as IList<Vodovoz.ViewModel.WorkingDriverVMNode>) .SelectMany(x => x.RouteListsIds.Keys).ToArray(); var start = DateTime.Now; var lastPoints = Repository.Logistics.TrackRepository.GetLastPointForRouteLists(uow, routesIds); var movedDrivers = lastPoints.Where(x => x.Time > DateTime.Now.AddMinutes(-20)).Select(x => x.RouteListId).ToArray(); var ere20Minuts = Repository.Logistics.TrackRepository.GetLastPointForRouteLists(uow, movedDrivers, DateTime.Now.AddMinutes(-20)); logger.Debug("Время запроса точек: {0}", DateTime.Now - start); carsOverlay.Clear(); carMarkers = new Dictionary<int, CarMarker>(); foreach(var pointsForDriver in lastPoints.GroupBy(x => x.DriverId)) { var lastPoint = pointsForDriver.OrderBy(x => x.Time).Last(); CarMarkerType iconType; var ere20 = ere20Minuts.Where(x => x.DriverId == pointsForDriver.Key).OrderBy(x => x.Time).LastOrDefault(); if (lastPoint.Time < DateTime.Now.AddMinutes(-20)) { iconType = CarMarkerType.BlueCar; } else if (ere20 != null) { var point1 = new PointLatLng(lastPoint.Latitude, lastPoint.Longitude); var point2 = new PointLatLng(ere20.Latitude, ere20.Longitude); var diff = gmapWidget.MapProvider.Projection.GetDistance(point1, point2); if (diff <= 0.1) iconType = CarMarkerType.RedCar; else iconType = CarMarkerType.GreenCar; } else iconType = CarMarkerType.GreenCar; if(lastSelectedDriver == lastPoint.DriverId) { lastMarkerType = iconType; iconType = CarMarkerType.BlackCar; } var marker = new CarMarker(new PointLatLng(lastPoint.Latitude, lastPoint.Longitude), iconType); var driverRow = (yTreeViewDrivers.RepresentationModel.ItemsList as IList<Vodovoz.ViewModel.WorkingDriverVMNode>) .First(x => x.Id == lastPoint.DriverId); string text = String.Format("{0}({1})", driverRow.ShortName, driverRow.CarNumber); if (lastPoint.Time < DateTime.Now.AddSeconds(-30)) text += lastPoint.Time.Date == DateTime.Today ? String.Format("\nБыл виден: {0:t} ", lastPoint.Time) : String.Format("\nБыл виден: {0:g} ", lastPoint.Time); marker.ToolTipText = text; carsOverlay.Markers.Add(marker); carMarkers.Add(lastPoint.DriverId, marker); } return true; }