コード例 #1
0
 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));
 }
コード例 #2
0
ファイル: Frige.cs プロジェクト: anatoliyshulika/HomeWebForm
 public Frige(string name, Lamp lamp)
     : base(name)
 {
     this.lamp = lamp;
 }
コード例 #3
0
ファイル: Oven.cs プロジェクト: anatoliyshulika/HomeWebForm
 public Oven(string name, Lamp lamp)
     : base(name)
 {
     this.lamp = lamp;
 }