private void RefreshWafer(DeviceType deviceType, string product) { if (product == "") { return; } string filename; Graphics graphics; Dictionary <string, WaferDie> wafers = new Dictionary <string, WaferDie>(); filename = FTPClient.DownloadFile(Parameter.CurrentDevice, product); if (File.Exists(filename)) { WaferFile.GetInfo(Parameter.CurrentDevice, filename, ref wafers); if (deviceType == DeviceType.HL9309) { Parameter.DeviceHL9309.FilePath = filename; graphics = hl9309PictureBox.CreateGraphics(); _hl9309WaferDieDic.Clear(); foreach (string key in wafers.Keys) { _hl9309WaferDieDic.Add(key, wafers[key]); } } else { Parameter.DeviceHL9308.FilePath = filename; graphics = hl9308PictureBox.CreateGraphics(); _hl9308WaferDieDic.Clear(); foreach (string key in wafers.Keys) { _hl9308WaferDieDic.Add(key, wafers[key]); } } this.Invoke(new EventHandler(delegate { if (Parameter.CurrentDevice == deviceType) { fileComboBox.Text = Path.GetFileName(filename); } WaferDrawing(deviceType, filename, wafers, graphics); })); } wafers.Clear(); wafers = null; }
private void WaferDrawing(string filepath, Graphics graphics) { Pen pen = new Pen(SystemColors.ControlDark, 1); SolidBrush solidBrush = new SolidBrush(Color.Black); Font font = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Regular, GraphicsUnit.Pixel); Color color1, color2; int x, y, width, height; double zThreshold; WaferDie die; PointF pointF; string[] points; pictureBox1.Refresh(); _WaferDieDic.Clear(); WaferFile.GetInfo(Parameter.CurrentDevice, filepath, ref _WaferDieDic); if (Parameter.CurrentDevice == DeviceType.HL9309) { zThreshold = Parameter.DeviceHL9309.Z_Threshold; color1 = Parameter.DeviceHL9309.DieColor1; color2 = Parameter.DeviceHL9309.DieColor2; } else { zThreshold = Parameter.DeviceHL9308.Z_Threshold; color1 = Parameter.DeviceHL9308.DieColor1; color2 = Parameter.DeviceHL9308.DieColor2; } foreach (string key in _WaferDieDic.Keys) { points = key.Split(','); if (points.Length >= 4) { Int32.TryParse(points[0], out x); Int32.TryParse(points[1], out y); Int32.TryParse(points[2], out width); Int32.TryParse(points[3], out height); die = _WaferDieDic[key]; solidBrush.Color = (Math.Abs(die.z) > zThreshold) ? color2 : color1; graphics.FillRectangle(solidBrush, x, y, width, height); pointF = new PointF(x + (width - 9) / 2, y + (height - 9) / 2 - 2); solidBrush.Color = Color.Black; graphics.DrawString(Convert.ToInt32(die.z).ToString(), font, solidBrush, pointF); } } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { Excel.Application xlApp = null; Excel.Workbook xlWorkbook = null; Excel.Worksheet xlWorksheet = null; Excel.Sheets xlSheets = null; Excel.Range xlRange; int startX, startY, endX, endY, value, column, index = 2; string filename, filepath, device, product, savepath = ""; WaferDie die; string[] points; string[] title = { "Device", "Product", "Filename", "Focus Field", "Z", "Average laser energy", "Laser stability" }; Dictionary <string, WaferDie> waferdies = new Dictionary <string, WaferDie>(); Application.UseWaitCursor = true; this.Cursor = Cursors.WaitCursor; backBtn.Enabled = false; searchTextBox.Enabled = false; waferListBox.Enabled = false; if (waferListBox.SelectedIndices.Count > 0) { if (Parameter.CurrentDevice == DeviceType.HL9309) { device = "1HL9309"; product = Parameter.DeviceHL9309.ProductName; filepath = Parameter.DeviceHL9309.HistoryPath + product + "/"; } else { device = "1HL9308"; product = Parameter.DeviceHL9308.ProductName; filepath = Parameter.DeviceHL9308.HistoryPath + product + "/"; } xlApp = new Microsoft.Office.Interop.Excel.Application(); xlWorkbook = xlApp.Workbooks.Add(Type.Missing); xlSheets = xlWorkbook.Sheets as Excel.Sheets; xlApp.Visible = false; xlApp.DisplayAlerts = false; int count = xlWorkbook.Worksheets.Count; for (; count < waferListBox.SelectedIndices.Count; count++) { xlWorkbook.Worksheets.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value); } for (int i = 0; i < waferListBox.SelectedIndices.Count; i++) { try { filename = waferListBox.GetItemAt(waferListBox.SelectedIndices[i], 1).ToString(); filename = filepath + Path.GetFileNameWithoutExtension(filename) + ".wafer/" + filename; if (File.Exists(filename)) { WaferFile.GetInfo(Parameter.CurrentDevice, filename, ref waferdies); xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets[i + 1]; xlWorksheet.Name = Path.GetFileNameWithoutExtension(filename) + ".wafer"; column = 1; for (int j = 0; j < title.Length; j++) { xlRange = (Excel.Range)xlWorksheet.Cells[column, j + 1]; xlRange.Value2 = title[j]; xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; } column++; foreach (string key in waferdies.Keys) { points = key.Split(','); if (points.Length >= 4) { Int32.TryParse(points[0], out value); startX = (value - Parameter.Offset) / Parameter.RectangleWeight; Int32.TryParse(points[1], out value); startY = (value - Parameter.Offset) / Parameter.RectangleWeight; Int32.TryParse(points[2], out value); endX = value / Parameter.RectangleWeight + startX; Int32.TryParse(points[3], out value); endY = value / Parameter.RectangleWeight + startY; die = waferdies[key]; try { xlRange = (Excel.Range)xlWorksheet.Cells[column, 1]; xlRange.Value2 = device; xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 2]; xlRange.Value2 = product; xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 3]; xlRange.Value2 = Path.GetFileName(filename); xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 4]; string location = string.Format("({0},{1}) ({2},{3})", startX, startY, endX, endY); xlRange.Value2 = location; xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 5]; xlRange.Value2 = die.z.ToString("f2"); xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 6]; xlRange.Value2 = die.energy.ToString("f2"); xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; xlRange = (Excel.Range)xlWorksheet.Cells[column, 7]; xlRange.Value2 = die.stability.ToString("f2"); xlRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; } catch (Exception ex) { EventLog.Write(ex.Message); } column++; } } } } catch (Exception ex) { EventLog.Write("SPC: " + ex.Message); } } savepath = Parameter.SpcPath + device + "_" + product + "_wafers.xlsx"; while (File.Exists(savepath)) { savepath = Parameter.SpcPath + device + "_" + product + "_wafers_" + index.ToString() + ".xlsx"; index++; } try { xlWorkbook.SaveAs(savepath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); } catch (Exception ex) { EventLog.Write("SPC: " + ex.Message); } if (xlApp != null) { xlWorkbook.Close(Type.Missing, savepath, Type.Missing); xlApp.Quit(); if (xlWorksheet != null) { Marshal.ReleaseComObject(xlWorksheet); xlWorksheet = null; } if (xlWorkbook != null) { Marshal.ReleaseComObject(xlWorkbook); xlWorkbook = null; } Marshal.ReleaseComObject(xlApp); xlApp = null; } GC.Collect(); MessageBox.Show("Save to " + savepath, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } //count > 0 Application.UseWaitCursor = false; this.Cursor = Cursors.Default; backBtn.Enabled = true; searchTextBox.Enabled = true; waferListBox.Enabled = true; waferdies.Clear(); waferdies = null; }