Пример #1
0
        static void TestFillPie()
        {
            Canvas canvas = new Canvas(showForm1.CreateGraphics());
            Painter painter = new Painter(canvas);

            Brush blueBrush = new SolidBrush(Color.Blue);
            Rectangle fanRect = new Rectangle(100, 100, 50, 50);
            painter.FillPie(blueBrush, fanRect, 0, 60);

            canvas.g = null;
        }
Пример #2
0
        static void TestDrawRectangle()
        {
            Canvas canvas = new Canvas(showForm1.CreateGraphics());
            Painter painter = new Painter(canvas);

            Pen pen = new Pen(Color.Blue);
            Rectangle rect = new Rectangle(200, 200, 50, 50);
            painter.DrawRectangle(pen, rect);

            canvas.g = null;
        }
Пример #3
0
        static void TestDrawPolygon()
        {
            Canvas canvas = new Canvas(showForm1.CreateGraphics());
            Painter painter = new Painter(canvas);

            Pen pen = new Pen(Color.Blue);
            Point[] points = { new Point(10, 10), new Point(100, 100), new Point(10, 200) };
            painter.DrawPolygon(pen, points);

            canvas.g = null;
        }
Пример #4
0
        static void TestDrawOnBitmap()
        {
            showForm2 = new Form();
            showForm2.Width = 600;
            showForm2.Height = 600;
            showForm2.Show();

            //draw on bitmap
            Bitmap b = new Bitmap(400, 400);

            Canvas canvas = new Canvas(Graphics.FromImage(b));
            Painter painter = new Painter(canvas);

            //draw a line
            Pen pen = new Pen(Color.Red, 1);
            pen.DashStyle = DashStyle.DashDotDot;
            painter.DrawLine(pen, 5, 5, 100, 100);

            //draw a pie
            LinearGradientBrush mylbrush = new LinearGradientBrush(new Rectangle(20, 80, 250, 100),
                   Color.DarkOrange, Color.Aquamarine,
                   LinearGradientMode.BackwardDiagonal);
            Rectangle fanRect = new Rectangle(100, 100,200, 200);
            painter.FillPie(mylbrush, fanRect, 0, 60);

            //show a bitmap onto pictureBox
            PictureBox pictureBox = new PictureBox();
            pictureBox.Size = new Size(500,500);
            pictureBox.BorderStyle = BorderStyle.FixedSingle;

            showForm2.Controls.Add(pictureBox);
            pictureBox.Image = Image.FromHbitmap(b.GetHbitmap());
            pictureBox.Refresh();

            canvas.g = null;
        }
Пример #5
0
        static void TestDrawLine()
        {
            Canvas canvas = new Canvas(showForm1.CreateGraphics());
            Painter painter = new Painter(canvas);

            Pen pen = new Pen(Color.Red, 2.5f);
            painter.DrawLine(pen, 5, 5, 100, 100);

            canvas.g = null;
        }
Пример #6
0
 static void TestClear()
 {
     Canvas canvas = new Canvas(showForm1.CreateGraphics());
     Painter painter = new Painter(canvas);
     painter.Clear(showForm1.BackColor);
     canvas.g = null;
 }