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; }
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; }