in Hands-on lab/lab-files/starter-project/SmartMeterSimulator/MainForm.cs [276:308]
private void Device_Hover(object sender, EventArgs e)
{
//Get the Sensor data from the control's tag property
Button button = (Button)sender;
if(button.Tag != null)
{
Sensor sensor = (Sensor)button.Tag;
string tempIndicator = "";
switch(sensor.TemperatureIndicator)
{
case SensorState.Cold:
tempIndicator = "Cold";
break;
case SensorState.Normal:
tempIndicator = "Normal";
break;
case SensorState.Hot:
tempIndicator = "Hot";
break;
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("Device Id: " + sensor.DeviceId);
sb.AppendLine("Device Key: " + sensor.DeviceKey);
sb.AppendLine("");
sb.AppendLine("Temperature: " + string.Format("{0:0.0}", sensor.CurrentTemperature));
sb.AppendLine("Indicator: " + tempIndicator);
ttDeviceStatus.Show(sb.ToString(), button);
}
}