Пример #1
0
        private static void ShowUserOnMapChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DigiTransitMap _this = d as DigiTransitMap;

            if (_this == null)
            {
                return;
            }

            if (e.NewValue.Equals(e.OldValue))
            {
                return;
            }

            bool newBool = (bool)e.NewValue;

            if (newBool)
            {
                _this.StartLiveUpdates();
            }
            else
            {
                _this.SelfMarker.Visibility = Visibility.Collapsed;
                _this.StopLiveUpdates();
            }
        }
Пример #2
0
        private static void OnColoredCirclesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DigiTransitMap _this = d as DigiTransitMap;

            if (_this == null)
            {
                return;
            }

            var oldCollection = e.OldValue as INotifyCollectionChanged;
            var newCollection = e.NewValue as INotifyCollectionChanged;

            if (oldCollection != null)
            {
                oldCollection.CollectionChanged -= _this.OnColoredCirclesCollectionChanged;
            }
            if (newCollection != null)
            {
                newCollection.CollectionChanged += _this.OnColoredCirclesCollectionChanged;
            }

            var newList = e.NewValue as IEnumerable <ColoredGeocircle>;

            if (newList == null || !newList.Any())
            {
                _this.SetMapPolygons(null);
                return;
            }

            List <MapPolygon> polygons = new List <MapPolygon>();

            foreach (var circle in newList)
            {
                var polygon = new MapPolygon();
                polygon.FillColor       = circle.FillColor;
                polygon.Path            = new Geopath(circle.CirclePoints.Select(x => x.Position));
                polygon.StrokeColor     = circle.StrokeColor;
                polygon.StrokeThickness = circle.StrokeThickness;
                polygons.Add(polygon);
            }
            _this.SetMapPolygons(polygons);
        }
Пример #3
0
        private static void OnIsInteractionEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DigiTransitMap _this = d as DigiTransitMap;

            if (_this == null)
            {
                return;
            }

            bool oldEnabled = (bool)e.OldValue;
            bool newEnabled = (bool)e.NewValue;

            if (oldEnabled == newEnabled)
            {
                return;
            }

            if (newEnabled)
            {
                _this.DigiTransitMapControl.PanInteractionMode    = MapPanInteractionMode.Auto;
                _this.DigiTransitMapControl.ZoomInteractionMode   = MapInteractionMode.Auto;
                _this.DigiTransitMapControl.RotateInteractionMode = MapInteractionMode.Auto;
                _this.DigiTransitMapControl.TiltInteractionMode   = MapInteractionMode.Auto;
                if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Maps.MapControl", "AllowFocusOnInteraction"))
                {
                    _this.DigiTransitMapControl.AllowFocusOnInteraction = true;
                }
            }
            else
            {
                _this.DigiTransitMapControl.PanInteractionMode    = MapPanInteractionMode.Disabled;
                _this.DigiTransitMapControl.ZoomInteractionMode   = MapInteractionMode.Disabled;
                _this.DigiTransitMapControl.RotateInteractionMode = MapInteractionMode.Disabled;
                _this.DigiTransitMapControl.TiltInteractionMode   = MapInteractionMode.Disabled;
                if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Maps.MapControl", "AllowFocusOnInteraction"))
                {
                    _this.DigiTransitMapControl.AllowFocusOnInteraction = false;
                }
            }
        }
Пример #4
0
        private static void ColoredMapLinesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DigiTransitMap _this = d as DigiTransitMap;

            if (_this == null)
            {
                return;
            }

            var oldCollection = e.OldValue as INotifyCollectionChanged;
            var newCollection = e.NewValue as INotifyCollectionChanged;

            if (oldCollection != null)
            {
                oldCollection.CollectionChanged -= _this.OnColoredMapLinePointsCollectionChanged;
            }
            if (newCollection != null)
            {
                newCollection.CollectionChanged += _this.OnColoredMapLinePointsCollectionChanged;
            }

            IList <ColoredMapLine> newValue = e.NewValue as IList <ColoredMapLine>;

            if (newValue == null)
            {
                if (_this.DigiTransitMapControl.MapElements.OfType <MapPolyline>().Any())
                {
                    _this.SetMapLines(null);
                }
                return;
            }

            List <MapPolyline>      newPolylines         = new List <MapPolyline>();
            List <BasicGeoposition> currentLinePositions = new List <BasicGeoposition>();

            foreach (ColoredMapLine lineCollection in newValue)
            {
                for (int i = 0; i <= lineCollection.Count() - 2; i++)
                {
                    var startPoint = lineCollection[i];
                    var nextPoint  = lineCollection[i + 1];
                    currentLinePositions.Add(startPoint.Coordinates);

                    Color nextColor = nextPoint.LineColor;
                    if (nextPoint == lineCollection.Last() || startPoint.LineColor != nextColor)
                    {
                        MapPolyline polyline = new MapPolyline();
                        polyline.Path            = new Geopath(currentLinePositions);
                        polyline.StrokeColor     = Color.FromArgb(192, startPoint.LineColor.R, startPoint.LineColor.G, startPoint.LineColor.B);
                        polyline.StrokeDashed    = startPoint.IsLineDashed;
                        polyline.StrokeThickness = 6;
                        if (lineCollection.OptionalId != Guid.Empty)
                        {
                            MapElementExtensions.SetPoiId(polyline, lineCollection.OptionalId);
                        }
                        newPolylines.Add(polyline);

                        currentLinePositions = new List <BasicGeoposition>();
                    }
                }
            }

            _this.SetMapLines(newPolylines);
        }