private void UploadToImgurBounds() { // prevent blackening if (!isTakingSnapshot) { isTakingSnapshot = true; Program.hotkeysEnabled = false; //back cover used for pulling cursor position into updateSelectedArea() magn = new Magnificator(); completeCover backCover = new completeCover(this); backCover.Show(); backCover.SetBounds(SystemInformation.VirtualScreen.X, SystemInformation.VirtualScreen.Y, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); backCover.TopMost = false; magn.Show(); magn.TopMost = true; //backCover.BackColor = Color.White; //backCover.Opacity = 0.1; setBox(topBox); setBox(leftBox); setBox(bottomBox); setBox(rightBox); } }
public void updateSelectedArea(completeCover backCover, bool keyPressed, bool escapePressed)//this thing is essentially a f*****g frame-loop. { backCover.Activate(); magn.Bounds = new Rectangle(Cursor.Position.X + 32, Cursor.Position.Y - 32, 124, 124); if (wasPressed != (MouseButtons == MouseButtons.Left)) { if (wasPressed)//keyUp { magn.Close(); if (!Properties.Settings.Default.FreezeScreenOnRegionShot) { backCover.Close(); } topBox.Hide(); bottomBox.Hide(); leftBox.Hide(); rightBox.Hide(); if (Width > 0 && Height > 0) { playSound("snip.wav"); Bitmap result = cap.Capture(enmScreenCaptureMode.Bounds, X, Y, Width, Height); if (Properties.Settings.Default.FreezeScreenOnRegionShot) { backCover.Close(); } File.Delete(System.IO.Path.GetTempPath() + "screenshot.png"); result.Save(System.IO.Path.GetTempPath() + "screenshot.png"); result.Dispose(); if (Properties.Settings.Default.EditScreenshotAfterCapture) { uploadImageFile(System.IO.Path.GetTempPath() + "screenshot.png", true); } else { uploadImageFile(System.IO.Path.GetTempPath() + "screenshot.png"); } } else { } if (Properties.Settings.Default.FreezeScreenOnRegionShot) { backCover.Close(); } isTakingSnapshot = false; Program.hotkeysEnabled = true; } else//keyDown { tempX = Cursor.Position.X; tempY = Cursor.Position.Y; } } if (MouseButtons == MouseButtons.Left) { topBox.SetBounds(X, Y, Width, 0); bottomBox.SetBounds(X, Height + Y, Width, 0); leftBox.SetBounds(X, Y, 0, Height); rightBox.SetBounds(Width + X, Y, 0, Height); Width = Math.Abs(Cursor.Position.X - tempX); Height = Math.Abs(Cursor.Position.Y - tempY); Y = tempY; X = tempX; if ((Cursor.Position.Y - tempY) < 0) { Y = tempY + (Cursor.Position.Y - tempY); } if ((Cursor.Position.X - tempX) < 0) { X = tempX + (Cursor.Position.X - tempX); } } if (escapePressed) { magn.Close(); backCover.Close(); topBox.Hide(); bottomBox.Hide(); leftBox.Hide(); rightBox.Hide(); isTakingSnapshot = false; Program.hotkeysEnabled = true; } wasPressed = MouseButtons == MouseButtons.Left; }