Esempio n. 1
0
 public usrGPSTrackerEntry()
 {
     InitializeComponent();
     viewModel   = new GPSTrackerViewModel();
     DataContext = viewModel;
     PropertyChangedEventManager.AddListener(UserContext.Current, this, string.Empty);
     updateMapMode();
 }
Esempio n. 2
0
        public void Fill(GPSTrackerViewModel viewModel, bool centerMap = true)
        {
            Children.Clear();

            //Color routeColor = Colors.Blue;
            //SolidColorBrush routeBrush = new SolidColorBrush(routeColor);
            //var routeLine = new MapPolyline();
            //routeLine.Locations = new LocationCollection();
            //routeLine.Stroke = routeBrush;
            //routeLine.Opacity = 0.50;
            //routeLine.StrokeThickness = 5.0;


            //MapLayer myRouteLayer = new MapLayer();
            //Children.Add(myRouteLayer);

            //// Add the route line to the new layer.
            //myRouteLayer.Children.Add(routeLine);
            //foreach (var gpsPoint in points)
            //{
            //    routeLine.Locations.Add(gpsPoint.ToLocation());
            //}

            var myRouteLayer = new MapLayer();

            Children.Add(myRouteLayer);
            lapsLayer        = new MapLayer();
            selectedLapLayer = new MapLayer();
            Children.Add(selectedLapLayer);
            Children.Add(lapsLayer);
            // Add the route line to the new layer.
            var routeLine = createMapLine(myRouteLayer);
            var firstLine = routeLine;

            for (int index = 0; index < viewModel.GPSPoints.Count; index++)
            {
                var gpsPoint = viewModel.GPSPoints[index];
                if (gpsPoint.Point.IsPoint())
                {
                    routeLine.Locations.Add(gpsPoint.ToLocation());
                }
                else if (routeLine.Locations != null && routeLine.Locations.Count > 0)
                {
                    routeLine = createMapLine(myRouteLayer);
                }
            }

            //add laps start-end points
            foreach (var lapViewModel in viewModel.Laps)
            {
                Pushpin pin = new Pushpin();
                pin.Content  = lapViewModel.Nr;
                pin.Location = lapViewModel.EndPoint.ToLocation();
                pin.ToolTip  = new usrLapPushpinInfo(lapViewModel);
                lapsLayer.Children.Add(pin);
            }

            var correctPoints = viewModel.GPSPoints.Where(x => x.Point.IsPoint());

            if (centerMap)
            {
                mapBounds = new LocationRect(
                    correctPoints.Max((p) => p.Point.Latitude),
                    correctPoints.Min((p) => p.Point.Longitude),
                    correctPoints.Min((p) => p.Point.Latitude),
                    correctPoints.Max((p) => p.Point.Longitude));
                //map.SetView(mapBounds);//here we got exception so moved this line to SizeChanged event
                Center = firstLine.Locations.FirstOrDefault();
            }
            updateLapsLayer();

            //add finish image (flag at the end of track)
            var startImg = new Image();

            startImg.Source = "pack://application:,,,/BodyArchitect.Client.Module.GPSTracker;component/Resources/Start16.png".ToBitmap();
            startImg.Width  = 16;
            startImg.Height = 16;
            myRouteLayer.AddChild(startImg, correctPoints.Last().ToLocation());
        }