Beispiel #1
0
        private void AddVertex(Point point)
        {
            ListViewItem item = new ListViewItem(new string[] { point.X + "", point.Y + "" });

            item.Tag = point;

            lstPartVertexes.Items.Add(item);

            DrawSchematic();
        }
        private static Bitmap DrawSingleCoordinate(Bitmap bitmap, Font font, Color fontColor, Point vertex, Point coordinates)
        {
            Graphics graphics = Graphics.FromImage(bitmap);

            string text = coordinates.ToString();

            float x = vertex.X;
            float y = vertex.Y;

            SizeF  size         = graphics.MeasureString(text, font);
            Bitmap stringBitmap = new Bitmap((int)size.Width, (int)size.Height);

            Graphics.FromImage(stringBitmap).DrawString(text, font, new SolidBrush(fontColor), 0, 0);

            stringBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
            graphics.DrawImage(stringBitmap, x, y);

            return(bitmap);
        }
Beispiel #3
0
        private void AddVertexToPart(object sender, EventArgs e)
        {
            Point point = new Point((float)numXInternal.Value, (float)numYInternal.Value);

            AddVertex(point);
        }
        private static Bitmap DrawPolygon(Bitmap bitmap, List <Point> vertexes, Pen pen, Point vector = null)
        {
            if (vertexes.Count == 0)
            {
                return(bitmap);
            }

            Graphics graphics = Graphics.FromImage(bitmap);

            float vectorX = 0;
            float vectorY = 0;

            if (vector != null)
            {
                vectorX = vector.X;
                vectorY = vector.Y;
            }

            for (int i = 0; i < vertexes.Count - 1; i++)
            {
                graphics.DrawLine(pen, vertexes[i].X + vectorX, vertexes[i].Y + vectorY, vertexes[i + 1].X + vectorX, vertexes[i + 1].Y + vectorY);
            }

            graphics.DrawLine(pen, vertexes.Last().X + vectorX, vertexes.Last().Y + vectorY, vertexes.First().X + vectorX, vertexes.First().Y + vectorY);

            return(bitmap);
        }