예제 #1
0
        private void canvas_Paint(object sender, PaintEventArgs e)
        {
            ShapesDrawnLabel.Text = _shapes.Count.ToString();

            FastBitmap fastBitmap = new FastBitmap(new Bitmap(canvas.Width, canvas.Height, e.Graphics), false);

            PaintTools paintTools = new PaintTools(canvas, fastBitmap, e.Graphics);

            _DrawGrid(paintTools);

            _DrawShapes(paintTools);
        }
예제 #2
0
        //private void canvas_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        //{
        //    switch (e.KeyCode)
        //    {
        //        case Keys.Down:
        //        case Keys.Up:
        //            e.IsInputKey = true;
        //            break;
        //    }
        //}

        private void _DrawShapes(PaintTools paintTools)
        {
            foreach (Shape shape in _shapes)
            {
                shape.DrawFilling(paintTools);
            }

            paintTools.Graphics.DrawImage(paintTools.Bitmap.GetBitmap(), new Point(0, 0));

            foreach (Shape shape in _shapes)
            {
                shape.DrawContours(paintTools);
            }
        }
예제 #3
0
        private void _DrawGrid(PaintTools paintTools)
        {
            int numOfCells = 50, cellSize = 30;

            for (int y = 0; y < numOfCells; ++y)
            {
                Segment segment = new Segment(new PointD(0, y * cellSize),
                                              new PointD(numOfCells * cellSize, y * cellSize),
                                              _meshPen.Color);

                segment.Draw(paintTools);
            }

            for (int x = 0; x < numOfCells; ++x)
            {
                Segment segment = new Segment(new PointD(x * cellSize, 0),
                                              new PointD(x * cellSize, numOfCells * cellSize),
                                              _meshPen.Color);

                segment.Draw(paintTools);
            }
        }