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."; } }
public void DisplayCurrent() { DateTime currentTime = Convert.ToDateTime(Form1.days[0].date); DateTime sunrise = Convert.ToDateTime(Form1.days[0].sunrise); DateTime sunset = Convert.ToDateTime(Form1.days[0].sunset); double currentTemp = Math.Round(Convert.ToDouble(Form1.days[0].currentTemp)); double minTemp = Math.Round(Convert.ToDouble(Form1.days[0].tempLow)); double maxTemp = Math.Round(Convert.ToDouble(Form1.days[0].tempHigh)); cityOutput.Text = Form1.days[0].location; tempLabel.Text = currentTemp.ToString("#") + "°C"; minOutput.Text = minTemp.ToString("#") + "°C"; maxOutput.Text = maxTemp.ToString("#") + "°C"; sunriseLabel.Text = "Sunrise: " + sunrise.ToString("dddd hh:mm tt") + " UTC"; sunsetLabel.Text = "Sunset: " + sunset.ToString("dddd hh:mm tt") + " UTC"; timeLabel.Text = "Last Updated: " + currentTime.ToString("dd-MM-yy hh:mm tt") + " UTC"; if (currentTemp >= 20) { BackgroundImage = Properties.Resources.Red_Background; } else if (currentTemp < 20 && 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.ExtractCurrent(); } }
//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.ExtractCurrent(); DisplayCurrent(); }