C#类属性方法.docxVIP

  • 10
  • 0
  • 约7.04万字
  • 约 82页
  • 2018-06-30 发布于天津
  • 举报
C#类amp;属性amp;方法.docx

一、关于缩放(MouseEvent)1、实例一public FrmZone() { InitializeComponent(); //实现鼠标拖效果,这些事件可以直接在属性里面添加,我写这里是为了让你看得更清楚 this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp); //设置鼠标滚轮事件,滚动鼠标时,改变图像的大小 this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.test_MouseWheel); //设置图处显示为缩略图 this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; }private void test_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e) { System.Drawing.Size t = pictureBox1.Size; t.Width += e.Delta; t.Height += e.Delta; //设置最小显示大小 if (t.Width 40) t.Width = 40; if (t.Height 30) t.Height = 30; //设置最大显示大小 if (t.Width 600) t.Width = 600; if (t.Height 450) t.Height = 450; //if (t.Width = 600 t.Height = 450) //{ // this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); // this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); // this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp); //} //else //{ // this.pictureBox1.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); // this.pictureBox1.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); // this.pictureBox1.MouseUp -= new System.Windows.Forms.MouseEventHandler(this.pictureBo

文档评论(0)

1亿VIP精品文档

相关文档