Beispiel #1
0
        } //Weather Update Interval

        private void button4_Click(object sender, EventArgs e)
        {
            //First, test the connection to the server.
            if (WxManager.TestConnection())
            {
                if (_TcpConnected)
                {
                    //If we are already connected to the player location server, go ahead and get the first wx request
                    string[] response = WxManager.GetMetar(PlayerData.playerLat, PlayerData.playerLng, 20); //Get the closest metar within a 20 nm radius
                    //Convert from inHg to QNH
                    double pressure = Convert.ToDouble(response[5]) * 33.864;

                    //Update the screen
                    //Combine the wind speed
                    string winddir = response[3];
                    string windspd = response[4];
                    if (label28.InvokeRequired)
                    {
                        label28.Invoke(new Action(() => label28.Text = winddir + "/" + windspd));
                    }
                    else
                    {
                        label28.Text = winddir + "/" + windspd;
                    }

                    if (label26.InvokeRequired)
                    {
                        label26.Invoke(new Action(() => label26.Text = pressure.ToString()));
                    }
                    else
                    {
                        label26.Text = pressure.ToString();
                    }

                    if (label24.InvokeRequired)
                    {
                        label24.Invoke(new Action(() => label24.Text = response[0]));
                    }
                    else
                    {
                        label24.Text = response[0];
                    }

                    toolStripStatusLabel11.ForeColor = Color.LimeGreen;
                    toolStripStatusLabel11.Text      = "CONNECTED";
                }
                //Now start the timer
                wxUpdate.Start();
            }
        } //WX Connect Button