private void NewImitationTrackGpsDevicesDataGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (Player.Timer != null && Player.Timer.IsEnabled) { Player.Timer.Stop(); } Player.CurrentPlayPauseState = false; var obj = (GpsDevice)NewImitationTrackGpsDevicesDataGrid.SelectedItem; Player.CurrentPosition = obj.CurrentTrackPosition; if (TrackPositions.Any() && Player.CurrentPosition < TrackPositions.Count) { if (!MainMap.Children.Contains(_pinCar)) { MainMap.Children.Add(_pinCar); } var point = TrackPositions[Player.CurrentPosition]; _pinCar.Location = new Location(point.Latitude, point.Longitude); } }
private void Timer_Tick(object sender, EventArgs e) { if (TrackPositions.Any() && Player.CurrentPosition < TrackPositions.Count) { if (!MainMap.Children.Contains(_pinCar)) { MainMap.Children.Add(_pinCar); } var point = TrackPositions[Player.CurrentPosition]; _pinCar.Location = new Location(point.Latitude, point.Longitude); TrackPositionsDataGrid.SelectRowByIndex(Player.CurrentPosition); Player.CurrentPosition++; if (NewImitationTrackGpsDevicesDataGrid.Items.Count > 0 && NewImitationTrackGpsDevicesDataGrid.SelectedIndex != -1) { var device = (GpsDevice)NewImitationTrackGpsDevicesDataGrid.SelectedItem; var devIndex = NewGpsDevices.IndexOf(device); NewGpsDevices[devIndex].CurrentTrackPosition = Player.CurrentPosition; } } else { Player.Timer.Stop(); Player.CurrentPlayPauseState = false; } }
private bool Check2TabInfo() { if (!TrackPositions.Any()) { return(false); } return(true); }
private async Task InitAndDrowTrack(TrackPosition[] points) { TrackPositions.Clear(); MapPolyline.Locations?.Clear(); Player.CurrentPosition = 0; if (points == null || !points.Any()) { LogWindowControl.AddMessage($"No data..."); return; } TrackPositions.AddRange(points); if (points.Any()) { foreach (var device in NewGpsDevices) { device.TrackPositionsCount = TrackPositions.Count; } } if (!TrackPositions.Any()) { foreach (var device in NewGpsDevices) { device.TrackPositionsCount = 0; } return; } LogWindowControl.AddMessage($"Loaded {TrackPositions.Count} points."); LogWindowControl.AddMessage($"Drowing route..."); MapPolyline.Locations = await ConvertTrackPositionsToLocations(TrackPositions); MainMap.Center = MapPolyline.Locations.FirstOrDefault(); _pinStart.Location = MapPolyline.Locations.First(); _pinEnd.Location = MapPolyline.Locations.Last(); _pinCar.Location = MapPolyline.Locations.First(); if (!MainMap.Children.Contains(_pinStart)) { MainMap.Children.Add(_pinStart); } if (!MainMap.Children.Contains(_pinEnd)) { MainMap.Children.Add(_pinEnd); } LogWindowControl.AddMessage($"Completed"); CheckTabItems(); }