Exemple #1
0
        public TeamPin(Team team, MapSectionPage mapSection) : base(team, mapSection, size)
        {
            this.team       = team;       //Providing a link to the team that this pin represents
            this.mapSection = mapSection;
            //Updating image to match training and status of team in addition to text
            Update();

            //Creating a context menu for TeamPin objects
            MenuItem[] menuItems = new MenuItem[4];

            //Menu items for status change
            menuItems[0]        = new MenuItem();
            menuItems[0].Uid    = "MenuItem_TeamPin_Available";
            menuItems[0].Header = ETD.Properties.Resources.MenuItem_TeamPin_Available;

            menuItems[1]        = new MenuItem();
            menuItems[1].Uid    = "MenuItem_TeamPin_Moving";
            menuItems[1].Header = ETD.Properties.Resources.MenuItem_TeamPin_Moving;

            menuItems[2]        = new MenuItem();
            menuItems[2].Uid    = "MenuItem_TeamPin_Intervening";
            menuItems[2].Header = ETD.Properties.Resources.MenuItem_TeamPin_Intervening;

            menuItems[3]        = new MenuItem();
            menuItems[3].Uid    = "MenuItem_TeamPin_Unavailable";
            menuItems[3].Header = ETD.Properties.Resources.MenuItem_TeamPin_Unavailable;

            //Adding the method to be called when a menu item is clicked and adding the menuitem to the TeamPin context menu
            ContextMenu contextMenu = new ContextMenu();

            for (int i = 0; i < menuItems.Length; i++)
            {
                menuItems[i].Click += ChangeStatus_Click;
                contextMenu.Items.Add(menuItems[i]);
            }
            this.ContextMenu = contextMenu;

            //When the context menu is opened, check the appropriate status of the team
            this.ContextMenu.Opened += CheckCurrentStatus_Opened;

            //Register as an observer to the team instance that this pin represents
            team.RegisterInstanceObserver(this);

            //Register as an observer to the GPS locations so that it will be notified when the GPS locations are changed (team has moved)
            if (team.getGPSLocation() != null)            //The team has been associated to GPS locations
            {
                gpsLocation = team.getGPSLocation();      //Getting a direct pointer for ease of access only
                gpsLocation.RegisterInstanceObserver(this);
            }
        }
Exemple #2
0
        //Choosing which (if any) gps location to use for the intervention coordinates
        internal void SelectGPSLocation()
        {
            //Dissociate from last GPS coordinates
            if (gpsLocation != null)
            {
                gpsLocation.DeregisterInstanceObserver(this);
                gpsLocation = null;
            }

            //Find a team that has a GPS location and attach self to it
            foreach (TeamPin teamPin in getInterveningTeamsPin())
            {
                if (teamPin.getTeam().getGPSLocation() != null && teamPin.getTeam().getStatus() == Statuses.intervening)
                {
                    gpsLocation = teamPin.getTeam().getGPSLocation();
                    gpsLocation.RegisterInstanceObserver(this);
                }
            }
        }