Exemplo n.º 1
0
        public override void Bind(IMapControl page, object parameter)
        {
            base.Bind(page, parameter);
            base.RegisterElementTypes(typeof(PlanItemPopup), typeof(MapCircle));
            var selected = (Way)parameter;

            double north = double.MinValue, west = double.MaxValue, south = double.MaxValue, east = double.MinValue;

            foreach (var item in selected)
            {
                var pointList = new List <GeoCoordinate>();
                foreach (var x in item.ShapePoints)
                {
                    pointList.Add(x);
                    north = Math.Max(north, x.Latitude);
                    east  = Math.Max(east, x.Longitude);
                    south = Math.Min(south, x.Latitude);
                    west  = Math.Min(west, x.Longitude);
                }

                page.AddPolyLine(new MapLine
                {
                    Color     = item.Route.RouteGroup.GetColors().MainColor,
                    Thickness = 7,
                    Points    = pointList
                });

                //Microsoft.Phone.Maps.Controls.MapLayer mapLayer = new Microsoft.Phone.Maps.Controls.MapLayer();
                //mapLayer.Add(new MapOverlay()
                //{
                //    GeoCoordinate = line.Path[line.Path.Count / 2],
                //    Content = new Pushpin() { Content = item.Route.RouteGroup.Name + " - " + item.Route.Name }
                //});
                //Map.Layers.Add(mapLayer);

                PutStopCircle(page, item.Route, item.StartStop, item.StartTime, item.StopCount, item == selected.First() ? PlanItemPopupType.Start : PlanItemPopupType.MidStart);
                PutStopCircle(page, item.Route, item.EndStop, item.EndTime, item.StopCount, item == selected.Last() ? PlanItemPopupType.Finish : PlanItemPopupType.MidFinish);
            }

            this.EmptyMapTap   += (sender, args) => closePopups(page);
            this.MapElementTap += (sender, element) =>
            {
                if (element is MapCircle)
                {
                    tapActions[(MapCircle)element].Invoke();
                }
            };
            SetBoundaries(page, north, west, south, east);
        }
Exemplo n.º 2
0
        public override void Bind(IMapControl map, object parameter)
        {
            base.Bind(map, parameter);
            base.RegisterElementTypes(typeof(TripStopPopup), typeof(MapCircle));
            var tripParam = (TripParameter)parameter;

            var trip       = tripParam.Trip;
            var routeGroup = trip.Route.RouteGroup;
            //int position = tripParam.Position;
            //DateTime dateTime = tripParam.DateTime ?? DateTime.Today;
            //Way.Entry entry = new Way.Entry(trip.TripType);
            int position = trip.IndexAt(tripParam.Stop, tripParam.DateTime.Value);

            map.AddPolyLine(new MapLine
            {
                //Points = entry.ShapePoints,
                Points    = trip.TripType.Shape.Points.Select(p => new GeoCoordinate(p.Latitude, p.Longitude)).ToList(),
                Thickness = 7,
                Color     = trip.Route.RouteGroup.GetColors().MainColor
            });

            int i     = 0;
            var stops = trip.Stops;

            foreach (var stop in stops)
            {
                var content = base.CreateColoredCircle(
                    new SolidColorBrush(i == 0 ? routeGroup.GetColors().SecondaryColorBrush.Color : i == position ? Colors.White : i < position ? routeGroup.GetColors().PrimaryColorBrush.Color : Colors.White),
                    trip.Route.RouteGroup.GetColors().MainColorBrush,
                    routeGroup.GetColors().SecondaryColorBrush
                    );
                AddControlToMap(content, stop.Item2.Coordinate);

                int curPos = i;
                tapActions[content] = delegate()
                {
                    clearOpenedOpopup(map);

                    var popupContent = new TripStopPopup(map);
                    popupContent.Initialize(trip, curPos, stops[position].Item1);
                    popupContent.StopClick += (sender1, clickedStop) =>
                    {
                        if (StopSelected != null)
                        {
                            StopSelected(this, new StopParameter
                            {
                                StopGroup = clickedStop.Group,
                                DateTime  = tripParam.DateTime.Value.Date + stops[curPos].Item1,
                                Location  = new ParameterLocation {
                                    Stop = clickedStop
                                }
                            });
                        }
                    };
                    currentPopupLayer = popupContent;
                    AddControlToMap(popupContent, stop.Item2.Coordinate, new Point(0.5, 1));
                };

                i++;
            }

            this.EmptyMapTap   += (sender, args) => clearOpenedOpopup(map);
            this.MapElementTap += (sender, element) =>
            {
                if (element is MapCircle)
                {
                    tapActions[(MapCircle)element].Invoke();
                }
            };
            SetBoundaries(map, stops);
        }