private void drawThreshold(ThresholdViewModel aThreshold) { try { if (aThreshold != null && mScanMode == Constants.EField) { if (aThreshold.Limits.Count != 0) { Point[] lThresholdLine = new Point[aThreshold.Limits.Count * 2 - 1]; int freq = Convert.ToInt32(aThreshold.Limits[0].Frequency); int amp = Convert.ToInt32(aThreshold.Limits[0].Amplitude); int pos = 0; for (int i = 1; i < aThreshold.Limits.Count * 2; i++) { if (i % 2 == 0) freq = Convert.ToInt32(aThreshold.Limits[i / 2].Frequency); else amp = Convert.ToInt32(aThreshold.Limits[i / 2].Amplitude); lThresholdLine[pos] = new Point(freq, amp); pos++; } graph1.Data[0] = lThresholdLine; } } else { graph1.Data[0] = null; } } catch (Exception) { } }
// select image to set scan area and zoom in on picture //http://www.codeproject.com/Articles/148503/Simple-Drag-Selection-in-WPF private void populateGraph(int aRow, int aCol, int aZPos) { string[] lLine = Logger.getLineFromFile(mLogFileName + ".csv", Convert.ToString(aRow), Convert.ToString(aCol), Convert.ToString(aZPos)); if (lLine != null) { int numberOfPoints = lLine.Length - 3; Point[] data = new Point[numberOfPoints]; string[] lStrPoint; for (int i = 0; i < numberOfPoints; i++) { lStrPoint = lLine[i + 3].Split('|'); data[i] = new Point(Convert.ToDouble(lStrPoint[0]), Convert.ToDouble(lStrPoint[1])); } graph1.Data[1] = data; // Only show the section of the treshold that applies to the data collected ThresholdViewModel lDerivedThreshold = Utilities.getDerivedThreshold(mSelectedThreshold, (double)(((ScanLevel)dgZScanPoints.SelectedItem).ZPos) - mDUTHeight); ThresholdViewModel lThresholdSection = new ThresholdViewModel(); lThresholdSection.Name = "Trimmed Threshold"; ThresholdLimitViewModel lPrevLimit = null; foreach (ThresholdLimitViewModel lLimit in lDerivedThreshold.Limits) { if (lPrevLimit == null) lPrevLimit = lLimit; if (lPrevLimit.Frequency <= data[0].X && lLimit.Frequency >= data[0].X) { lThresholdSection.Limits.Add(new ThresholdLimitViewModel(data[0].X, lPrevLimit.Amplitude)); } if (lPrevLimit.Frequency <= data[numberOfPoints - 1].X && lLimit.Frequency >= data[numberOfPoints - 1].X) { lThresholdSection.Limits.Add(new ThresholdLimitViewModel(data[numberOfPoints - 1].X, lPrevLimit.Amplitude)); } if (lLimit.Frequency >= data[0].X && lLimit.Frequency <= data[numberOfPoints - 1].X) { lThresholdSection.Limits.Add(lLimit); } lPrevLimit = lLimit; } drawThreshold(lThresholdSection); } else { MessageBox.Show("Still Writing data to file. Please try again."); } }
private void analyzeGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { if (dgThresholds.SelectedItem != null) { mSelectedThresholdChanged = true; mSelectedThreshold = ((ThresholdViewModel)dgThresholds.SelectedItem); } }
private void click_addThreshold(object sender, RoutedEventArgs e) { ThresholdViewModel lRow = new ThresholdViewModel(); _thresholds.Add(lRow); }