private void frm_Instructions_Load(object sender, EventArgs e) { Screen current = Screen.FromControl(this); Rectangle area = current.WorkingArea; this.Size = new Size(area.Width, area.Height); int nBtnsWidth = (area.Width - 48) / 3; this.btnPASS.Location = new Point(12, 50); this.btnFAIL.Location = new Point(12 + nBtnsWidth + 12, 50); this.btnTERMINATE.Location = new Point(12 + nBtnsWidth + 12 + nBtnsWidth + 12, 50); this.btnPASS.Size = new Size(nBtnsWidth, 63); this.btnFAIL.Size = new Size(nBtnsWidth, 63); this.btnTERMINATE.Size = new Size(nBtnsWidth, 63); Int32 n_majorOSVersion = Environment.OSVersion.Version.Major; if (n_majorOSVersion == 5) { this.ConfigPath = @"C:\Documents and Settings\All Users\Application Data\SSManualReportGenerator\"; } else if (n_majorOSVersion == 6) { this.ConfigPath = @"C:\Users\Public\SSManualReportGenerator\"; } else { MessageBox.Show("Neznama verzia operacneho systemu. Zavolajte prosim testovacieho inziniera"); this.Dispose(); return; } this.ProductsConfig = new ProductsConfigurationFile(this.ConfigPath); this.dgv_Instructions = new DGV_Instructions(this.ProductsConfig.GetChildTestsInfos(this.ProductName, this.TestKind)); this.dgv_Instructions.DefaultCellStyle.Font = new Font("Arial", 20.0F); this.dgv_Instructions.Location = new Point(12, 120); this.dgv_Instructions.RowHeadersVisible = false; this.dgv_Instructions.Size = new Size((area.Width - 12) / 2, area.Height - 140); this.dgv_Instructions.Columns[1].Width = this.dgv_Instructions.Width / 2; //this.dgv_Instructions.Columns[5].Width = this.dgv_Instructions.Width - (this.dgv_Instructions.Columns[0].Width + this.dgv_Instructions.Columns[1].Width + this.dgv_Instructions.Columns[2].Width + this.dgv_Instructions.Columns[3].Width + this.dgv_Instructions.Columns[4].Width); for (int i = 0; i < this.Instructions.Length; i++) { ProductsConfigurationFile.ChildTestInfo actCTI = (ProductsConfigurationFile.ChildTestInfo) this.Instructions.GetValue(i); if (actCTI.ScanBarcode == "") { this.dgv_Instructions.Rows.Add(actCTI.Name, actCTI.Instruction, "", "PASS", "FAIL", ""); } else { this.dgv_Instructions.Rows.Add(actCTI.Name, actCTI.Instruction, "", "SCAN", "FAIL", ""); } } this.Controls.Add(this.dgv_Instructions); this.dgv_Instructions.Columns[5].Width = this.dgv_Instructions.Width - (this.dgv_Instructions.Columns[0].Width + this.dgv_Instructions.Columns[1].Width + this.dgv_Instructions.Columns[2].Width + this.dgv_Instructions.Columns[3].Width + this.dgv_Instructions.Columns[4].Width); }
private void tb_Order_KeyUp(object sender, KeyEventArgs e) { if (!btn_Pass.Enabled) { return; } if (e.KeyCode != Keys.Enter) { return; } String actOrder = this.tb_Order.Text.Trim(); String buffer = Regex.Match(actOrder, @"\d+").Value; if (buffer.Length > 12) { if (buffer.Substring(0, 13) == actSN.SerialNumber) { actOrder = "$StepPass#"; } } ProductsConfigurationFile.ChildTestInfo actCI = (ProductsConfigurationFile.ChildTestInfo)Instructions.GetValue(actInstruction); SimpleMode_Form.StepInfo actSI = new SimpleMode_Form.StepInfo(); if (actCI.CameraInspection == "1") { actSI = this.TcpConnect(); if (actSI.Grade == "") { this.ErrorMessageBoxShow(String.Concat("Nemozem nadviazat spojenie s kamerovym systemom. Skontrolujte ci je spusteny program pre obsluhu kamery - Ikona je na ploche PC. Ak sa chyba aj napriek tomu opakuje, zavolajte prosim technika."), true); return; } if (actSI.Grade == "FAIL") { return; } } if (actCI.ScanBarcode != "") { if (!ProductsConfigurationFile.CheckValueToMask(actOrder, actCI.ScanBarcode)) { this.lbl_Instruction.Text = String.Concat("Nespravne zoskenovany udaj\n\n", actCI.Instruction); this.lbl_Instruction.ForeColor = Color.Red; this.tb_Order.Text = ""; this.tb_Order.Focus(); return; } else { actSI.Name = actCI.Name; actSI.Description = actCI.Instruction; actSI.Grade = "PASS"; actSI.ResultValue = actOrder; } } else { if (actOrder == "$StepFail#") { actSI.Name = actCI.Name; if (actCI.CameraInspection != "1") { actSI.Description = actCI.Instruction; } actSI.Grade = "FAIL"; this.Close(); } else if (actOrder == "$StepPass#") { actSI.Name = actCI.Name; if (actCI.CameraInspection != "1") { actSI.Description = actCI.Instruction; } actSI.Grade = "PASS"; } else { this.lbl_Instruction.Text = String.Concat("Nespravne zoskenovany/zadany udaj\n\n", actCI.Instruction); this.lbl_Instruction.ForeColor = Color.Red; this.tb_Order.Text = ""; this.tb_Order.Focus(); return; } } if (actSI.ResultValue.Trim() == "") { actSI.ResultValue = "Checked"; } Array.Resize(ref actSN.Steps, actSN.Steps.Length + 1); actSN.Steps.SetValue(actSI, actSN.Steps.Length - 1); this.actInstruction++; if (actInstruction == this.Instructions.Length) { this.Close(); } else { this.lbl_InsCounter.Text = String.Format("Instruction {0}/{1}", actInstruction + 1, this.Instructions.Length); actCI = (ProductsConfigurationFile.ChildTestInfo)Instructions.GetValue(actInstruction); this.actTimeout = Convert.ToInt32(actCI.Timeout); this.lbl_Instruction.Text = actCI.Instruction; this.lbl_Instruction.ForeColor = Color.Black; if (actCI.CameraInspection == "1") { this.btn_Pass.Text = "START"; } else { this.btn_Pass.Text = "PASS"; } if (actCI.PicturePath != "") { String str_actPicturesPath = String.Concat(str_PicturesPath, actCI.PicturePath); if (actCI.CameraInspection == "1") { Int32 foldIndex = actCI.PicturePath.IndexOf('\\'); String instrfolder = actCI.PicturePath.Substring(0, foldIndex + 1); str_actPicturesPath = String.Concat(str_PicturesPath, instrfolder, this.Item, "_CAM.jpg"); if (!File.Exists(str_actPicturesPath)) { str_actPicturesPath = String.Concat(str_PicturesPath, instrfolder, "Default_CAM.jpg"); } } if (Directory.Exists(Path.GetDirectoryName(str_actPicturesPath))) { if (!File.Exists(str_actPicturesPath)) { this.Cursor = Cursors.Default; if (Path.GetFileName(str_actPicturesPath) == "") { return; } else { this.ErrorMessageBoxShow(String.Concat("Neexistuje subor \"", str_actPicturesPath, "\". Zavolajte prosim testovacieho technika."), true); } return; } Image img_PictureToShow = Image.FromFile(str_actPicturesPath); this.pictureBox1.Visible = true; this.pictureBox1.Image = img_PictureToShow; this.pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; } } else { this.pictureBox1.Visible = false; } this.btn_Pass.BackColor = this.BackColor; this.btn_Pass.Enabled = false; this.btn_Fail.BackColor = this.BackColor; this.btn_Fail.Enabled = false; this.tb_Order.Text = ""; this.timeoutStart = DateTime.Now; this.t_Main.Start(); } }
private void frm_InstructionsOneByOne_Load(object sender, EventArgs e) { this.lbl_SerialNumber.Text = String.Concat("SerialNumber: ", this.actSN.SerialNumber); this.lbl_Operator.Text = String.Concat("Operator: ", this.OperatorName); this.lbl_Station.Text = String.Concat("Station: ", this.StationName); this.lbl_Item.Text = String.Concat("Item/PN: ", this.Item); this.lbl_InsCounter.Text = String.Format("Instruction 1/{0}", this.Instructions.Length); this.btn_Pass.BackColor = this.BackColor; this.btn_Pass.Enabled = false; this.btn_Fail.BackColor = this.BackColor; this.btn_Fail.Enabled = false; ProductsConfigurationFile.ChildTestInfo firstCTI = (ProductsConfigurationFile.ChildTestInfo)Instructions.GetValue(0); this.lbl_Instruction.Text = firstCTI.Instruction; this.timeoutStart = DateTime.Now; this.actTimeout = Convert.ToInt32(firstCTI.Timeout); String str_actPicturesPath = ""; if (firstCTI.PicturePath != "") { if (firstCTI.CameraInspection == "1") { str_actPicturesPath = String.Concat(str_PicturesPath, this.Item, "_CAM.jpg"); } else { str_actPicturesPath = String.Concat(str_PicturesPath, firstCTI.PicturePath); } if (Directory.Exists(Path.GetDirectoryName(str_actPicturesPath))) { if (!File.Exists(str_actPicturesPath)) { this.Cursor = Cursors.Default; if (Path.GetFileName(str_actPicturesPath) == "") { this.pictureBox1.Image = null; return; } else { this.ErrorMessageBoxShow(String.Concat("Neexistuje subor \"", str_actPicturesPath, "\". Zavolajte prosim testovacieho technika."), true); } return; } Image img_PictureToShow = Image.FromFile(str_actPicturesPath); this.pictureBox1.Image = img_PictureToShow; this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } } ProductsConfigurationFile.ChildTestInfo actCTI = (ProductsConfigurationFile.ChildTestInfo) this.Instructions.GetValue(actInstruction); if (firstCTI.CameraInspection == "1") { this.btn_Pass.Text = "START"; } else { this.btn_Pass.Text = "PASS"; } this.t_Main.Start(); }
private void dgv_Instructions_CellClick(object sender, DataGridViewCellEventArgs e) { if ((e.ColumnIndex < 3) || (e.ColumnIndex > 4)) { return; } if (e.ColumnIndex == 3) { if (this.Rows[e.RowIndex].Cells[3].Value.ToString() == "SCAN") { InputBox_Form myIBF = new InputBox_Form("Pouzite snimac ciarovych kodov", this.Rows[e.RowIndex].Cells[1].Value.ToString()); myIBF.ShowDialog(); if (myIBF.Answer != "") { ProductsConfigurationFile.ChildTestInfo actCTI = (ProductsConfigurationFile.ChildTestInfo) this.ar_ChildTestInfos.GetValue(e.RowIndex); Boolean b_ScanInfoValidation = true; if (myIBF.Answer.Length >= actCTI.ScanBarcode.Length) { for (int i = 0; i < actCTI.ScanBarcode.Length; i++) { if (actCTI.ScanBarcode[i].ToString().Trim() == "*") { continue; } if (actCTI.ScanBarcode[i].ToString().Trim() != myIBF.Answer[i].ToString().Trim()) { b_ScanInfoValidation = false; break; } } } else { b_ScanInfoValidation = false; } if (b_ScanInfoValidation) { this.Rows[e.RowIndex].Cells[2].Value = "PASS"; this.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green; } else { this.Rows[e.RowIndex].Cells[2].Value = "FAIL"; this.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red; } this.Rows[e.RowIndex].Cells[2].ToolTipText = myIBF.Answer; } } else { this.Rows[e.RowIndex].Cells[2].Value = "PASS"; this.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green; this.Rows[e.RowIndex].Cells[2].ToolTipText = ""; } } else if (e.ColumnIndex == 4) { this.Rows[e.RowIndex].Cells[2].Value = "FAIL"; this.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red; this.Rows[e.RowIndex].Cells[2].ToolTipText = ""; } }