Пример #1
0
        //Tag the point at which the team is
        private static void TagPoint_Click(object sender, RoutedEventArgs e)
        {
            MenuItem    mi      = (MenuItem)sender;
            ContextMenu cm      = (ContextMenu)mi.Parent;
            TeamPin     teamPin = (TeamPin)cm.PlacementTarget;

            GPSLocation.referencePoints.Add(new GPSLocation(teamPin.getTeam().getGPSLocation().getLattitude(), teamPin.getTeam().getGPSLocation().getLongitude(), teamPin.getX() * GPSLocation.xRatio, teamPin.getY() * GPSLocation.yRatio));
            MessageBox.Show("Point tagged");
            if (GPSLocation.referencePoints.Count == 2)
            {
                MessageBox.Show("Setup completed");

                GPSLocation.setConfigured(true);     //Change flag to signify that the setup is successfully done
                mapSection.Update();                 //Readding all the pins to the map
                setupOngoing = false;
                gpsStatusCallbacks.SetupCompleted(); //Notifying caller
            }
        }
Пример #2
0
        //Called when team is picked for setup, prepare team pin for setup
        private static void ChooseTeamForSetup_Click(object sender, RoutedEventArgs e)
        {
            MenuItem    mi      = (MenuItem)sender;
            ContextMenu cm      = (ContextMenu)mi.Parent;
            TeamPin     teamPin = (TeamPin)cm.PlacementTarget;

            //Hiding all pins except the pin of the selected team, change its context menu for point tagging
            Pin.ClearAllPins(mapSection.Canvas_map);

            //Customizing the context menu for the exact use needed
            MenuItem tagPointMenuItem = new MenuItem();

            tagPointMenuItem.Header = "Tag point";
            tagPointMenuItem.Click += TagPoint_Click;

            ContextMenu contextMenu = new ContextMenu();

            contextMenu.Items.Add(tagPointMenuItem);
            teamPin.ContextMenu = contextMenu;

            //Replacing pin on the map for tagging
            mapSection.Canvas_map.Children.Add(teamPin);
            double[] previousPinPosition = Pin.getPreviousPinPosition(teamPin.getRelatedObject());
            if (previousPinPosition == null)
            {
                previousPinPosition = new double[] { teamPin.Width / 2, teamPin.Height / 2 };                 //Top-left corner
            }
            teamPin.setPinPosition(previousPinPosition[0], previousPinPosition[1]);

            //Clearing the reference points in case the user is going through the setup again for any reason
            if (GPSLocation.gpsConfigured == true || GPSLocation.referencePoints.Count > 0)
            {
                GPSLocation.gpsConfigured = false;
                GPSLocation.referencePoints.Clear();
                MessageBox.Show("Previous setup is cleared. You can now proceed to re-setup the GPS");
            }

            MessageBox.Show("Team " + teamPin.getTeam().getName() + " selected. Please ask the team to position themselves at different locations of the site.\n"
                            + "As soon as they reach a particular location, wait at least 10 seconds and then tag the position by placing the team pin on the equivalent point on the map, right click on it, and select \"Tag point\".\n"
                            + "Only 2 points are required. For best results, have the points on two different sides of the map.\nSetup will complete as soon as the second point is tagged.");
        }