当前位置:编程学习 > C#/ASP.NET >>

c# 之Region实现图形构造和填充代码

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Drawing.Drawing2D;
  9. namespace advanced_drawing
  10. {
  11.     public partial class Form15 : Form
  12.     {
  13.         public Form15()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.         private void Form15_Paint(object sender, PaintEventArgs e)
  18.         {
  19.             GraphicsPath myPath = new GraphicsPath();
  20.             string stringText = "zhuzhao";
  21.             FontFamily family = new FontFamily("Arial");
  22.             int fontStyle = (int)FontStyle.Italic;
  23.             int emSize = 26;
  24.             Point origin = new Point(20, 20);
  25.             StringFormat format = StringFormat.GenericDefault;
  26.             myPath.AddString(stringText,family,fontStyle,emSize,origin,format);
  27.             Region region = new Region(myPath);
  28.             e.Graphics.FillRegion(Brushes.Red, region);
  29.         }
  30.     }
  31. }
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,