public frmClient(string title, string lineID, string connection_str) { InitLabel(); InitPanel(); _line = new Line(this, _panel, false, false); //Get the list of wst from database LinesColletion_DataBase conn = new LinesColletion_DataBase(connection_str); if (lineID == "") { return; } string lineName = conn.FindLineName(lineID); if (title == "") { _line.LineName = lineName; _title_Lbl.Text = lineName + " Status"; } else { _title_Lbl.Text = title; } DataTable wstList = conn.Load_List_of_WST(lineID); foreach (DataRow row in wstList.Rows) { int x = row["WST_x"] == DBNull.Value ? 0 : (int)row["WST_x"]; int y = row["WST_y"] == DBNull.Value ? 0 : (int)row["WST_y"]; int w = row["WST_width"] == DBNull.Value ? 30 : (int)row["WST_width"]; int h = row["WST_heigh"] == DBNull.Value ? 30 : (int)row["WST_heigh"]; if (w == 0) w = 30; if (h == 0) h = 30; Point initPoint = new Point(x, y); Size initSize = new Size(w, h); WST wst = new WST(initPoint, initSize, _allowToModify); wst.DescString = row["WST_Name"].ToString(); wst.ID = row["WST_ID"].ToString(); wst.RefreshInfo(); _line.Add_Object(wst); wst.Click += new EventHandler(control_Click); this.AcceptButton = (Button)wst; ((Button)wst).DialogResult = DialogResult.OK; } this.FormBorderStyle = FormBorderStyle.Sizable; this.WindowState = FormWindowState.Maximized; this.TopMost = false; }
private void CreateWorkStationsFromString(Panel _linePannel, string objStr) { string[] controlsInfo = objStr.Split(new[] { "*" }, StringSplitOptions.RemoveEmptyEntries); foreach (string controlInfo in controlsInfo) { string[] info = controlInfo.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries); WST obj = new WST(info[0], info[1]); Add_Object(obj); } }
private void buttonClickHandler(object sender, MouseEventArgs e) { if (_allowObjectModification == false) { return; } if (e.Button == System.Windows.Forms.MouseButtons.Right) { _lastContextMenuSource = (WST)sender; contextMenu.Show(Cursor.Position); } }
public void SetActiveWST(string workStationID, string msnv) { _tmr.Stop(); _currActiveWorkStation = _wstList.Find(c => (c.ID == workStationID.Trim())); if (_currActiveWorkStation != null) { _currActiveWorkStation.BackColor = ActiveColor; _currActiveWorkStation.ExtraString = msnv; _currActiveWorkStation.Select(); _currActiveWorkStation.RefreshInfo(); StartActiveTimer(); } }
public void Remove_Object(WST wst) { var itemToRemove = _wstList.SingleOrDefault(r => r.Name == wst.Name); if (itemToRemove != null) { _wstList.Remove(itemToRemove); if (_linePannel.Controls.Contains(itemToRemove)) { _linePannel.Controls.Remove(itemToRemove); } } }
public void Add_Object(WST wst) { wst.Name = _index.ToString(); wst.AddContextMenu(MouseClickHandler); _index++; _wstList.Add(wst); _linePannel.Controls.Add(wst); }