📄 sample14.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)
{
TextureBrush testTB = new TextureBrush(
new Bitmap("C:\\w2k.jpg"));
Matrix testM = new Matrix();
testM.Translate(30, 0);
testTB.MultiplyTransform(testM);
//使用MultiplyTransform方法以指定顺序将表示此
//TextureBrush对象的局部几何变换的Matrix对象乘以指定的Matrix对象
Font testF=new Font("Arial",8);
Brush testB=new SolidBrush(Color.Black);
e.Graphics.DrawString("MultiplyTransform:",testF,testB,3,1);
e.Graphics.FillRectangle(testTB, 10, 15, 100, 120);
testTB.RotateTransform(90);
//使用RotateTransform方法将此TextureBrush对象的局部几何变换旋转指定的角度
e.Graphics.DrawString("RotateTransform:",testF,testB,10,145);
e.Graphics.FillRectangle(testTB, 10, 160, 100, 220);
testTB.ResetTransform();
//使用ResetTransform方法将此TextureBrush对象的Transform属性重置为单位矩阵
e.Graphics.DrawString("ResetTransform:",testF,testB,150,1);
e.Graphics.FillRectangle(testTB, 150, 15, 250, 100);
e.Graphics.DrawString("ScaleTransform:",testF,testB,150,145);
testTB.ScaleTransform(3, 1, MatrixOrder.Prepend);
//使用ScaleTransform方法将此TextureBrush对象的局部几何变换缩放指定的倍数
e.Graphics.FillRectangle(testTB, 150, 160, 250, 220);
e.Graphics.DrawString("TranslateTransform:",testF,testB,
450,1);
testTB.TranslateTransform(10, 0);
//使用TranslateTransform方法以指定顺序将此TextureBrush对象的局部几何变换平移指定的尺寸
e.Graphics.FillRectangle(testTB, 450, 15, 600, 120);
testTB.ResetTransform();
//使用ResetTransform方法将此TextureBrush对象的Transform属性重置为单位矩阵
e.Graphics.DrawString("ResetTransform:",testF,testB,450,145);
e.Graphics.FillRectangle(testTB,450,160,600,220);
}
*/
public static void Main()
{
TestExceptionHandler testE = new TestExceptionHandler();
Application.ThreadException += New ThreadExceptionEventHandler(testE.OnThreadException);
Application.Run(new Form1());
//使用Run方法在当前线程上开始运行标准应用程序消息循环
}
private void button1_Click(object sender, System.EventArgs e)
{
int i = 5;
string str=null;
for(int j=1; j<=i; j++)
{
str+=j;
}
listBox1.Items.Add(str);
if (MessageBox.Show("退出应用程序吗?", "",
MessageBoxButtons.YesNo) == DialogResult.No)
{
MessageBox.Show("请继续使用");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
throw new ArgumentException("找不到匹配项");
}
private void button3_Click(object sender, System.EventArgs e)
{
Application.Exit();
//使用Exit方法退出应用程序
}
}
internal class TestExceptionHandler
{
public void OnThreadException(object sender,ThreadExceptionEventArgs t)
{
//使用OnThreadException方法引发 ThreadException 事件
DialogResult result = DialogResult.Cancel;
try
{
result = this.ShowThreadExceptionDialog(t.Exception);
}
catch
{
try
{
MessageBox.Show("严重错误", "严重错误",
MessageBoxButtons.AbortRetryIgnore,
MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
if (result == DialogResult.Abort)
Application.Exit();
}
private DialogResult ShowThreadExceptionDialog(Exception e)
{
string errMsg="请和管理员联系,该程序出现以下错误: \n\n";errMsg = errMsg + e.Message + "\n\n栈跟踪结果:\n" + e.StackTrace;
return MessageBox.Show(errMsg,"应用程序错误:", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
}
}
/*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 + -