//本程序顯示如何旋轉顯示文本,代碼很簡單,不過個人覺得做學習用還是不錯的!
//作者: i.Posei(ipqn)
//歡迎訪問 www.kunwsoft.com
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
namespace eddy
{
public class Form1:System.Windows.Forms.Form
{
/// 必需的設計器變量。
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClIEntSize = new System.Drawing.Size(520, 520);
this.Name = "Form1";
this.Text = "旋轉顯示文本";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Paint(object sender,System.Windows.Forms.PaintEventArgs e)
{
//聲明並且初始化Graphics對象
Graphics g=e.Graphics;
g.SmoothingMode=SmoothingMode.AntiAlias;
string str="C#學習筆記 kunwsoft.com";
for(int i=0;i<360;i=i+10)
{
g.TranslateTransform(260,260);
//將指定旋轉應用於g的變換矩陣
g.RotateTransform(i);
Brush myBrush=Brushes.Red;
Font drawFont = new Font("宋體", 12);
g.DrawString(str,drawFont,myBrush,60,0);
g.ResetTransform();
}
}
}
}