1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63:
| private void frmMain_WheelUsage(object sender, MouseEventArgs e) { if (Properties.Settings.Default.useScrollWheel == true) { if (e.Delta > 0) picBack(); else if (e.Delta < 0) picForward(); } else if (opened == true) { if (zoomed == false) { pbMain.Dock = DockStyle.None; pbMain.SizeMode = PictureBoxSizeMode.StretchImage; } pbMain.Size = getDimension(); zoomed = true; pbMain.SendToBack(); if (e.Delta > 0) { int tempX = pbMain.Size.Width + 30; int tempY = pbMain.Size.Height + 30; int posX = pbMain.Location.X - 15; int posY = pbMain.Location.Y - 15; pbMain.Size = new Size(tempX, tempY); pbMain.Location = new Point(posX, posY); } else if (e.Delta < 0) { int tempX = pbMain.Size.Width - 30; int tempY = pbMain.Size.Height - 30; int posX = pbMain.Location.X + 15; int posY = pbMain.Location.Y + 15; pbMain.Size = new Size(tempX, tempY); pbMain.Location = new Point(posX, posY); } } }
Size getDimension() { if (pbMain.Image.Size.Width > pbMain.Size.Width || pbMain.Image.Size.Height > pbMain.Size.Height) { double dimension = (double)pbMain.Image.Size.Width / (double)pbMain.Image.Size.Height; double temp1 = (double)pbMain.Image.Size.Width / (double)pbMain.Size.Width; double temp2 = (double)pbMain.Image.Size.Height / (double)pbMain.Size.Height;
if (temp1 > temp2) { double breite = dimension * (double)pbMain.Size.Height; return new Size((int)breite, pbMain.Size.Height); } else { double hoehe = (double)pbMain.Size.Width / dimension; return new Size(pbMain.Size.Width, (int)hoehe); } } else { return new Size(pbMain.Image.Size.Width, pbMain.Image.Size.Height); } } |