You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
847 B
42 lines
847 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Observer.TemperatureObserver
|
|
{
|
|
class MainForm : Form
|
|
{
|
|
public static Temperature Temp { get; } = new Temperature();
|
|
|
|
private int timeout;
|
|
private TextBox textBox1;
|
|
|
|
public MainForm(int timeout)
|
|
{
|
|
this.timeout = timeout;
|
|
this.textBox1 = new TextBox();
|
|
this.Controls.Add(this.textBox1);
|
|
|
|
this.Load += TextBoxForm_Load;
|
|
}
|
|
|
|
private void TextBoxForm_Load(object sender, EventArgs e)
|
|
{
|
|
Temp.Changed += (s, eArgs) =>
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
textBox1.Text = Temp.Fahrenheit.ToString();
|
|
}));
|
|
};
|
|
|
|
Form trackBarForm = new TrackBarForm();
|
|
trackBarForm.Show();
|
|
|
|
Task.Factory.StartNew(() => Temp.StartMeasure(timeout));
|
|
}
|
|
}
|
|
}
|
|
|