代码为一个用户定义类Drawing当中的构造方法,我从代码:
PictureBox.MouseWheel += PictureBox_MouseWheel;
标记处开始不明白,构造方法不是在创建实例时调用且仅调用一次的吗?那么从
PictureBox.MouseWheel += PictureBox_MouseWheel;
哪有什么作用呢,鼠标在PictureBox上触发的事件还会再一次调用构造方法吗?
编程小白在线等
public Drawing(PictureBox pictureBox)
{
PictureBox = pictureBox;
Points = new List<PointF>();
PaintPoints = new List<PointF>();
PictureBox.MouseWheel += PictureBox_MouseWheel;
PictureBox.MouseDown += PictureBox_MouseDown;
PictureBox.MouseUp += PictureBox_MouseUp;
PictureBox.MouseMove += PictureBox_MouseMove;
PictureBox.MouseEnter+=PictureBox_MouseEnter;
PictureBox.Paint += PictureBox_Paint;
}