private void btnSet_Click(object sender, EventArgs e)
 {
     try
     {
         DeviceInfo di;
         if (this._adding)
             di = new DeviceInfo();
         else
             di = this._selected;
         di.ID = this.tbID.Text;
         if (di.ID == "")
             throw new IDFieldEmpty();
         di.Password = this.tbPassword.Text;
         di.Name = this.tbName.Text;
         if (this._adding)
         {
             this.btnAdd.Enabled = true;
             this._adding = false;
             this._devices.Add(di);
             this._selected = di;
         }
         this.UpdateItems();
         this.SelectDevice(di);
     }
     catch (IDFieldEmpty)
     {
         MessageBox.Show("ID field can not be empty");
         this.tbID.Focus();
     }
     catch (Exception exc)
     {
         this._main_form.Log.PostHead("Exception", "Device set, exc: " + exc);
         MessageBox.Show(exc.Message);
     }
 }
 public DevicesConfigForm(MainForm main_form, DeviceInfo[] devices)
 {
     InitializeComponent();
     this._main_form = main_form;
     this._devices = new List<DeviceInfo>(devices);
 }
 private void lbDevices_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this._adding)
     {
         this.btnAdd.Enabled = true;
         this._adding = false;
     }
     this._selected = this.lbDevices.SelectedItem as DeviceInfo;
     this.SelectDevice(this._selected);
 }
 void SelectDevice(DeviceInfo device)
 {
     if (device == null)
     {
         this.tbID.Text = "";
         this.tbID.Enabled = false;
         this.tbPassword.Text = "";
         this.tbPassword.Enabled = false;
         this.tbName.Text = "";
         this.tbName.Enabled = false;
         this.btnRemove.Enabled = false;
         this.btnSet.Enabled = false;
     } else
     {
         this.tbID.Enabled = true;
         this.tbPassword.Enabled = true;
         this.tbName.Enabled = true;
         this.btnSet.Enabled = true;
         this.btnRemove.Enabled = true;
         this.tbID.Text = device.ID;
         this.tbPassword.Text = device.Password;
         this.tbName.Text = device.Name;
     }
 }
Beispiel #5
0
 private void cbDevice_SelectedIndexChanged(object sender, EventArgs e)
 {
     this._selected_device = this.cbDevice.SelectedItem as DeviceInfo;
     this.UpdateSettingsValues();
 }