コード例 #1
0
        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;
            BOM B = Main.GetBom();

            Font F = new Font("Panton", 10);

            if (B == null)
            {
                G.DrawString("Not loaded..", F, Brushes.White, 2, 2);
                return;
            }

            int i  = 0;
            int pc = B.GetPartCount(new List <string>()
            {
            });

            CurrentPart = (CurrentPart + pc) % pc;
            foreach (var a in B.DeviceTree)
            {
                foreach (var v in a.Value.Values)
                {
                    string count = v.RefDes.Count().ToString();
                    Brush  Br    = Brushes.Red;
                    if (v.Soldered)
                    {
                        Br = Brushes.Green;
                    }
                    int y = 2 + i * 14;
                    if (i == CurrentPart)
                    {
                        G.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 255, 0)), 0, y, pictureBox1.Width, 14);
                    }
                    G.DrawString(count, F, Br, 2, y);
                    G.DrawString(v.Combined(), F, Br, 22, y);
                    i++;
                }
            }
        }
コード例 #2
0
        public void UpdateCurrentPart()
        {
            BOM B = Main.GetBom();

            if (B == null)
            {
                return;
            }

            int pc = B.GetPartCount(new List <string>()
            {
            });

            CurrentPart = (CurrentPart + pc) % pc;
            if (CurrentPart < 0)
            {
                CurrentPart = 0;
            }
        }
コード例 #3
0
        private void ToggleCurrentPart()
        {
            BOM B = Main.GetBom();

            if (B == null)
            {
                return;
            }
            int i = 0;

            int pc = B.GetPartCount(new List <string>()
            {
            });

            CurrentPart = (CurrentPart + pc) % pc;

            foreach (var a in B.DeviceTree)
            {
                foreach (var v in a.Value.Values)
                {
                    if (i == CurrentPart)
                    {
                        v.Soldered = !v.Soldered;
                        if (v.Soldered)
                        {
                            Main.SolderPart(v.Combined());
                        }
                        else
                        {
                            Main.UnSolderPart(v.Combined());
                        }
                        return;
                    }
                    i++;
                }
            }
        }
コード例 #4
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++;
            }
        }