Esempio n. 1
0
        // #todo: this should be bound to a UI event. (when the map actually design the route.)
        private void OnFlightRouteReady(object sender, FlightRouteDrawEventArgs args)
        {
            FlightRouteControlTextBlock textBlock = new FlightRouteControlTextBlock();

            textBlock.FlightRouteName.Text       = args.FlightRouteData.FlightPlanName;
            textBlock.FlightRouteName.Foreground = new SolidColorBrush(args.RouteColor);
            FlightRoutePanelContainer.Children.Add(textBlock);
        }
Esempio n. 2
0
        private void OnFlightRouteReady(object sender, FlightRouteReadyEventArgs args)
        {
            if (flightRouteUIElementsMap.ContainsKey(args.FlightPlanName))
            {
                // we already have a collection describing this particular route.
                // don't need to add a copy.
                return;
            }

            // polyline + markers
            List <UIElement> flightUIElem = new List <UIElement>(args.FlightPlan.waypoints + 1);

            MapPolyline polyline = new MapPolyline();
            Color       color    = RouteColors[ColorIndex++ % RouteColors.Length];

            polyline.Stroke          = new SolidColorBrush(color);
            polyline.StrokeThickness = 5;
            polyline.Opacity         = 0.7;

            LocationCollection collection = new LocationCollection();

            for (int i = 0; i < args.FlightPlan.waypoints; i++)
            {
                // fill polyline
                NavigationNode currentNode = args.FlightPlan.route.nodes[i];

                collection.Add(new Location(currentNode.lat, currentNode.lon));

                // add marker
                Pushpin pin = new Pushpin();
                pin.Location   = new Location(currentNode.lat, currentNode.lon);
                pin.ToolTip    = args.FlightPlan.notes;
                pin.Content    = currentNode.type;
                pin.Background = GetColorFromNavigationNodeType(currentNode.type);

                BingMap.Children.Add(pin);
                flightUIElem.Add(pin);
            }

            polyline.Locations = collection;

            BingMap.Children.Add(polyline);
            flightUIElem.Add(polyline);

            flightRouteUIElementsMap.Add(args.FlightPlanName, flightUIElem);

            FlightRouteDrawEventArgs e = new FlightRouteDrawEventArgs();

            e.FlightRouteData = args;
            e.RouteColor      = color;

            NewFlightRouteDrawDelegate?.Invoke(this, e);
        }