public void refreshResultsPage(MeasureResultCollection col) { if (!measureListCB.Items.Contains(col.Name)) { measureListCB.Items.Add(col.Name); ResultCollections.Add(col.Clone()); } else { for (int i = 0; i < ResultCollections.Count; i++) { if (ResultCollections[i].Name == col.Name) { ResultCollections[i] = col.Clone(); break; } } } if (measureListCB.SelectedIndex == -1 && measureListCB.Items.Count > 0) { measureListCB.SelectedIndex = 0; } if (measureListCB.Text == col.Name) { if (measureResultTable.Rows.Count != col.Count) { if (col.Count < measureResultTable.Rows.Count) { measureResultTable.Rows.Clear(); } int dif = col.Count - measureResultTable.Rows.Count; for (int i = dif; i > 0; i--) { MeasureResult mr = col.ResultsList[col.Count - i]; addRowToDataGrid(mr); } } } }
private void measureListCB_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; // MessageBox.Show(String.Format("{0} {1}", cb.SelectedIndex, this.measure.ResultCollectionsList.Count)); MeasureResultCollection col = null; foreach (MeasureResultCollection mrc in ResultCollections) { if (cb.Text == mrc.Name) { col = mrc; break; } } if (col == null) { return; } measureResultTable.Rows.Clear(); foreach (MeasureResult r in col.ResultsList) { addRowToDataGrid(r); } }
public void updateResultField() //Для обновления поля результата из другого потока в котором проходит испытание { if (InvokeRequired) { BeginInvoke(new updateResultFieldDelegate(updateResultField)); return; } else { MeasureResultCollection resultList = this.measure.ResultCollectionsList; //refreshResultsPage(); resultForm.refreshResultsPage(resultList); this.cycleCounterLbl.Text = String.Format("{0} Цикл {1}", resultList.Name, this.measure.CycleNumber); //Отрисовка для статистических испытаний if (measure.IsStatistic) { this.statMeasNumbOfLbl.Text = String.Format("измерено {0} из {1}", measure.StatCycleNumber, measure.AveragingTimes); if (resultList.Count > 0) { MeasureResultTera result = resultList.Last() as MeasureResultTera; this.midStatMeasValLbl.Text = String.Format("промежуточное значение: {0}", !isDegreeViewCheckBox.Checked ? absoluteResultView(result.BringingResult) : deegreeResultView(result.BringingResult)); if (result.StatCycleNumber == measure.AveragingTimes) { double avVal = resultList.AverageBringing(); if (isDegreeViewCheckBox.Checked) { this.updateResultFieldText(deegreeResultView(avVal)); } else { this.updateResultFieldText(absoluteResultView(avVal)); } } else { this.measureResultLbl.Text = "подождите..."; } } } else //для обычных испытаний { if (resultList.Count > 0) { MeasureResultTera result = resultList.Last() as MeasureResultTera; if (result.StatCycleNumber == this.measure.AveragingTimes) { if (this.measure.Type == MEASURE_TYPE.CALIBRATION || this.measure.Type == MEASURE_TYPE.VERIFICATION) { this.updateResultFieldText(absoluteResultView(result.BringingResult)); //absoluteResultView(result); this.normaLbl.Text = (this.measure.NormaValue > 0) ? "эталон: " + absoluteResultView((double)this.measure.NormaValue / 1000) + " " + result.DeviationPercent.ToString() + "%" : ""; } else { if (isDegreeViewCheckBox.Checked) { this.updateResultFieldText(deegreeResultView(result.BringingResult)); //absoluteResultView(result); this.normaLbl.Text = (this.measure.NormaValue > 0) ? "норма: " + deegreeResultView((double)this.measure.NormaValue / 1000) : ""; } else { this.updateResultFieldText(absoluteResultView(result.BringingResult)); //absoluteResultView(result); this.normaLbl.Text = (this.measure.NormaValue > 0) ? "норма: " + absoluteResultView((double)this.measure.NormaValue / 1000) : ""; } } } else { this.measureResultLbl.Text = "подождите..."; } } } } }