[C#]原子能委員會輻射監控非官方API
namespace LevelUp.RadiationAPI.Demo { public partial class Form1 : Form { private RadiationAgent _radiationAgent; private RadiationAgent m_RadiationAgent { get { if (_radiationAgent == null) { _radiationAgent = new RadiationAgent(); _radiationAgent.AutoUpdateInterval = 5000; _radiationAgent.EnableAutoUpdate = true; } return _radiationAgent; } }
public Form1()
{
InitializeComponent();
}
private void UpdateRadiationValue()
{
listView1.Items.Clear();
listView1.BeginUpdate();
foreach (var data in m_RadiationAgent.RadiationDatas)
{
listView1.Items.Add(data.City).SubItems.AddRange(new string[] { data.RadiationValue.ToString(), data.State.ToString() });
}
listView1.EndUpdate();
}
private void timer1_Tick(object sender, EventArgs e)
{
UpdateRadiationValue();
}
private void Form1_Load(object sender, EventArgs e)
{
UpdateRadiationValue();
m_RadiationAgent.RaditionDataUpdated += new EventHandler(m_RadiationAgent_RaditionDataUpdated);
}
void m_RadiationAgent_RaditionDataUpdated(object sender, EventArgs e)
{
UpdateRadiationValue();
}
private void button1_Click(object sender, EventArgs e)
{
m_RadiationAgent.Update();
UpdateRadiationValue();
}
}
}