private void DrawContact(Graphics g) { String Text = pcbi_parent.GetJobName();// "www.EasyLogix.de"; SizeF strSize = g.MeasureString(Text, new Font("Arial", 40)); Brush TextB = new SolidBrush(Color.FromArgb(180, 255, 250, 230)); g.FillRectangle(TextB, 0, 5, strSize.Width, strSize.Height); g.DrawString(Text, new Font("Arial", 40), Brushes.DarkBlue, new PointF(0, 5)); }
public string FileSaveDialog(IPCBIWindow parent) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = parent.GetODBJobDirectory(); saveFileDialog1.FileName = parent.GetJobName(); saveFileDialog1.Title = "Save Seica Files"; saveFileDialog1.CheckFileExists = false; saveFileDialog1.OverwritePrompt = true; saveFileDialog1.CheckPathExists = true; saveFileDialog1.DefaultExt = "par"; saveFileDialog1.Filter = "PAR files (*.par)|*.par|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { return(saveFileDialog1.FileName); } return(string.Empty); }
private DialogResult MakeWorkingCopy() { DialogResult res = DialogResult.Abort; string stepName = this.Parent.GetCurrentStep().Name; string pathForWorkingODB = Path.GetTempPath() + "NBI\\" + Parent.GetJobName() + "_" + stepName + DateTime.Now.Ticks + "\\"; if (Directory.Exists(pathForWorkingODB)) { Directory.Delete(pathForWorkingODB, true); System.Threading.Thread.Sleep(400); } Parent.SaveJob(pathForWorkingODB, false); if (!Parent.LoadODBJob(pathForWorkingODB)) { MessageBox.Show("Can't create a temporary working copy of ODB-Data.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { //res = MessageBox.Show("Continue", "Workingcopy is loaded", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); return(DialogResult.OK); } return(res); }
public void Execute(IPCBIWindow parent) { //your code here if (parent == null) { return; } System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; nfi.NumberGroupSeparator = ""; IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); StringBuilder sb = new StringBuilder(); IMatrix m = parent.GetMatrix(); List <int> netnumbers = step.GetAllNetNrs(); Dictionary <int, List <PCBIObject> > allNetNrsWithItems = PCBI.Automation.NetCreation.NetCreator.CreateGlobalNet(step, m, true); foreach (int netlist in allNetNrsWithItems.Keys) { foreach (PCBIObject oObject in allNetNrsWithItems[netlist]) { oObject.iObj.PcbNetNumber = oObject.NetNrGlobal; } } List <string> names = step.GetAllLayerNames(); foreach (string layername in names) { if (step.GetLayer(layername).GetType() == typeof(IODBLayer)) { IODBLayer layer = (IODBLayer)step.GetLayer(layername); if (m.GetMatrixLayerType(layername) == MatrixLayerType.Signal || m.GetMatrixLayerType(layername) == MatrixLayerType.Rout || m.GetMatrixLayerType(layername) == MatrixLayerType.Drill || m.GetMatrixLayerType(layername) == MatrixLayerType.Mask) { foreach (IODBObject obj in layer.GetAllLayerObjects()) { int PCB_NetNum = obj.PcbNetNumber; int LayerNetNum = obj.LayerNetNumber; obj.FreeText = PCB_NetNum.ToString(); //sb.Append("P: " + PCB_NetNum.ToString() + "L: " + LayerNetNum.ToString() + Environment.NewLine); } } } } sb.Append("P VER IPC D 356" + Environment.NewLine); sb.Append("P IMAGE PRIMARY" + Environment.NewLine); sb.Append("C Created with PCB-Investigator" + Environment.NewLine); sb.Append("P Creation date:" + DateTime.Now.ToShortDateString() + Environment.NewLine); sb.Append("C " + step.Name + " " + parent.GetJobName() + Environment.NewLine); sb.Append("C" + Environment.NewLine); sb.Append("P CUST 0" + Environment.NewLine); #region descriptions // Units of measurement : //SI Metric //CUST 0 or CUST Inches and degrees //CUST 1 Millimeters and degrees //CUST 2 Inches and radians //ALLOWED OPERATION CODES (columns 1-3) //317 Through hole. Alternatively it can represent a feature and through hole at a point. //017 Continuation record that defines a through hole associated with the previous record //367 Non-plated tooling hole //327 Surface mount feature //027 Continuation record that defines a through hole associated with the previous record //099 Test point location of the feature described in the previous record //088 Solder mask clearance of the feature described in the previous record //307 Blind or buried via //309 Image 2 through NNNN offset data //370 In-board resistor, capacitor or inductor //070 Continuation of In-board resistor, capacitor or inductor //378 Conductor segment data //078 Continuation record of conductor segment data //379 Adjacency data record //079 Continuation of adjacency data record //380 On-board resistor, capacitor or inductor //080 Continuation of on-board resistor, capacitor or inductor //389 Board, panel or sub-panel , scoring or other fabrication outline data //089 Continuation of outline data //390 Non-test feature such as fiducials , targets , test status marking location , etc … //090 Reference for high-voltage isolation , impedance and other specified tests //999 End of Job data file #endregion List <string> drillNames = m.GetAllDrillLayerNames(); foreach (string drilName in drillNames) { IODBLayer layer = (IODBLayer)step.GetLayer(drilName); string LayerNumber = m.GetRawIndexByName(layer.LayerName).ToString(); foreach (IODBObject via in layer.GetAllLayerObjects()) { string NetName = via.PcbNetNumber.ToString();; IObjectSpecifics viaSpec = via.GetSpecifics(); if (viaSpec.GetType() == typeof(IPadSpecifics)) { float x = ((IPadSpecifics)viaSpec).Location.X; float y = ((IPadSpecifics)viaSpec).Location.Y; double diameter = ((IPadSpecifics)viaSpec).Diameter; string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "317"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "VIA"); currentLine = currentLine.Insert(27, "-"); //currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(x) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, x.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "X"); currentLine = currentLine.Insert(59, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "Y"); currentLine = currentLine.Insert(64, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "3"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPTop = (IODBLayer)step.GetLayer(m.GetTopSignalLayer()); if (LayerPTop != null) { string LayerNumber = m.GetRawIndexByName(LayerPTop.LayerName).ToString(); foreach (IODBObject padTop in LayerPTop.GetAllLayerObjects()) { string NetName = padTop.PcbNetNumber.ToString();; IObjectSpecifics os = padTop.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padTop.GetBounds().X + padTop.GetBounds().Width / 2, padTop.GetBounds().Y + padTop.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padTop.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPBot = (IODBLayer)step.GetLayer(m.GetBotSignalLayer()); if (LayerPBot != null) { string LayerNumber = m.GetRawIndexByName(LayerPBot.LayerName).ToString(); foreach (IODBObject padBot in LayerPBot.GetAllLayerObjects()) { string NetName = padBot.PcbNetNumber.ToString();; IObjectSpecifics os = padBot.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padBot.GetBounds().X + padBot.GetBounds().Width / 2, padBot.GetBounds().Y + padBot.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padBot.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } sb.Append("999" + Environment.NewLine); // End of File string text = sb.ToString(); Directory.CreateDirectory(parent.GetODBJobDirectory() + "\\user\\"); FileStream fs = new FileStream(parent.GetODBJobDirectory() + "\\user\\IPC356.txt", FileMode.OpenOrCreate); StreamWriter sr = new StreamWriter(fs, Encoding.UTF8); fs.SetLength(0); sr.WriteLine(text); sr.Close(); fs.Close(); parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { //set all signal layers in one image string Rows = Microsoft.VisualBasic.Interaction.InputBox("How many rows do you wish?", "Setup", "2"); int rows = 2; try { rows = int.Parse(Rows); } catch (Exception re) { MessageBox.Show("Please provide a number\n" + re.ToString()); } string pathForImage = System.IO.Path.GetTempPath() + "imageComplete.png"; //output somewhere stopImaging = false; //internal bool to use cancel button float DPI = 1000; //in pixel foreach layer int maxWidtBMP = 40000; //image class is dangerous for big RAM usage! int countImagesEachLine = rows; //maximum of image in one line bool AddDrillsToImage = true; //see where are the connections to other layers bool AddCompToImageAsSeperateLayer = true; //see where are the connections to other layers IStep step = parent.GetCurrentStep(); IMatrix matrix = parent.GetMatrix(); if (step == null || matrix == null) { return; } PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = null; try { working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog(); //show waiting dialog, because for some projects it is very slow working.CanCancel(true); working.CancelPressed += working_CancelPressed; working.SetAnimationStatus(false); working.ShowWorkingDlgAsThread(); int curValPercentage = 0; working.SetStatusPercent(curValPercentage); List <string> allSignalLayerNames = matrix.GetAllSignalLayerNames(); if (!AddCompToImageAsSeperateLayer) { allSignalLayerNames.Insert(0, matrix.GetTopComponentLayer()); allSignalLayerNames.Add(matrix.GetBotComponentLayer()); } List <ILayer> activeLayerList = step.GetActiveLayerList(); //remember active layer list to set them later back step.TurnOffAllLayer(); int maxHeight = 0; int maxWidth = 0; int completeWidth = 0; int lines = 1; bool setBackHatch = parent.IColorsetting.UseHatchMode; Color setBackColor = parent.IColorsetting.SelectionColor; parent.IColorsetting.SelectionColor = Color.White; //highlight selection better with plane color parent.IColorsetting.UseHatchMode = false; RectangleF boundsStep = step.GetBounds(); boundsStep.Inflate(20, 20); int height = (int)(boundsStep.Height * DPI / 1000); int width = (int)(boundsStep.Width * DPI / 1000); //set the step bounds with DPI if (height > maxHeight) { maxHeight = height; } curValPercentage = 10; working.SetStatusPercent(curValPercentage); Dictionary <string, System.Drawing.Bitmap> allLayerImages = new Dictionary <string, System.Drawing.Bitmap>(); int counterLayers = 0; foreach (string layername in allSignalLayerNames) { if (stopImaging) { break; } counterLayers++; working.SetStatusText("working on " + layername); curValPercentage += 80 / allSignalLayerNames.Count; //we want only the part in the middle of the progress bar... working.SetStatusPercent(curValPercentage); Bitmap resultImage; if (step.GetLayer(layername) is IODBLayer) { IODBLayer signalLayer = (IODBLayer)step.GetLayer(layername); signalLayer.EnableLayer(true); if (AddDrillsToImage) { List <ILayer> drawList = new List <ILayer>(); foreach (string layerDrillName in matrix.GetAllDrillLayersForThisLayer(layername)) { drawList.Add(step.GetLayer(layerDrillName)); } drawList.Add(signalLayer); if (AddCompToImageAsSeperateLayer) { if (matrix.GetTopSignalLayer() == layername) { ILayer layer = step.GetLayer(matrix.GetTopComponentLayer()); if (layer != null) { drawList.Add(layer); } } if (matrix.GetBotSignalLayer() == layername) { ILayer layer = step.GetLayer(matrix.GetBotComponentLayer()); if (layer != null) { drawList.Add(layer); } } } resultImage = step.GetBitmap(drawList, boundsStep, width, height, true, false, false, false); // public Bitmap GetBitmap( List<ILayer> Layers,RectangleF DetailRectangle, int Width, int Height, bool DrawPCBOutline, bool FillBoardOutline, bool ShowComponentDetails, bool IgnoreSelection, bool DrawOnlySelection, out RectangleF DrawnRectangle Bitmap copyBitmap = new Bitmap(resultImage); //do copy the image before the old one will be disposed resultImage = copyBitmap; } else { resultImage = step.GetBitmap(new List <ILayer>() { signalLayer }, boundsStep, width, height, true, false, false, false); } if (resultImage != null) { allLayerImages.Add(layername, resultImage); //remember the layer image later } signalLayer.DisableLayer(); } else if (!AddCompToImageAsSeperateLayer && step.GetLayer(layername) is ICMPLayer) { ICMPLayer cmpLayer = (ICMPLayer)step.GetLayer(layername); resultImage = step.GetBitmap(new List <ILayer>() { cmpLayer }, boundsStep, width, height, true, false, true, false); allLayerImages.Add(layername, resultImage); //remember the layer image later } if (completeWidth + width > maxWidtBMP || counterLayers > countImagesEachLine) //max image size { lines++; completeWidth = width; counterLayers = 1; } else { completeWidth += width; } if (completeWidth > maxWidth) { maxWidth = completeWidth; } } working.SetStatusText("built new image..."); working.SetStatusPercent(85); Bitmap bitComplete = null; bool needDownScale = false; try { bitComplete = new Bitmap(maxWidth, lines * (maxHeight + 100) + 60); //depending on your design this constructor sometimes throw an exception } catch { bitComplete = new Bitmap(maxWidth / 10, lines * (maxHeight + 1000) / 10 + 60); needDownScale = true; //depending on your machine settings and RAM it can make problems by creating big images. } parent.IColorsetting.UseHatchMode = setBackHatch; parent.IColorsetting.SelectionColor = setBackColor; Graphics g = Graphics.FromImage(bitComplete); g.Clear(Color.Transparent); int Xoff = 0; int Yoff = 0; working.SetStatusText("set images in one... "); Font f = new Font("Arial", needDownScale ? 20 : 40); //we need a font to write layernames int counterImagesInLine = 0; foreach (string layer in allLayerImages.Keys) { counterImagesInLine++; if (needDownScale && (Xoff + allLayerImages[layer].Width / 10 > bitComplete.Width || counterImagesInLine > countImagesEachLine)) { Yoff += maxHeight / 10 + 100; //space for text Xoff = 0; counterImagesInLine = 1; } else if (Xoff + allLayerImages[layer].Width > maxWidtBMP || counterImagesInLine > countImagesEachLine) { Yoff += maxHeight + 100; //space for text Xoff = 0; counterImagesInLine = 1; } if (needDownScale) { g.DrawImage(allLayerImages[layer], new RectangleF(Xoff, Yoff + 100, width / 10, height / 10), new RectangleF(0, 0, allLayerImages[layer].Width, allLayerImages[layer].Height), GraphicsUnit.Pixel); } else { g.DrawImage(allLayerImages[layer], new Point(Xoff, Yoff + 100)); } g.DrawString(layer, f, Brushes.Red, new PointF(Xoff + 50, Yoff + 30)); //name of layer if (needDownScale) { Xoff += allLayerImages[layer].Width / 10; } else { Xoff += allLayerImages[layer].Width; } } string textForFooter = parent.GetJobName() + " - creation date: " + DateTime.Now.ToString() + " www.PCB-Investigator.com"; SizeF size = g.MeasureString(textForFooter, f); g.DrawString(textForFooter, f, Brushes.White, new PointF((bitComplete.Width - size.Width) / 2, bitComplete.Height - 60)); //name of layer working.SetStatusPercent(91); foreach (ILayer layerActive in activeLayerList) { layerActive.EnableLayer(true); } working.SetStatusPercent(95); try { working.SetStatusText("saving result..."); bitComplete.Save(pathForImage, ImageFormat.Png); //open image with standard viewer System.Diagnostics.Process.Start(pathForImage); } catch { } working.DoClose(); } catch (Exception ex) { if (working != null) { working.DoClose(); } MessageBox.Show("Can't create image, because " + Environment.NewLine + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }