⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample13.cs

📁 C#函数手册
💻 CS
字号:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
public class testAnimateImage : Form 
{
	Bitmap testB = new Bitmap("C:\\w2k.jpg");
	bool flag = false;	
	private void OnFrameChanged(object o, EventArgs e) 
	{
		this.Invalidate();
	}
	protected override void OnPaint(PaintEventArgs e) 
	{		
		Graphics  testG = e.Graphics;
		SolidBrush  testB = new SolidBrush(Color.Black);
		Font  testF = new Font("Arial", 8);
		StringFormat testSF = new StringFormat();
		string   str = "1 2 3 4 5";
		testSF.SetDigitSubstitution(0x0C01,StringDigitSubstitute.National);
		//使用SetDigitSubstitution方法替换以此 StringFormat 对象绘制的文本中的字符
		testG.DrawString("阿拉伯语:\n普通模式:" + str,
			testF, testB, new PointF(5, 10), testSF);
		testSF.SetDigitSubstitution(0x0C01,StringDigitSubstitute.Traditional);
		testG.DrawString("传统模式: "+str,testF,testB,
			new PointF(5, 35), testSF);
		testSF.SetDigitSubstitution(0x041E,StringDigitSubstitute.National);
		testG.DrawString("泰语:\n普通模式:" + str,testF, testB,new PointF(5, 60), testSF);testSF.SetDigitSubstitution(0x041E,StringDigitSubstitute.Traditional);
		testG.DrawString("传统模式: " + str,testF, testB, new PointF(5, 85), testSF);
		Rectangle  testR1 = new Rectangle(20, 110, 60, 180);
		Rectangle  testR2 = new Rectangle(65, 110, 120, 190);
		Rectangle  testR3 = new Rectangle(125, 110, 155, 230);
		testSF= new StringFormat();
		CharacterRange[] testCR =     
{
	new CharacterRange(3, 5), 
	new CharacterRange(15, 2),
	new CharacterRange(30, 15)
};
		Region[]testRn = new Region[testCR.Length];
		str ="ABC DEF GHI JKL MNO PQR STU VWX YZ  123 456 789 @ #";
		testSF.SetMeasurableCharacterRanges(testCR);
		//使用SetMeasurableCharacterRanges方法测定的字符的范围
		byte  i;    
		testRn = testG.MeasureCharacterRanges(str, testF,testR1, testSF);
		testG.DrawString(str, testF, Brushes.Blue, testR1, testSF );
		testG.DrawRectangle(Pens.Black, testR1);
		for ( i = 0; i < testRn.Length; i++ )testG.FillRegion(testB, testRn[i]);   
		testSF.FormatFlags= StringFormatFlags.MeasureTrailingSpaces;
		testRn = testG.MeasureCharacterRanges(str, testF,testR2, testSF);
		testG.DrawString(str, testF, Brushes.Blue, testR2, testSF );
		testG.DrawRectangle(Pens.Black, testR2);
		for ( i = 0; i < testRn.Length; i++ )
			testG.FillRegion(testB, testRn[i]);   
		testSF.FormatFlags = 0;   
		testRn = testG.MeasureCharacterRanges(str, testF,testR3, testSF);
		testG.DrawString(str, testF, Brushes.Blue, testR3, testSF );
		testG.DrawRectangle(Pens.Black, testR3);
		for ( i = 0; i < testRn.Length; i++ )
			testG.FillRegion(testB, testRn[i]); 
		testSF = new StringFormat();
		str = testSF.ToString();
		testG.DrawString("改变为字符串前:" + testSF,testF,testB, 120, 40);
		testSF.Trimming = StringTrimming.None;
		testSF.FormatFlags =StringFormatFlags.NoWrap	
			| StringFormatFlags.NoClip;
		str = testSF.ToString();
		//使用ToString方法将此 StringFormat 对象转换为可读的字符串
		testG.DrawString("改变为字符串后:" + testSF,testF, testB, 120, 70);
	}

	public static void Main() 
	{
		Application.Run(new testAnimateImage());
	}

	private void InitializeComponent()
	{
		// 
		// testAnimateImage
		// 
		this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
		this.ClientSize = new System.Drawing.Size(292, 273);
		this.Name = "testAnimateImage";
		//this.Load += new System.EventHandler(this.testAnimateImage_Load);

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -