private void button1_Click(object sender, EventArgs e) { try { city = input.Text; results = client.Query(city); outputF.Text = results.Main.Temperature.FahrenheitCurrent.ToString(); outputC.Text = Convert.ToString(Formula(results.Main.Temperature.FahrenheitCurrent)); timer.Enabled = true; var city = input.Text; var results = client.Query(city); Console.WriteLine($"Температура в {city} {results.Main.Temperature.FahrenheitCurrent}F."); output.Text = results.Main.Temperature.FahrenheitCurrent.ToString(); SystemSounds.Beep.Play(); } catch (Exception ex) { if (input.Text == "") { MessageBox.Show("Вы не ввели свой город.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show($"У вас произошла ошибка №{ex.HResult}Обратитесь к администратору для исправления данной ошибки.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public static void handleCommand(TwitchLib.TwitchChatClient.OnCommandReceivedArgs e) { if (verifyCommand(e)) { OpenWeatherAPI.Query query = Common.OpenWeatherAPI.query(e.ArgumentsAsString); if (query != null && query.ValidRequest) { Common.ChatClient.SendMessage(string.Format("{0}, {1} temperature: {2} ~F ({3} ~C).Conditions: {4} ({5}). Humidity: {6}%. Wind speed: {7} m/s ({8})", query.Name, query.Sys.Country, query.Main.Temperature.FahrenheitCurrent, query.Main.Temperature.CelsiusCurrent, query.Weathers[0].Main, query.Weathers[0].Description, query.Main.Humdity, query.Wind.SpeedMetersPerSecond, query.Wind.directionEnumToString(query.Wind.Direction)), Common.DryRun); } else { Common.ChatClient.SendMessage("Failed to process weather command. Sorry :(", Common.DryRun); } } }
protected void Button1_Click(object sender, EventArgs e) { int airportID = Convert.ToInt16(DropDownList1.SelectedValue); double lat = 0, lon = 0; string latlong = ""; var airports = from item in dbcon.Airports where item.Airport_ID.Equals(airportID) select item; foreach (Airport item in airports) { lat = item.Latitude; lon = item.Longitude; } latlong = string.Format("lat={0}&lon={1}", lat, lon); //lat=35&lon=139 try { query = openWeatherAPI.query(latlong); Label2.Text = string.Format("City Neighborhood: {0} Country: {1}", query.Name, query.Sys.Country); Label3.Text = string.Format("Tempurature: {0} °F", query.Main.Temperature.FahrenheitCurrent); Label4.Text = string.Format("Wind speed (mph): {0}", (query.Wind.SpeedFeetPerSecond * 0.681818)); Label5.Text = string.Format("Percipitation: {0}%", query.Main.Humdity); Label6.Text = string.Format("Cloudiness: {0}%", query.Clouds.All); if ((query.Wind.SpeedFeetPerSecond * 0.681818) > 28.7695) { risk += 4; } if ((query.Main.Temperature.FahrenheitCurrent < 32) && (query.Main.Humdity > 50)) { risk += 4; } if (((query.Main.Temperature.FahrenheitCurrent > 24) && (query.Main.Temperature.FahrenheitCurrent < 40)) && (query.Main.Humdity > 50)) { risk += 4; } if (query.Clouds.All >= 90) { risk += 1; } } catch { }//Does squat if (risk < 4) { Label7.ForeColor = System.Drawing.Color.Green; } else if (risk < 7) { Label7.ForeColor = System.Drawing.Color.Yellow; } else { Label7.ForeColor = System.Drawing.Color.Red; } Label7.BackColor = System.Drawing.Color.Gray; Label7.Text = "Risk: " + risk.ToString() + " "; }
public static bool update() { weatherInfo = new OpenWeatherAPI.Query(key, User.UserLocation); return(weatherInfo.ValidRequest); }
public static bool validCity(string city) { weatherInfo = new OpenWeatherAPI.Query(key, city); return(weatherInfo.ValidRequest); }