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

C#形状原点变换的方法

程序员文章站 2024-02-09 14:59:34
本文实例讲述了c#形状原点变换的方法。分享给大家供大家参考。具体实现方法如下: using system; using system.collections.g...

本文实例讲述了c#形状原点变换的方法。分享给大家供大家参考。具体实现方法如下:

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 form7 : form
  {
    public form7()
    {
      initializecomponent();
    }
    void drawlabelrect(graphics g, string label)
    {
      rectangle rect = new rectangle(0, 0, 125, 125);
      stringformat format = new stringformat();
      format.alignment = stringalignment.center;
      format.linealignment = stringalignment.center;
      g.fillrectangle(brushes.white, rect);
      g.drawrectangle(pens.black, rect.x, rect.y, rect.width, rect.height);
      g.drawstring(label, this.font, brushes.black, rect, format);
    }
    private void form7_paint(object sender, painteventargs e)
    {
      graphics g = e.graphics;
      drawlabelrect(g, "zhuzhao");
      matrix matrix = new matrix();
      matrix.translate(150, 150);
      g.transform = matrix;
      drawlabelrect(g, "zhuzhao123");
    }
  }
}

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