using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using RemoteController; using RemoteController.ReceiverClasses; using System.Collections; using System.Text; public partial class ApplianceDisplay : System.Web.UI.UserControl { private House h; public void CmdButtonWasClicked(object sender, EventArgs e) { updateDisplay(); } protected void Page_Load(object sender, EventArgs e) { updateDisplay(); } private void updateDisplay() { hideAllImgs(); h = (House)Session["HOUSE"]; ArrayList a = h.Appliances; IEnumerable enumGarageDoor = a.OfType(); IEnumerable enumLight = a.OfType(); IEnumerable enumStereo = a.OfType(); IEnumerable enumCeilingFan = a.OfType(); var sb = new StringBuilder(); if (a.OfType().Count() > 0) { sb.AppendLine("\n Light is: " + (enumLight.Single().isLightOn ? " ON" : " OFF")); if (enumLight.Single().isLightOn) {imgLightOn.Visible = true;} else {imgLightOff.Visible = true;} } if (a.OfType().Count() > 0) { sb.AppendLine("\n Garage Door is: " + (enumGarageDoor.Single().isOpen ? " OPEN" : " CLOSED")); if (enumGarageDoor.Single().isOpen) { imgGarageDoorOpen.Visible = true; } else { imgGarageDoorClosed.Visible = true; } } if (a.OfType().Count() > 0) { sb.AppendLine("\n Ceiling Fan is: " + (enumCeilingFan.Single().isFanOn ? " ON " : " OFF")); if (enumCeilingFan.Single().isFanOn) { imgCeilingFanOn.Visible = true; } else imgCeilingFanOff.Visible = true; } if (a.OfType().Count() > 0) { Stereo stereo = enumStereo.Single(); sb.AppendLine("\n Stereo is: " + (stereo.isOn ? " ON " : " OFF ")); sb.Append(" CD is : " + (stereo.isCDSet ? " ON " : " OFF ")); sb.Append(" Volume is: " + stereo.Volume); if (stereo.isOn && stereo.isCDSet) imgStereoOnSetCD.Visible = true; else imgStereoOff.Visible = true; } divTextOutput.InnerHtml = sb.ToString(); } private void hideAllImgs() { imgCeilingFanOff.Visible = false; imgCeilingFanOn.Visible = false; imgGarageDoorClosed.Visible = false; imgGarageDoorOpen.Visible = false; imgLightOff.Visible = false; imgLightOn.Visible = false; imgStereoOff.Visible = false; imgStereoOnSetCD.Visible = false; } }