/* If this is the first button clicked, it will * do the same as the plotWafer button click, * generating an initial array. It will then highlight * inspection points on the wafer. If it is not * the first button clicked, it will just take * the current array and highlight the inspection * points based on user input. */ private void GenerateButton_Click(object sender, EventArgs e) { // Clear just the current inspection points dieVisualizer.Series[1].Points.Clear(); // And the text box coordBox.Text = ""; if (dice == null) { dice = new Die[gridDimensionX, gridDimensionY]; // Set the gridlines to show the edges of the dice. dieVisualizer.ChartAreas[0].AxisX.Interval = dieWidth; dieVisualizer.ChartAreas[0].AxisX.IntervalOffset = dieWidth / 2; dieVisualizer.ChartAreas[0].AxisY.Interval = dieHeight; dieVisualizer.ChartAreas[0].AxisY.IntervalOffset = dieHeight / 2; // Fill in array xCoord = 0; // For the current release of the app, // ic and jc exist to evenly space inspection points. int ic = 0, jc = 0; for (float i = xLowHigh[0]; i <= xLowHigh[1]; i += dieWidth) { yCoord = 0; for (float j = yLowHigh[0]; j <= yLowHigh[1]; j += dieHeight) { // Create 5 new points that define the current die Point bl = new Point(i - (float)(dieWidth / 2), j - (float)(dieHeight / 2)); Point br = new Point(i + (float)(dieWidth / 2), j - (float)(dieHeight / 2)); Point tl = new Point(i - (float)(dieWidth / 2), j + (float)(dieHeight / 2)); Point tr = new Point(i + (float)(dieWidth / 2), j + (float)(dieHeight / 2)); Point center = new Point(i, j); // Create the new die and validate it Die d = new Die(tl, tr, bl, br, center); d.isValid(); // If the die is valid, it will be printed showValidDie(d); // Check to make sure that the point is evenly spaced // then highlight it if it is valid if (ic % numPoints == 0 && jc % numPoints == 0) { showInspectedDie(d); } // Actually add the die to the array dice[xCoord, yCoord] = d; yCoord++; jc++; } xCoord++; ic++; } //testCoords(); } else { // Simply run through the current array // and highlight dice at the correct interval int ic = 0, jc = 0; for (int i = 0; i < xCoord; i++) { for (int j = 0; j < yCoord; j++) { Die d = dice[i, j]; if (ic % numPoints == 0 && jc % numPoints == 0) { showInspectedDie(d); } jc++; } ic++; } } }