예제 #1
0
        private void currentLocationButton_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            //Start the stopwatch to see how long reading takes
            watch.Start();

            //Uses ISS class to find where the ISS is and set information on that
            ISSLocation.setISSLocation();
            string overWater    = "";
            var    locationData = "";
            var    seconds      = 0.0;

            //Finds distance in miles with decimal values of lat and long from current Location and ISS location
            double distance = GeoCalculator.GetDistance(CurrentLocation.currentDLat, CurrentLocation.currentDLong, ISSLocation.ISSDLat, ISSLocation.ISSDLong);

            if (ISSLocation.bodyOfWater)
            {
                overWater = $"The ISS is currently over water.\r\n";
            }
            else
            {
                overWater = $"ISS country: {ISSLocation.ISSCountry}\r\nISS State: {ISSLocation.ISSState}\r\n";
            }

            locationData = $"Your chosen zip: {CurrentLocation.currentZip}\r\n" +
                           $"Your chosen location: {CurrentLocation.currentCity}\r\n" +
                           $"Your chosen state: {CurrentLocation.currentState}\r\n" +
                           $"ISS Latitude: {ISSLocation.ISSLat}\r\n" +
                           $"ISS Longitude: {ISSLocation.ISSLong}\r\n" +
                           $"Distance from ISS: {distance} miles\r\n" +
                           overWater +
                           $"Time pinpointed: {ISSLocation.timeAccessed}\r\n";

            mainContentTxtBox.Text = locationData;

            //sets stopwatch textbox to show fast it did it in
            watch.Stop();
            TimeSpan ts = watch.Elapsed;

            seconds = ts.Milliseconds / 1000.0;
            stopWatchTxtBox.Text = $"Reading Taken in {seconds} Second(s)!";

            SerializeData.save(locationData); //Saves after every click
        }