C#这段代码的作用
来源:百度知道 编辑:UC知道 时间:2024/06/20 17:31:14
作者:zys19860718
问题:http://zhidao.baidu.com/question/94668988.html
仅寻求作者答复,谢谢
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.richTextBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.richTextBox1_MouseWheel);
}
private void richTextBox1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
int numberOfTextLinesToMove = e.Delta * SystemInformation.MouseWheelScrollLines / 120;
int numberOfPixelsToMove = numberOfTextLinesToMove * fontSize;
if (numberOfPixelsToMove != 0) {
System.Drawing.Drawing2D.Matrix translateMatrix = new System.Drawing.Drawing2D.Matrix();
translateMatrix.Translate(0, numberOfPixelsToMove);
mousePath.Transform(translateMatrix);
}
richTextBox1.Invalidate();
}
}
变量mousePath是什么?
tr
问题:http://zhidao.baidu.com/question/94668988.html
仅寻求作者答复,谢谢
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.richTextBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.richTextBox1_MouseWheel);
}
private void richTextBox1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
int numberOfTextLinesToMove = e.Delta * SystemInformation.MouseWheelScrollLines / 120;
int numberOfPixelsToMove = numberOfTextLinesToMove * fontSize;
if (numberOfPixelsToMove != 0) {
System.Drawing.Drawing2D.Matrix translateMatrix = new System.Drawing.Drawing2D.Matrix();
translateMatrix.Translate(0, numberOfPixelsToMove);
mousePath.Transform(translateMatrix);
}
richTextBox1.Invalidate();
}
}
变量mousePath是什么?
tr
不好意思,最近忙,那天没仔细看你的问题。只是把我的代码改名复制给你的。
这是全代码,你看看应该就懂了。新建WindowsFormsApplication1项目,把下面的代码复制进去运行就可以了。是在VS2008。如果是VS2005就把我注释的那段代码取消注释就可以了
mousePath存的是鼠标在两次点击之间经过的路径
invalidate()理解为跟新也可以
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
&n