Beispiel #1
0
        public bool HilightWaferPoint(System.Drawing.Point picPoint)
        {
            var  drawList = Layers.Where(it => it.Visible).Select(it => it.LayerName).ToList();
            bool hitTest  = false;


            DXFPolyline biggest  = null;
            int         maxWidth = 0;


            foreach (var obj in Shapes)
            {
                DXFPolyline temp = (DXFPolyline)obj;
                if (drawList.Contains(temp.LayerIndex))
                {
                    if (temp.HitTest(picPoint))
                    {
                        if (temp.ItemLineWidth > maxWidth)
                        {
                            maxWidth = temp.ItemLineWidth;
                            biggest  = temp;
                        }
                        hitTest |= true;
                        // break;
                    }
                }
            }
            biggest.Highlight(picPoint);

            return(hitTest);
        }
Beispiel #2
0
        public void LoadFile(string filename)
        {
            DxfDocument loaded = DxfDocument.Load(filename);

            Layers = loaded.Layers.OrderBy(x => x.Name).Select(x => new DXFLayer {
                LayerName = x.Name, Visible = true, color = x.Color.ToColor()
            }).ToArray();


            Shapes = new List <DXFShape>();

            foreach (var block in loaded.Blocks)
            {
                foreach (var shape in block.Entities)
                {
                    switch (shape.Type)
                    {
                    case EntityType.Polyline:
                        Shapes.Add(new DXFPolyline(shape.Color.ToColor(), 1, shape.Layer.Name));
                        break;

                    case EntityType.LightWeightPolyline:

                        Color color = shape.Color.ToColor();
                        if (shape.Color.IsByLayer)
                        {
                            color = shape.Layer.Color.ToColor();
                        }
                        var pl            = new DXFPolyline(color, 1, shape.Layer.Name);
                        var specificShape = (LwPolyline)shape;
                        for (int i = 1; i < specificShape.Vertexes.Count; i++)
                        {
                            pl.AppendLine(new DFXLine(
                                              new System.Drawing.Point((int)specificShape.Vertexes[i - 1].Position.X, -1 * (int)specificShape.Vertexes[i - 1].Position.Y),
                                              new System.Drawing.Point((int)specificShape.Vertexes[i].Position.X, -1 * (int)specificShape.Vertexes[i].Position.Y),
                                              color,
                                              (int)specificShape.Vertexes[i].StartWidth)
                                          );
                        }
                        Shapes.Add(pl);
                        break;

                    case EntityType.Hatch:
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        public bool Hilight(System.Drawing.Point picPoint, bool mirror, bool rotate90)
        {
            var x        = picPoint.X / mainScale + XMin;
            var y        = picPoint.Y / mainScale + YMin;
            var drawList = Layers.Where(it => it.Visible).Select(it => it.LayerName).ToList();

            var         hitPoint = new System.Drawing.Point((int)x, (int)y);
            bool        hitTest  = false;
            DXFPolyline biggest  = null;
            int         maxWidth = 0;

            foreach (var obj in Shapes)                     //iterates through the objects
            {
                DXFPolyline temp = (DXFPolyline)obj;
                if (drawList.Contains(temp.LayerIndex))
                {
                    if (temp.HitTest(hitPoint))
                    {
                        if (temp.ItemLineWidth > maxWidth)
                        {
                            maxWidth = temp.ItemLineWidth;
                            biggest  = temp;
                        }

                        hitTest |= true;
                    }
                }
            }
            if (biggest != null)
            {
                biggest.Highlight(hitPoint);
            }
            if (rotate90)
            {
                foreach (var obj in Shapes)                     //iterates through the objects
                {
                    DXFPolyline temp = (DXFPolyline)obj;
                    if (drawList.Contains(temp.LayerIndex))
                    {
                        if (temp.Highlight(new System.Drawing.Point(-1 * (int)y, (int)x)))
                        {
                            hitTest |= true;
                            break;
                        }
                    }
                }
            }

            if (mirror)
            {
                foreach (var obj in Shapes)                     //iterates through the objects
                {
                    DXFPolyline temp = (DXFPolyline)obj;
                    if (drawList.Contains(temp.LayerIndex))
                    {
                        if (temp.Highlight(new System.Drawing.Point(-1 * (int)x, -1 * (int)y)))
                        {
                            hitTest |= true;
                            break;
                        }
                    }
                }

                if (rotate90)
                {
                    foreach (var obj in Shapes)                     //iterates through the objects
                    {
                        DXFPolyline temp = (DXFPolyline)obj;
                        if (drawList.Contains(temp.LayerIndex))
                        {
                            if (temp.Highlight(new System.Drawing.Point((int)y, -1 * (int)x)))
                            {
                                hitTest |= true;
                                break;
                            }
                        }
                    }
                }
            }


            return(hitTest);
        }
Beispiel #4
0
        public void Draw(System.Drawing.Image pictureBox1)
        {
            ScaleImage(pictureBox1.Width, pictureBox1.Height);

            var drawList = Layers.Where(x => x.Visible).Select(x => x.LayerName).ToList();
            var colors   = Enum.GetNames(typeof(KnownColor)).Where(item => !item.StartsWith("Control")).OrderBy(item => item).Select(x => Color.FromName(x)).ToArray();

            using (var g = Graphics.FromImage(pictureBox1))
            {
                Rectangle rect = new Rectangle(0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height);


                System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(
                    rect,
                    Color.Black,
                    Color.Black,
                    System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);
                g.FillRectangle(brush, rect);


                var offset = new System.Drawing.Point((int)XMin, (int)YMin);
                foreach (var corner in Corners)
                {
                    if (corner != null && corner.X != 0 && corner.Y != 0)
                    {
                        using (var lePen2 = new Pen(Color.Yellow, 4))
                        {
                            g.DrawEllipse(lePen2, (float)(corner.X - offset.X) * (float)mainScale - 10, (float)(corner.Y - offset.Y) * (float)mainScale - 10, 20, 20);
                        }
                    }
                }

                if (Marker != null && Marker.X != 0 && Marker.Y != 0)
                {
                    using (var lePen2 = new Pen(Color.AliceBlue, 4))
                    {
                        g.DrawEllipse(lePen2, (float)(Marker.X - offset.X) * (float)mainScale - 10, (float)(Marker.Y - offset.Y) * (float)mainScale - 10, 20, 20);
                    }
                }

                Pen lePen = new Pen(Color.White, 3);

                int cc = 0;
                foreach (var obj in Shapes)                     //iterates through the objects
                {
                    DXFPolyline temp = (DXFPolyline)obj;
                    if (drawList.Contains(temp.LayerIndex))
                    {
                        if (temp.AccessContourColor.Name == "White")
                        {
                            lePen.Color = colors[cc];
                        }
                        else
                        {
                            lePen.Color = temp.AccessContourColor;
                        }
                        lePen.Width = (float)Math.Max(1, temp.AccessLineWidth * mainScale);


                        if (mainScale == 0)
                        {
                            mainScale = 1;
                        }

                        temp.Draw(lePen, g, mainScale, new System.Drawing.Point((int)XMin, (int)YMin));
                        cc++;
                    }
                }

                lePen.Dispose();
                brush.Dispose();
            }
        }