private void CancelBtn_Click(object sender, EventArgs e) { ClipboardMonitor.OnClipboardChange -= new ClipboardMonitor.OnClipboardChangeEventHandler(ClipboardMonitor_OnClipboardChange); ClipboardMonitor.Stop(); // do not forget to stop Close(); }
private void OKBtn_Click(object sender, EventArgs e) { ClipboardMonitor.OnClipboardChange -= new ClipboardMonitor.OnClipboardChangeEventHandler(ClipboardMonitor_OnClipboardChange); ClipboardMonitor.Stop(); // do not forget to stop ClearMeasCycles(); CycleList newCycles = new CycleList(); // NEXT: manual entry needs more work to get it completed, but you have a good start here Multiplicity key = new Multiplicity(ah.det.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand in some logical manner, e.g. enable user to select the analyzer and related results for manual entry and assignment for (int i = 0; i < MAX_MANUAL_ENTRIES; i++) // hard-coded limits are ... lame { DataGridViewRow r = cyclesGridView.Rows[i]; if (r.Cells == null || (r.Cells[1].Value == null) || r.Cells[1].Value.ToString() == string.Empty) { break; } Cycle cycle = new Cycle(m_log); ulong tots = 0, r_acc = 0, acc = 0; ulong.TryParse(r.Cells[1].Value.ToString(), out tots); ulong.TryParse((string)r.Cells[2].FormattedValue, out r_acc); // FormattedValue gives "" instead of the null checked for in the conditional above ulong.TryParse((string)r.Cells[3].FormattedValue, out acc); newCycles.Add(cycle); cycle.Totals = tots; cycle.TS = new TimeSpan(0, 0, 0, 0, (int)(1000 * m_counttime)); // milliseconds permitted for LM and future cycle.SinglesRate = tots / m_counttime; cycle.SetQCStatus(key, QCTestStatus.Pass); cycle.seq = i + 1; MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq); cycle.CountingAnalysisResults.Add(key, mcr); mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.ASum = acc; mcr.RASum = r_acc; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = tots; mcr.RawSinglesRate.v = cycle.SinglesRate; // no alpha-beta, mult bins, HV, doubles, triples, raw nor corrected } int seq = 0; foreach (Cycle cycle in newCycles) // add the necessary meta-data to the cycle identifier instance { seq++; cycle.UpdateDataSourceId(ConstructedSource.Manual, ah.det.Id.SRType, new DateTimeOffset(m_refDate.AddTicks(cycle.TS.Ticks * cycle.seq)), string.Empty); } NC.App.Opstate.Measurement.Add(newCycles); if (newCycles.Count > 0) { DialogResult = DialogResult.OK; } Close(); }