コード例 #1
0
ファイル: Viewer.cs プロジェクト: valor7/GerberTools
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            var G = e.Graphics;

            G.Clear(Color.Black);
            G.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            G.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            G.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            G.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;

            if (TheBOM == null)
            {
                return;
            }
            Font F     = new Font("Panton", 16);
            Font F2    = new Font("Panton ExtraBold", 26);
            int  count = TheBOM.GetPartCount(new List <string>()
            {
            });
            int solderedcount = TheBOM.GetSolderedPartCount(new List <string>()
            {
            });

            string disp = String.Format("{0}/{1}", solderedcount, count);

            G.DrawString(disp, F, Brushes.White, 2, 2);
            G.DrawString(SolderTool.GetCurrentPartName(), F2, Brushes.White, 2, pictureBox1.Height - F2.Height);

            if (ActiveDes != null)
            {
                string txt = String.Format("{0} {1} - {2}", ActiveEntry.DispName, ActiveDes.OriginalName, ActiveDes.NameOnBoard);
                G.DrawString(txt, F, Brushes.Pink, 2, 20);
            }


            G.TranslateTransform(10, 10);

            float S = (float)Math.Min(pictureBox1.Width / (TheBox.Width() - 20), pictureBox1.Height / (TheBox.Height() - 20));

            if (TopView)
            {
                G.ScaleTransform(S * 0.8f, -S * 0.8f);
                G.TranslateTransform((float)-TheBox.TopLeft.X, (float)-TheBox.TopLeft.Y - (float)TheBox.Height());
            }
            else
            {
                G.ScaleTransform(-S * 0.8f, -S * 0.8f);
                G.TranslateTransform((float)(-TheBox.TopLeft.X - TheBox.Width()), (float)-TheBox.TopLeft.Y - (float)TheBox.Height());
            }

            RenderLayerSets(G, S, BoardSide.Both, BoardLayer.Outline, Color.Gray);
            if (TopView)
            {
                RenderLayerSets(G, S, BoardSide.Top, BoardLayer.SolderMask, Color.FromArgb(20, 255, 255, 50), false);
                RenderLayerSets(G, S, BoardSide.Top, BoardLayer.Silk, Color.FromArgb(100, 255, 255, 255));
            }
            else
            {
                RenderLayerSets(G, S, BoardSide.Bottom, BoardLayer.SolderMask, Color.FromArgb(20, 255, 255, 50), false);
                RenderLayerSets(G, S, BoardSide.Bottom, BoardLayer.Silk, Color.FromArgb(100, 255, 255, 255));
            }
            int i = 0;

            if (ActiveDes != null)
            {
                G.DrawLine(Pens.Gray, (float)ToolX, (float)TheBox.TopLeft.Y, (float)ToolX, (float)TheBox.BottomRight.Y);
                G.DrawLine(Pens.Gray, (float)TheBox.TopLeft.X, (float)ToolY, (float)TheBox.BottomRight.X, (float)ToolY);
            }


            var PL = SolderTool.GetPartList();

            foreach (var v in PL)
            {
                bool Current = SolderTool.GetCurrentPart() == i;
                foreach (var r in v.RefDes)
                {
                    DrawMarker(G, r, v.Soldered, S, Current, ActiveDes == r);
                }
                i++;
            }
        }