日期:2014-05-18 浏览次数:21129 次
private bool isMoving = false;
        private int x, y;
        private void mouseDown(object sender, MouseEventArgs e)
        {
            this.pictureBox1.Focus();
            isMoving = true;
            x = e.X;
            y = e.Y;
        }
        private void mouseMove(object sender, MouseEventArgs e)
        {
            if (isMoving)
            {
                this.pictureBox1.Left += (e.X - x);
                this.pictureBox1.Top += (e.Y - y);
            }
        }
        private void mouseUp(object sender, MouseEventArgs e)
        {
            isMoving = false;
        }
        private void PictureBox1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                pictureBox1.Width = Convert.ToInt32(pictureBox1.Width * 0.8);
                pictureBox1.Height = Convert.ToInt32(pictureBox1.Height * 0.8);
            }
            else
            {
                pictureBox1.Width = Convert.ToInt32(pictureBox1.Width / 0.8);
                pictureBox1.Height = Convert.ToInt32(pictureBox1.Height / 0.8);
            }
        }
int imgWidth = this.pictureBox1.Image.Width;
int width = this.pictureBox1.Width;
if (width / imgWidth >= 8) return; // 放大
if((float)width / (float)imgWidth <= 0.1) return; // 缩小