public aktuator(Int16 index, string name, plc plc, aktor_type type) { _index = index; _name = name; _plc = plc; _type = type; }
private Point default_location(aktor_type t) { switch (t) { case aktor_type.light: Location = new Point(12, 143); break; case aktor_type.jalousie: Location = new Point(81, 143); break; case aktor_type.heater: Location = new Point(12, 209); break; case aktor_type.undef: Location = new Point(81, 209); break; case aktor_type.sensor: Location = new Point(12, 275); break; } return(Location); }
public aktuator_control(aktuator a) { aktuator = a; aktuatorIndex = a.Index; _aktor_type = a.AktorType; set_uc(aktuator); }
public static Bitmap GetPicByType(aktor_type t) { try { switch (t) { case aktor_type.light: return(new Bitmap(AutoHome.Properties.Resources.img_candle_default)); case aktor_type.jalousie: return(new Bitmap(AutoHome.Properties.Resources.img_jalousie_default)); case aktor_type.heater: return(new Bitmap(AutoHome.Properties.Resources.img_heater_default)); case aktor_type.undef: return(new Bitmap(AutoHome.Properties.Resources.img_undef_default)); case aktor_type.sensor: return(new Bitmap(AutoHome.Properties.Resources.img_sensor_default)); } } catch (Exception e) { MessageBox.Show("FrmConfigPlatform: " + e.Message, "error loading png from file "); //log.exception("FrmConfigPlatform", "error loading png from file ", e); } return(null); }
//bild für FrmConfigPlatform wird erstellt private void pic_set_edit_pic(aktor_type t) { Visible = true; Size = new Size(60, 60); this.BackColor = Color.Transparent; this.BringToFront(); Image = PBdefaultControl.GetPicByType(t); }
private void set_pic(aktor_type t) { Visible = true; Size = new Size(60, 60); this.BackColor = Color.Transparent; this.BringToFront(); Image = GetPicByType(t); this._type = t; }
//anlegen eines neuen controls ohne ausgewähltem aktuator public platform_control(aktor_type t) { _type = t; if (t == aktor_type.sensor) { _UCsensorValue = new UC_SensorValue(this); } else { _PictureBox = new PBplatformControl(t, this); } }
private void button_save_actuator_Click(object sender, EventArgs e) { //ein item wird editiert if (listBox_aktors.SelectedItems.Count == 1 || checkBox_add_new_aktuator.Checked) { textBox_akt_id.BackColor = Color.White; Int16 index; //id auf zahl verifizieren if (Int16.TryParse(textBox_akt_id.Text, out index)) { plc plc = (plc)comboBox_edit_plc.SelectedItem; aktor_type type = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); if (checkBox_add_new_aktuator.Checked) { plc.ListAktuator.Add(new aktuator(index, textBox_edit_name.Text, plc, type)); textBox_akt_id.Text = (Convert.ToInt16(textBox_akt_id.Text) + 1).ToString(); } else { aktuator a = (aktuator)listBox_aktors.SelectedItem; //plc.ListAktuator.FindIndex(a) if (comboBox_edit_type.SelectedItem != null) { a.AktorType = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); } if (comboBox_edit_plc.SelectedItem != null) { if (a._plc != (plc)comboBox_edit_plc.SelectedItem) { ((plc)comboBox_edit_plc.SelectedItem).ListAktuator.Add(a); a._plc.ListAktuator.Remove(a); } } if (textBox_akt_id.Text != "") { a.Index = Convert.ToInt16(textBox_akt_id.Text); } if (textBox_edit_name.Text != "") { a.Name = textBox_edit_name.Text; } //int nr = plc.ListAktuator.IndexOf(a); //plc.ListAktuator[nr].Index = index; //plc.ListAktuator[nr].Name = textBox_edit_name.Text; //plc.ListAktuator[nr]._plc = plc; //plc.ListAktuator[nr]._type = type; } //################################################# TODO: //###################### alle bereits projektierten aktoren suchen und ebenfalls updaten //foreach(platform p in _list_platform) // int fn = p._list_platform_control. } else { textBox_akt_id.BackColor = Color.Red; } } //mehrere items werden gleichzeitig editiert else { ListBox.SelectedObjectCollection collection = new ListBox.SelectedObjectCollection(listBox_aktors); foreach (aktuator a in collection) { if (comboBox_edit_type.SelectedItem != null) { a.AktorType = (aktor_type)Enum.Parse(typeof(aktor_type), comboBox_edit_type.Text); } if (comboBox_edit_plc.SelectedItem != null) { if (a._plc != (plc)comboBox_edit_plc.SelectedItem) { ((plc)comboBox_edit_plc.SelectedItem).ListAktuator.Add(a); a._plc.ListAktuator.Remove(a); } } } } listBox_aktors_refresh(); }
//neues element wird erstellt public PBplatformControl(aktor_type t, platform_control platform_control) { _platform_control = platform_control; pic_set_edit_pic(t); }
public PBdefaultControl(aktor_type _type) { this._type = _type; set_pic(_type); default_location(_type); }