159.326-Software-Architecture/Tutorial 5/CurrentConditionsDisplay.cs
2021-09-21 20:07:08 +12:00

59 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Tutorial_5
{
public partial class CurrentConditionsDisplay : Form, IWeatherObserver, IDisplay
{
ISubject subject;
//WeatherData_old weatherData;
private void RegisterButton_Click(object sender, EventArgs e)
{
subject.RegisterObserver(this);
}
double temperature = default, humidity = default, pressure = default;
/// <summary>
/// Push technique
/// </summary>
/// <param name="temperature"></param>
/// <param name="humidity"></param>
/// <param name="pressure"></param>
public void Update(double temperature, double humidity, double pressure)
{
this.temperature = temperature;
this.humidity = humidity;
this.pressure = pressure;
Display();
}
public void UpdateOther()
{
//this.temperature = weatherData.GetTemperature();
//this.humidity = weatherData.GetHumidity();
//this.pressure = weatherData.GetPressure();
}
public void Display()
{
TemperatureLabel.Text = temperature.ToString() + " ℃";
HumidityLabel.Text = humidity.ToString() + " %";
PressureLabel.Text = pressure.ToString() + " kPa";
}
public CurrentConditionsDisplay(ISubject subject)
{
InitializeComponent();
this.subject = subject;
}
}
}