private void searchLabel_Click(object sender, EventArgs e) { //store city and country string city = cityTextBox.Text; string countryCode = countryCodeTextBox.Text; Form f = this.FindForm(); Form1 fs = new Form1(); //if real location try { //extract weather data for location fs.ExtractForecast(city, countryCode); fs.ExtractCurrent(city, countryCode); //switch to current screen f.Controls.Remove(this); CurrentScreen cs = new CurrentScreen(); f.Controls.Add(cs); } //if not real location catch { //show error errorLabel.Visible = true; //use default location (stratford) fs.ExtractForecast("Stratford", "Ca"); fs.ExtractCurrent("Stratford", "Ca"); } }
private void continueButton_Click(object sender, EventArgs e) { try { tryAgain.Text = ""; Form1.place = cityInput.Text; Form1.ExtractForecast(); Form1.ExtractCurrent(); Form1.ExtractHourly(); if (cityInput.Text == "") { tryAgain.Text = "Please try again."; } else { Form f = this.FindForm(); f.Controls.Remove(this); CurrentScreen css = new CurrentScreen(); f.Controls.Add(css); } } catch { tryAgain.Text = "Please try again."; } }
//Search for a city and retrieve the information private void searchButton_Click(object sender, EventArgs e) { Form1.city = inputBox.Text; Console.WriteLine(Form1.city); while (Form1.days.Count > 0) { Form1.days.RemoveAt(0); } Form1.ExtractForecast(); Form1.ExtractCurrent(); DisplayCurrent(); Refresh(); }
private void WaterlooLabel_Click(object sender, EventArgs e) { //inputs data to gve Waterloo's weather Form1.days.Clear(); Form1.location = "waterloo,CA"; Form1.ExtractForecast(Form1.location); Form1.ExtractCurrent(Form1.location); Form f = this.FindForm(); f.Controls.Remove(this); CurrentScreen cs = new CurrentScreen(); f.Controls.Add(cs); }
private void SearchPicBox_Click(object sender, EventArgs e) { //searches for the city that has been entered, if teh city is not found, defaults to stratford Form1.days.Clear(); location = SearchBox.Text; Form1.ExtractForecast(location); Form1.ExtractCurrent(location); Form f = this.FindForm(); f.Controls.Remove(this); CurrentScreen cs = new CurrentScreen(); f.Controls.Add(cs); }
private void button1_Click(object sender, EventArgs e) { try { string location = textBox1.Text; Form1.ExtractForecast(location); Form1.ExtractCurrent(location); Form f = this.FindForm(); f.Controls.Remove(this); CurrentScreen cs = new CurrentScreen(); f.Controls.Add(cs); } catch { label4.Text = "please input proper city"; } }
private void searchButton_Click(object sender, EventArgs e) { try { Form1.location = cityInput.Text; Form1.ExtractForecast(); Form1.ExtractCurrent(); if (cityInput.Text == "") { errorLabel.Text = "Please try again"; } else { Form f = this.FindForm(); f.Controls.Remove(this); CurrentScreen cs = new CurrentScreen(); f.Controls.Add(cs); } } catch { errorLabel.Text = "Please try again"; } }
private void cityBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { try { workAround = false; cityBox.Visible = false; Form1.cityName = cityBox.Text; Form1.days.Clear(); Form1.GetData(); Form1.ExtractCurrent(); Form1.ExtractForecast(); workAround = true; cityBox.Text = "Stratford,CA"; DisplayCurrent(); Refresh(); } catch { MessageBox.Show("This is an invalid name."); } } }
private void updateTimer_Tick(object sender, EventArgs e) { Form1.ExtractForecast(); displayForecast(); }
public void displayForecast() { List <PictureBox> icons = new List <PictureBox>(new PictureBox [] { iconBox0, iconBox1, iconBox2, iconBox3, iconBox4, iconBox5 }); DateTime currentTime = Convert.ToDateTime(Form1.days[0].date); double minTempOne = Math.Round(Convert.ToDouble(Form1.days[1].tempLow)); double maxTempOne = Math.Round(Convert.ToDouble(Form1.days[1].tempHigh)); DateTime dateOne = Convert.ToDateTime(Form1.days[1].date); double minTempTwo = Math.Round(Convert.ToDouble(Form1.days[2].tempLow)); double maxTempTwo = Math.Round(Convert.ToDouble(Form1.days[2].tempHigh)); DateTime dateTwo = Convert.ToDateTime(Form1.days[2].date); double minTempThree = Math.Round(Convert.ToDouble(Form1.days[3].tempLow)); double maxTempThree = Math.Round(Convert.ToDouble(Form1.days[3].tempHigh)); DateTime dateThree = Convert.ToDateTime(Form1.days[3].date); double minTempFour = Math.Round(Convert.ToDouble(Form1.days[4].tempLow)); double maxTempFour = Math.Round(Convert.ToDouble(Form1.days[4].tempHigh)); DateTime dateFour = Convert.ToDateTime(Form1.days[4].date); double minTempFive = Math.Round(Convert.ToDouble(Form1.days[5].tempLow)); double maxTempFive = Math.Round(Convert.ToDouble(Form1.days[5].tempHigh)); DateTime dateFive = Convert.ToDateTime(Form1.days[5].date); date1.Text = dateOne.ToString("dddd dd"); min1.Text = minTempOne.ToString("#") + "°C"; max1.Text = maxTempOne.ToString("#") + "°C"; date2.Text = dateTwo.ToString("dddd dd"); min2.Text = minTempTwo.ToString("#") + "°C"; max2.Text = maxTempTwo.ToString("#") + "°C"; date3.Text = dateThree.ToString("dddd dd"); min3.Text = minTempThree.ToString("#") + "°C"; max3.Text = maxTempThree.ToString("#") + "°C"; date4.Text = dateFour.ToString("dddd dd"); min4.Text = minTempFour.ToString("#") + "°C"; max4.Text = maxTempFour.ToString("#") + "°C"; date5.Text = dateFive.ToString("dddd dd"); min5.Text = minTempFive.ToString("#") + "°C"; max5.Text = maxTempFive.ToString("#") + "°C"; timeLabel.Text = "Last Updated: " + currentTime.ToString("dd-MM-yy hh:mm tt") + " UTC"; for (int i = 0; i < 6; i++) { Image newimage; if (Convert.ToDouble(Form1.days[i].condition) <= 232) { newimage = Form1.thunderstorm; icons[i].Image = newimage; } else if (Convert.ToDouble(Form1.days[i].condition) <= 531) { newimage = Form1.rainy; icons[i].Image = newimage; } else if (Convert.ToDouble(Form1.days[i].condition) <= 622) { newimage = Form1.snowy; icons[i].Image = newimage; } else if (Convert.ToDouble(Form1.days[i].condition) == 800) { newimage = Form1.sunny; icons[i].Image = newimage; } else if (Convert.ToDouble(Form1.days[i].condition) >= 801) { newimage = Form1.cloudy; icons[i].Image = newimage; } } if (Convert.ToDouble(Form1.days[0].currentTemp) >= 20) { BackgroundImage = Properties.Resources.Red_Background; } else if (Convert.ToDouble(Form1.days[0].currentTemp) < 20 && Convert.ToDouble(Form1.days[0].currentTemp) > 10) { BackgroundImage = Properties.Resources.Grey_Background; } else { BackgroundImage = Properties.Resources.Blue_Background; } if (timeLabel.Text != DateTime.Now.ToString("dd-MM-yy hh:mm tt") + " UTC") { Form1.ExtractForecast(); } }