📄 sample10.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)
{
Pen testP= new Pen(Color.Black, 5);
Pen testCP = (Pen)testP.Clone();
//使用Clone方法创建此 Pen 对象的一个精确副本
e.Graphics.DrawLine(testCP, 0, 0, 100, 100);
Matrix testM = new Matrix();
testM.Scale(3, 1);
testP.MultiplyTransform (testM,MatrixOrder.Prepend);
//使用MultiplyTransform方法用指定的 Matrix 乘以此Pen 对象的变换矩阵
e.Graphics.DrawLine(testP, 20,10, 80, 10);
e.Graphics.DrawRectangle(testP, 30, 20, 100, 100);
testP.ScaleTransform(2, 1);
//使用ScaleTransform方法按指定因子缩放局部几何变换
testP.RotateTransform(90);
//使用RotateTransform方法将局部几何变换旋转指定角度
e.Graphics.DrawRectangle(testP, 140, 10, 100, 100);
testP.ScaleTransform(2, 1);
e.Graphics.DrawLine(testP, 10,60, 30, 200);
testP.ResetTransform();
//使用ResetTransform方法将此 Pen 对象的几何变换矩阵重置为单位矩阵
e.Graphics.DrawLine(testP, 50, 0, 50, 60);
testP.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
//使用SetLineCap方法设置用于确定帽样式的值
e.Graphics.DrawLine(testP, 80, 20, 200, 10);
}
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 + -