protected void addDevice_Click(object sender, EventArgs e)
 {
     string name = TextBoxNameOfDevice.Text;
     if(name == string.Empty)
     {
         return;
     }
     foreach(var key in deviceList)
     {
         if(name == key.Key)
         {
             TextBoxNameOfDevice.Text = null;
             return;
         }
     }
     switch(selectDevice.Value.ToString())
     {
         default:
             break;
         case "Lamp":
             deviceList.Add(name, new Lamp(name));
             break;
         case "TV":
             deviceList.Add(name, new TV(name));
             break;
         case "Bake":
             lamp = new Lamp(name + "bakeOven" + "lampOven");
             bakeOven = new Oven(name + "bakeOven", lamp);
             burnerList = new Dictionary<string, Devices> { { name + "burner1", new Burner() }, { name + "burner2", new Burner() } };
             deviceList.Add(name, new Bake(name, burnerList, bakeOven));
             break;
         case "Frige":
             lamp = new Lamp(name + "lampFrige");
             deviceList.Add(name, new Frige(name, lamp));
             break;
         case "Radio":
             deviceList.Add(name, new Radio(name));
             break;
     }
     TextBoxNameOfDevice.Text = null;
     Session["Device"] = deviceList;
     Device.Controls.Add(((IDraw)deviceList[name]).Draw(name, deviceList));
 }
Exemple #2
0
 public Frige(string name, Lamp lamp)
     : base(name)
 {
     this.lamp = lamp;
 }
Exemple #3
0
 public Oven(string name, Lamp lamp)
     : base(name)
 {
     this.lamp = lamp;
 }