Beispiel #1
0
 public EditorForm()
 {
     InitializeComponent();
     MemoryBitmap     = new MemoryBitmap(canvasPictureBox.Width, canvasPictureBox.Height);
     currentTool      = new Tools.MovePointTool(this);
     clearThreadStart = new ThreadStart(MemoryBitmap.Clear);
     clearThread      = new Thread(clearThreadStart);
     clearThread.Start();
     LoadDefaultScene();
 }
Beispiel #2
0
        private static void DrawRestrictionIcon(MemoryBitmap bitmap, Edge.Restriction restriction, int startX, int startY, int endX, int endY)
        {
            switch (restriction)
            {
            case Edge.Restriction.SameSize:
                DrawRestrictionSameSizeIcon(bitmap, startX, startY, endX, endY);
                break;

            case Edge.Restriction.Perpendicular:
                DrawRestrictionPerpendicularIcon(bitmap, startX, startY, endX, endY);
                break;
            }
        }
Beispiel #3
0
        private static void DrawRestrictionSameSizeIcon(MemoryBitmap bitmap, int startX, int startY, int endX, int endY)
        {
            startY = (startY + endY) / 2 - 3;
            endY   = startY + 6;
            startX++;
            endX--;

            for (int x = startX; x <= endX; x++)
            {
                bitmap.SetPixel(x, startY, Color.Black);
                bitmap.SetPixel(x, endY, Color.Black);
            }
        }
Beispiel #4
0
        private static void DrawRestrictionPerpendicularIcon(MemoryBitmap bitmap, int startX, int startY, int endX, int endY)
        {
            startX = (startX + endX) / 2 - 1;
            endX   = startX + 2;
            startY = (startY + endY) / 2 - 1;
            endY   = startY + 2;

            for (int x = startX; x <= endX; x++)
            {
                for (int y = startY; y <= endY; y++)
                {
                    bitmap.SetPixel(x, y, Color.Black);
                }
            }
        }
Beispiel #5
0
        private void CanvasPictureBox_Paint(object sender, PaintEventArgs e)
        {
            clearThread.Join();
            MemoryBitmap.CreateGraphics();
            foreach (Figures.Polygon polygon in Polygons)
            {
                polygon.Draw(MemoryBitmap);
            }
            currentTool.OnDrawGizmos();
            Bitmap b = MemoryBitmap.Bitmap;

            e.Graphics.DrawImageUnscaled(b, 0, 0);
            MemoryBitmap.DisposeGraphics();
            clearThread = new Thread(clearThreadStart);
            clearThread.Start();
        }
Beispiel #6
0
        public static void DrawRestrictionLabel(Figures.Edge e, MemoryBitmap bitmap,
                                                Color?color = null, Figures.Edge.Restriction?restriction = null)
        {
            int   restrictionBoxSizeDiv2 = Helper.restrictionBoxSize / 2;
            Point point = new Point(((int)e.Previous.X + (int)e.Next.X) / 2, ((int)e.Previous.Y + (int)e.Next.Y) / 2);
            int   startX = point.X - restrictionBoxSize, endX = point.X + restrictionBoxSize;
            int   midX = (endX + startX) / 2;
            int   startY = point.Y - restrictionBoxSizeDiv2, endY = point.Y + restrictionBoxSizeDiv2;

            for (int x = startX; x <= midX; x++)
            {
                for (int y = startY; y <= endY; y++)
                {
                    bitmap.SetPixel(x, y, color.HasValue ? color.Value.ToArgb() : e.RestrictionData);
                }
            }
            for (int x = midX; x <= endX; x++)
            {
                for (int y = startY; y <= endY; y++)
                {
                    bitmap.SetPixel(x, y, color.HasValue ? color.Value.ToArgb() : e.RestrictionData);
                }
            }
            for (int x = startX + 1; x <= midX - 1; x++)
            {
                for (int y = startY + 1; y <= endY - 1; y++)
                {
                    bitmap.SetPixel(x, y, Color.White);
                }
            }
            for (int x = startX + 1; x <= endX - 1; x++)
            {
                for (int y = startY + 1; y <= endY - 1; y++)
                {
                    bitmap.SetPixel(x, y, Color.White);
                }
            }
            Graphics g = bitmap.GetGraphics();

            g.DrawString(restriction.HasValue ? "X" : e.RestrictionNum.ToString(), f, Brushes.Black, midX + padding, startY + padding);
            if (!restriction.HasValue)
            {
                restriction = e.EnactedRestriction;
            }
            DrawRestrictionIcon(bitmap, restriction.Value, startX + padding, startY + padding, midX - padding, endY - padding);
        }
Beispiel #7
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     base.OnFormClosing(e);
     MemoryBitmap.Dispose();
 }