Esempio n. 1
0
        //Go through GPS setup
        private void GPSSetup_Click(object sender, RoutedEventArgs e)
        {
            //Handling case when the application is not connected to the server
            if (GPSServices.connectedToServer == false)
            {
                MessageBox.Show(Properties.Resources.MessageBox_GPS_ConnectionUnsuccessful);
                return;
            }

            //Handling case when no maps were added
            if (mapAdded == false)
            {
                MessageBox.Show(Properties.Resources.MessageBox_GPS_NoMap);
                return;
            }

            //Handling case when no teams were created
            if (Team.getTeamList().Count == 0)
            {
                MessageBox.Show(Properties.Resources.MessageBox_GPS_NoAssociation);
                return;
            }

            //Check if click was to cancel setup or start it
            if (GPSServices.setupOngoing == false)
            {
                //Create and populate list of registered teams
                List <Team> registeredTeams = new List <Team>();
                foreach (Team team in Team.getTeamList())
                {
                    if (team.getGPSLocation() != null)
                    {
                        registeredTeams.Add(team);
                    }
                }

                //Check if there is at least one team that is registered, it will be used for setup
                if (registeredTeams.Count != 0)
                {
                    GPSSetup_Button.Background = new SolidColorBrush(Colors.Red);
                    GPSSetup_Button.Foreground = new SolidColorBrush(Colors.White);
                    GPSServices.SetupGPSToMapTranslation_Start(mapSection, registeredTeams);
                }
                else
                {
                    MessageBox.Show(Properties.Resources.MessageBox_GPS_NoAssociation);
                }
            }
            else
            {
                GPSServices.setupOngoing = false;
                GPSSetup_Button.ClearValue(Button.BackgroundProperty);
                GPSSetup_Button.ClearValue(Button.ForegroundProperty);
                mapSection.Update();                 //Redrawing everything on the map
            }
        }
Esempio n. 2
0
        //UI work to notify of connection failure
        public void NotifyConnectionFail()
        {
            Dispatcher.Invoke(() =>
            {
                GPSLocationsTextBlock.IsEnabled  = false;
                GPSLocationsTextBlock.Background = new SolidColorBrush(Colors.Red);
                GPSLocationsTextBlock.Foreground = new SolidColorBrush(Colors.White);

                if (GPSServices.setupOngoing == true)
                {
                    MessageBox.Show(Properties.Resources.MessageBox_GPS_ConnectionLost);

                    GPSServices.setupOngoing = false;
                    GPSSetup_Button.ClearValue(Button.BackgroundProperty);
                    GPSSetup_Button.ClearValue(Button.ForegroundProperty);
                    mapSection.Update();                     //Redrawing everything on the map
                }
            });
        }