Beispiel #1
0
        protected void ConditionerDelButton_Click(object sender, EventArgs e)
        {
            deviceDictionary.Remove(i);
            Page.Session["Devices"] = deviceDictionary;
            displayPlaceHolder.Controls.Clear();
            DisplayDeviceControl displayDeviceControl = new DisplayDeviceControl(deviceDictionary, displayPlaceHolder);

            displayPlaceHolder.Controls.Add(displayDeviceControl);
        }
Beispiel #2
0
        protected void AddTvButton_Click(object sender, EventArgs e)
        {
            if (Page != null)
            {
                if ((TV)Page.Session["EmptyTV"] != null)
                {
                    tV                  = (TV)Page.Session["EmptyTV"];
                    tV.Name             = nameTextBox.Text.ToString();
                    tV.Channel          = graphicFactory.CreateEmptySlider();
                    tV.Sound            = graphicFactory.CreateEmptySlider();
                    tV.Sound.SliderName = "Громкость";
                    int  minSoundValue;
                    bool result3 = Int32.TryParse(minVolumeValueTextBox.Text, out minSoundValue);
                    int  maxSoundValue;
                    bool result4 = Int32.TryParse(maxVolumeValueTextBox.Text, out maxSoundValue);
                    tV.Sound.MinValue     = minSoundValue;
                    tV.Sound.CurrentValue = minSoundValue;
                    tV.Sound.MaxValue     = maxSoundValue;
                    tV.Channel.SliderName = "Каналы";
                    int  minChannelValue;
                    bool result1 = Int32.TryParse(minChannelValueTextBox.Text, out minChannelValue);
                    int  maxChannelValue;
                    bool result2 = Int32.TryParse(maxChannelValueTextBox.Text, out maxChannelValue);
                    tV.Channel.MinValue     = minChannelValue;
                    tV.Channel.CurrentValue = minChannelValue;
                    tV.Channel.MaxValue     = maxChannelValue;

                    if (result1 && result2 && result3 && result4)
                    {
                        Dictionary <int, Device> devicesDictionary = (Dictionary <int, Device>)Page.Session["Devices"];
                        devicesDictionary.Add((int)Page.Session["NextDeviceId"], tV);
                        Page.Session["Devices"]      = devicesDictionary;
                        Page.Session["NextDeviceId"] = (int)Page.Session["NextDeviceId"] + 1;
                        DisplayDeviceControl.Initializer();
                        displayPlaceHolder.Controls.Add(DisplayDeviceControl);
                        Page.Session["EmptyTV"] = null;
                        Initializer();
                    }
                    else
                    {
                        Page.Session["EmptyTV"] = null;
                        Initializer();
                        Controls.Add(Span("НЕКОРРЕКТНЫЙ ВВОД ДАННЫХ"));
                    }
                }
            }
        }
Beispiel #3
0
 protected void AddDeviceButton_Click(object sender, EventArgs e)
 {
     if (Page != null)
     {
         if ((UserDevice)Page.Session["EmptyUserDevice"] != null)
         {
             userDevice      = (UserDevice)Page.Session["EmptyUserDevice"];
             userDevice.Name = nameTextBox.Text.ToString();
             userDevice.Sliders.Clear();
             bool correct = true;
             for (int j = 1; j <= SlidersNamesTextBoxes.Count; j++)
             {
                 userDevice.Sliders.Add(j, graphicFactory.CreateEmptySlider());
                 int  minUDValue;
                 bool result1 = Int32.TryParse(MinValuesTextBoxes[j - 1].Text, out minUDValue);
                 int  maxUDValue;
                 bool result2 = Int32.TryParse(MaxValuesTextBoxes[j - 1].Text, out maxUDValue);
                 userDevice.Sliders[j].SliderName   = SlidersNamesTextBoxes[j - 1].Text;
                 userDevice.Sliders[j].MinValue     = minUDValue;
                 userDevice.Sliders[j].CurrentValue = minUDValue;
                 userDevice.Sliders[j].MaxValue     = maxUDValue;
                 if (result1 == false || result2 == false)
                 {
                     correct = false;
                 }
             }
             if (correct)
             {
                 Dictionary <int, Device> devicesDictionary = (Dictionary <int, Device>)Page.Session["Devices"];
                 devicesDictionary.Add((int)Page.Session["NextDeviceId"], userDevice);
                 Page.Session["Devices"]      = devicesDictionary;
                 Page.Session["NextDeviceId"] = (int)Page.Session["NextDeviceId"] + 1;
                 DisplayDeviceControl.Initializer();
                 displayPlaceHolder.Controls.Add(DisplayDeviceControl);
                 Page.Session["EmptyUserDevice"] = null;
                 Initializer();
             }
             else
             {
                 Page.Session["EmptyUserDevice"] = null;
                 Initializer();
                 Controls.Add(Span("НЕКОРРЕКТНЫЙ ВВОД ДАННЫХ"));
             }
         }
     }
 }
Beispiel #4
0
 protected void AddConditionerButton_Click(object sender, EventArgs e)
 {
     if (Page != null)
     {
         if ((Conditioner)Page.Session["EmptyConditioner"] != null)
         {
             conditioner                        = (Conditioner)Page.Session["EmptyConditioner"];
             conditioner.Name                   = nameTextBox.Text.ToString();
             conditioner.Temperature            = graphicFactory.CreateEmptySlider();
             conditioner.Temperature.SliderName = "Температура";
             int  minTempValue;
             bool result1 = Int32.TryParse(minTemperatureValueTextBox.Text, out minTempValue);
             int  maxTempValue;
             bool result2 = Int32.TryParse(maxTemperatureValueTextBox.Text, out maxTempValue);
             conditioner.Temperature.MinValue     = minTempValue;
             conditioner.Temperature.CurrentValue = minTempValue;
             conditioner.Temperature.MaxValue     = maxTempValue;
             if (result1 && result2)
             {
                 Dictionary <int, Device> devicesDictionary = (Dictionary <int, Device>)Page.Session["Devices"];
                 devicesDictionary.Add((int)Page.Session["NextDeviceId"], conditioner);
                 Page.Session["Devices"]      = devicesDictionary;
                 Page.Session["NextDeviceId"] = (int)Page.Session["NextDeviceId"] + 1;
                 DisplayDeviceControl.Initializer();
                 displayPlaceHolder.Controls.Add(DisplayDeviceControl);
                 Page.Session["EmptyConitioner"] = null;
                 Initializer();
             }
             else
             {
                 Page.Session["EmptyConditioner"] = null;
                 Initializer();
                 Controls.Add(Span("НЕКОРРЕКТНЫЙ ВВОД ДАННЫХ"));
             }
         }
     }
 }
Beispiel #5
0
 public GeneralControl(DisplayDeviceControl displayDeviceControl, PlaceHolder displayPlaceHolder)
 {
     DisplayDeviceControl    = displayDeviceControl;
     this.displayPlaceHolder = displayPlaceHolder;
 }