using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using RemoteController; using System.Text; using System.Collections; public partial class CommandSlot : System.Web.UI.UserControl { private int _slot; public int Slot { get { return _slot; } set { _slot = value; } } protected void Page_Load(object sender, EventArgs e) { if (DDCommandList.Items.Count == 0) { House h = (House)Session["HOUSE"]; LoadCommandsDropDownMenu(h); } } public delegate void BtnCommandClickedHandler(object sender, EventArgs e); public event BtnCommandClickedHandler BtnCmdClicked = delegate { }; protected void BtnOnCommand_Click(object sender, EventArgs e) { if (Session["HOUSE"] != null) { House h = (House)Session["HOUSE"]; h.On_Button_Pushed(_slot); Session["HOUSE"] = h; BtnCmdClicked(this, e); } } protected void BtnOffCommand_Click(object sender, EventArgs e) { if (Session["HOUSE"] != null) { House h = (House)Session["HOUSE"]; h.Off_Button_Pushed(_slot); Session["HOUSE"] = h; BtnCmdClicked(this, e); } } private void LoadCommandsDropDownMenu(House h) { ArrayList array = h.CommandList; ArrayList DDarray = new ArrayList(); DDarray.Add("Select Command"); foreach (House.command_pair cmds in array) { DDarray.Add(cmds.Name.ToString()); } DDCommandList.DataSource = DDarray; DDCommandList.DataBind(); } protected void DDCommandList_SelectedIndexChanged(object sender, EventArgs e) { if (DDCommandList.SelectedIndex != 0) { House h = (House)Session["HOUSE"]; h.setCommand(_slot, (DDCommandList.SelectedIndex - 1)); Session["HOUSE"] = h; LblCurrentCommand.Text = DDCommandList.SelectedValue; LblCurrentCommand.Visible = true; DDCommandList.Visible = false; BtnEdit.Enabled = true; BtnOnCommand.Enabled = true; BtnOffCommand.Enabled = true; } } protected void BtnEdit_Click(object sender, EventArgs e) { BtnEdit.Enabled = false; DDCommandList.Visible = true; } }