private void OnCurrentCellDirty(object sender, EventArgs e) { if (!_ignoreSelection && dgCogJobResult.CurrentCell != null) { eCol col = (eCol)dgCogJobResult.CurrentCell.ColumnIndex; int iRow = dgCogJobResult.CurrentCell.RowIndex; ExchangeDataMapBase dataMap = _visionJob.RefResults.dataMap[iRow]; string editedValue = dgCogJobResult.CurrentCell.EditedFormattedValue.ToString(); switch (col) { case eCol.Min: dataMap.MinString = editedValue; break; case eCol.Max: dataMap.MaxString = editedValue; break; case eCol.Mode: dataMap.Mode = (SpecBase.eMode)Enum.Parse(typeof(SpecBase.eMode), editedValue); break; case eCol.KeyName: dataMap.Key = editedValue; break; } } }
public void UpdateData() { _ignoreSelection = true; bool overallSuccess = true; Color bkGrnd = Color.YellowGreen; lblResultsError.Text = _visionJob.ResultsError; RefreshComboNames(); if (!_visionJob.ResultsSuccess) { overallSuccess = false; bkGrnd = Color.LightSalmon; } if (_visionJob.RefResults != null && _visionJob.RefResults.dataMap != null && _visionJob.RefResults.Results.Count > 0) { try { for (int iRow = 0; iRow < _visionJob.RefResults.dataMap.Length; iRow++) { bool found = true; bkGrnd = Color.Green; ExchangeDataMapBase dataItem = _visionJob.RefResults.dataMap[iRow]; if (dataItem.Mode != SpecBase.eMode.None && !dataItem.IsInSpec) { overallSuccess = false; bkGrnd = Color.LightSalmon; } DataGridViewRow row = dgCogJobResult.Rows[iRow]; row.Cells[(int)eCol.DataValue].Value = dataItem.DataToString; if (!this.visionName.Items.Contains(dataItem.Key)) { // data item no longer exists, Notify user and reset //U.LogPopup("vision data name '{0}' for data '{1}' does not exist in the vision results. Please select a valid name", // dataItem.Key, dataItem.DataName); //dataItem.Key = ResultsExchange.NONE; found = false; } row.Cells[(int)eCol.Min].Value = dataItem.MinString; row.Cells[(int)eCol.Max].Value = dataItem.MaxString; row.Cells[(int)eCol.Mode].Value = dataItem.Mode.ToString(); row.Cells[(int)eCol.Actual].Value = dataItem.Actual.ToString(); row.Cells[(int)eCol.Actual].Style.BackColor = bkGrnd; row.Cells[(int)eCol.KeyName].Value = found ? dataItem.Key : ResultsExchange.NONE; row.Cells[(int)eCol.KeyName].Tag = found; } } catch (Exception ex) { U.LogPopup(ex, "Problem updating the Results for '{0}'", _visionJob.Nickname); } } if (overallSuccess) { cbSuccess.Text = "Success"; } else { cbSuccess.Text = "Fail"; } cbSuccess.BackColor = bkGrnd; //Image image = _visionJob.LastJobImage; //if (image != null) //{ // lock (image) // { // AcquiredImage = new Bitmap(image); // } //} btnRunJob.Enabled = AcquiredImage != null || _visionJob.LastObjJobImage != null; _ignoreSelection = false; }