欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#中GraphicsPath的AddString方法用法实例

程序员文章站 2022-10-15 16:03:00
本文实例讲述了c#中graphicspath的addstring方法用法。分享给大家供大家参考。具体如下: using system; using system...

本文实例讲述了c#中graphicspath的addstring方法用法。分享给大家供大家参考。具体如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
namespace advanced_drawing
{
  public partial class form14 : form
  {
    public form14()
    {
      initializecomponent();
    }
    private void form14_paint(object sender, painteventargs e)
    {
      // create a graphicspath object.
      graphicspath mypath = new graphicspath();
      // set up all the string parameters.
      string stringtext = "sample text";
      fontfamily family = new fontfamily("arial");
      int fontstyle = (int)fontstyle.italic;
      int emsize = 26;
      point origin = new point(20, 20);
      stringformat format = stringformat.genericdefault;
      // add the string to the path.
      mypath.addstring(stringtext,
        family,
        fontstyle,
        emsize,
        origin,
        format);
      //draw the path to the screen.
      e.graphics.fillpath(brushes.black, mypath);
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。