mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Code quality fixes (NullReference checks, unused variables etc)
This commit is contained in:
parent
6ab6033f85
commit
ac08533727
99 changed files with 1252 additions and 1312 deletions
|
@ -18,24 +18,22 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Globalization;
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Controls;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
/// <summary>
|
||||
|
@ -44,44 +42,43 @@ namespace Greenshot.Forms {
|
|||
public partial class CaptureForm : AnimatingForm {
|
||||
private enum FixMode {None, Initiated, Horizontal, Vertical};
|
||||
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(CaptureForm));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Brush GreenOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.MediumSeaGreen));
|
||||
private static Brush RedOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.DarkRed));
|
||||
private static Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||
private static CaptureForm currentForm = null;
|
||||
private static Brush backgroundBrush = null;
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(CaptureForm));
|
||||
private static readonly CoreConfiguration Conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly Brush GreenOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.MediumSeaGreen));
|
||||
private static readonly Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||
private static CaptureForm _currentForm;
|
||||
private static readonly Brush BackgroundBrush;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the background brush
|
||||
/// </summary>
|
||||
static CaptureForm() {
|
||||
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
||||
backgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
|
||||
Image backgroundForTransparency = GreenshotResources.getImage("Checkerboard.Image");
|
||||
BackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
|
||||
}
|
||||
|
||||
private int mX;
|
||||
private int mY;
|
||||
private Point mouseMovePos = Point.Empty;
|
||||
private Point cursorPos = Point.Empty;
|
||||
private CaptureMode captureMode = CaptureMode.None;
|
||||
private List<WindowDetails> windows = new List<WindowDetails>();
|
||||
private WindowDetails selectedCaptureWindow;
|
||||
private bool mouseDown = false;
|
||||
private Rectangle captureRect = Rectangle.Empty;
|
||||
private ICapture capture = null;
|
||||
private Image capturedImage = null;
|
||||
private Point previousMousePos = Point.Empty;
|
||||
private FixMode fixMode = FixMode.None;
|
||||
private RectangleAnimator windowAnimator = null;
|
||||
private RectangleAnimator zoomAnimator = null;
|
||||
private bool isZoomerTransparent = conf.ZoomerOpacity < 1;
|
||||
private int _mX;
|
||||
private int _mY;
|
||||
private Point _mouseMovePos = Point.Empty;
|
||||
private Point _cursorPos = Point.Empty;
|
||||
private CaptureMode _captureMode = CaptureMode.None;
|
||||
private readonly List<WindowDetails> _windows = new List<WindowDetails>();
|
||||
private WindowDetails _selectedCaptureWindow;
|
||||
private bool _mouseDown;
|
||||
private Rectangle _captureRect = Rectangle.Empty;
|
||||
private readonly ICapture _capture;
|
||||
private readonly Image _capturedImage;
|
||||
private Point _previousMousePos = Point.Empty;
|
||||
private FixMode _fixMode = FixMode.None;
|
||||
private RectangleAnimator _windowAnimator;
|
||||
private RectangleAnimator _zoomAnimator;
|
||||
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
|
||||
/// <summary>
|
||||
/// Property to access the selected capture rectangle
|
||||
/// </summary>
|
||||
public Rectangle CaptureRectangle {
|
||||
get {
|
||||
return captureRect;
|
||||
return _captureRect;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +87,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
public CaptureMode UsedCaptureMode {
|
||||
get {
|
||||
return captureMode;
|
||||
return _captureMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +96,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
public WindowDetails SelectedCaptureWindow {
|
||||
get {
|
||||
return selectedCaptureWindow;
|
||||
return _selectedCaptureWindow;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,14 +117,14 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="capture"></param>
|
||||
/// <param name="windows"></param>
|
||||
public CaptureForm(ICapture capture, List<WindowDetails> windows) : base() {
|
||||
if (currentForm != null) {
|
||||
public CaptureForm(ICapture capture, List<WindowDetails> windows) {
|
||||
if (_currentForm != null) {
|
||||
LOG.Debug("Found currentForm, Closing already opened CaptureForm");
|
||||
currentForm.Close();
|
||||
currentForm = null;
|
||||
_currentForm.Close();
|
||||
_currentForm = null;
|
||||
Application.DoEvents();
|
||||
}
|
||||
currentForm = this;
|
||||
_currentForm = this;
|
||||
|
||||
// Enable the AnimatingForm
|
||||
EnableAnimation = true;
|
||||
|
@ -135,56 +132,56 @@ namespace Greenshot.Forms {
|
|||
// Using 32bppPArgb speeds up the drawing.
|
||||
//capturedImage = ImageHelper.Clone(capture.Image, PixelFormat.Format32bppPArgb);
|
||||
// comment the clone, uncomment the assignment and the original bitmap is used.
|
||||
capturedImage = capture.Image;
|
||||
_capturedImage = capture.Image;
|
||||
|
||||
// clean up
|
||||
this.FormClosed += delegate {
|
||||
currentForm = null;
|
||||
FormClosed += delegate {
|
||||
_currentForm = null;
|
||||
LOG.Debug("Remove CaptureForm from currentForm");
|
||||
};
|
||||
|
||||
this.capture = capture;
|
||||
this.windows = windows;
|
||||
this.captureMode = capture.CaptureDetails.CaptureMode;
|
||||
_capture = capture;
|
||||
_windows = windows;
|
||||
_captureMode = capture.CaptureDetails.CaptureMode;
|
||||
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent();
|
||||
// Only double-buffer when we are not in a TerminalServerSession
|
||||
this.DoubleBuffered = !isTerminalServerSession;
|
||||
this.Text = "Greenshot capture form";
|
||||
DoubleBuffered = !isTerminalServerSession;
|
||||
Text = "Greenshot capture form";
|
||||
|
||||
// Make sure we never capture the captureform
|
||||
WindowDetails.RegisterIgnoreHandle(this.Handle);
|
||||
WindowDetails.RegisterIgnoreHandle(Handle);
|
||||
// Unregister at close
|
||||
this.FormClosing += delegate {
|
||||
FormClosing += delegate {
|
||||
// remove the buffer if it was created inside this form
|
||||
if (capturedImage != capture.Image) {
|
||||
capturedImage.Dispose();
|
||||
if (_capturedImage != capture.Image) {
|
||||
_capturedImage.Dispose();
|
||||
}
|
||||
LOG.Debug("Closing captureform");
|
||||
WindowDetails.UnregisterIgnoreHandle(this.Handle);
|
||||
WindowDetails.UnregisterIgnoreHandle(Handle);
|
||||
};
|
||||
|
||||
// set cursor location
|
||||
cursorPos = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||
_cursorPos = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||
|
||||
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
||||
if (captureMode == CaptureMode.Window) {
|
||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||
if (_captureMode == CaptureMode.Window) {
|
||||
_windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||
}
|
||||
|
||||
// Set the zoomer animation
|
||||
InitializeZoomer(conf.ZoomerEnabled);
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
|
||||
this.SuspendLayout();
|
||||
this.Bounds = capture.ScreenBounds;
|
||||
this.ResumeLayout();
|
||||
SuspendLayout();
|
||||
Bounds = capture.ScreenBounds;
|
||||
ResumeLayout();
|
||||
|
||||
// Fix missing focus
|
||||
WindowDetails.ToForeground(this.Handle);
|
||||
this.TopMost = true;
|
||||
WindowDetails.ToForeground(Handle);
|
||||
TopMost = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -193,17 +190,17 @@ namespace Greenshot.Forms {
|
|||
void InitializeZoomer(bool isOn) {
|
||||
if (isOn) {
|
||||
// Initialize the zoom with a invalid position
|
||||
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||
VerifyZoomAnimation(cursorPos, false);
|
||||
} else if (zoomAnimator != null) {
|
||||
zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000));
|
||||
_zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||
VerifyZoomAnimation(_cursorPos, false);
|
||||
} else if (_zoomAnimator != null) {
|
||||
_zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000));
|
||||
}
|
||||
}
|
||||
|
||||
#region key handling
|
||||
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
||||
if (e.KeyCode == Keys.ShiftKey) {
|
||||
fixMode = FixMode.None;
|
||||
_fixMode = FixMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,9 +225,8 @@ namespace Greenshot.Forms {
|
|||
break;
|
||||
case Keys.ShiftKey:
|
||||
// Fixmode
|
||||
if (fixMode == FixMode.None) {
|
||||
fixMode = FixMode.Initiated;
|
||||
return;
|
||||
if (_fixMode == FixMode.None) {
|
||||
_fixMode = FixMode.Initiated;
|
||||
}
|
||||
break;
|
||||
case Keys.Escape:
|
||||
|
@ -239,7 +235,7 @@ namespace Greenshot.Forms {
|
|||
break;
|
||||
case Keys.M:
|
||||
// Toggle mouse cursor
|
||||
capture.CursorVisible = !capture.CursorVisible;
|
||||
_capture.CursorVisible = !_capture.CursorVisible;
|
||||
Invalidate();
|
||||
break;
|
||||
//// TODO: Enable when the screen capture code works reliable
|
||||
|
@ -253,43 +249,43 @@ namespace Greenshot.Forms {
|
|||
// Invalidate();
|
||||
// break;
|
||||
case Keys.Z:
|
||||
if (captureMode == CaptureMode.Region) {
|
||||
if (_captureMode == CaptureMode.Region) {
|
||||
// Toggle zoom
|
||||
conf.ZoomerEnabled = !conf.ZoomerEnabled;
|
||||
InitializeZoomer(conf.ZoomerEnabled);
|
||||
Conf.ZoomerEnabled = !Conf.ZoomerEnabled;
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case Keys.Space:
|
||||
// Toggle capture mode
|
||||
switch (captureMode) {
|
||||
switch (_captureMode) {
|
||||
case CaptureMode.Region:
|
||||
// Set the window capture mode
|
||||
captureMode = CaptureMode.Window;
|
||||
_captureMode = CaptureMode.Window;
|
||||
// "Fade out" Zoom
|
||||
InitializeZoomer(false);
|
||||
// "Fade in" window
|
||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||
captureRect = Rectangle.Empty;
|
||||
_windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||
_captureRect = Rectangle.Empty;
|
||||
Invalidate();
|
||||
break;
|
||||
case CaptureMode.Window:
|
||||
// Set the region capture mode
|
||||
captureMode = CaptureMode.Region;
|
||||
_captureMode = CaptureMode.Region;
|
||||
// "Fade out" window
|
||||
windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), FramesForMillis(700));
|
||||
_windowAnimator.ChangeDestination(new Rectangle(_cursorPos, Size.Empty), FramesForMillis(700));
|
||||
// Fade in zoom
|
||||
InitializeZoomer(conf.ZoomerEnabled);
|
||||
captureRect = Rectangle.Empty;
|
||||
InitializeZoomer(Conf.ZoomerEnabled);
|
||||
_captureRect = Rectangle.Empty;
|
||||
Invalidate();
|
||||
break;
|
||||
}
|
||||
selectedCaptureWindow = null;
|
||||
_selectedCaptureWindow = null;
|
||||
OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0));
|
||||
break;
|
||||
case Keys.Return:
|
||||
// Confirm
|
||||
if (captureMode == CaptureMode.Window) {
|
||||
if (_captureMode == CaptureMode.Window) {
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
break;
|
||||
|
@ -306,9 +302,9 @@ namespace Greenshot.Forms {
|
|||
void OnMouseDown(object sender, MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||
mX = tmpCursorLocation.X;
|
||||
mY = tmpCursorLocation.Y;
|
||||
mouseDown = true;
|
||||
_mX = tmpCursorLocation.X;
|
||||
_mY = tmpCursorLocation.Y;
|
||||
_mouseDown = true;
|
||||
OnMouseMove(this, e);
|
||||
Invalidate();
|
||||
}
|
||||
|
@ -320,18 +316,18 @@ namespace Greenshot.Forms {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnMouseUp(object sender, MouseEventArgs e) {
|
||||
if (mouseDown) {
|
||||
if (_mouseDown) {
|
||||
// If the mouse goes up we set down to false (nice logic!)
|
||||
mouseDown = false;
|
||||
_mouseDown = false;
|
||||
// Check if anything is selected
|
||||
if (captureMode == CaptureMode.Window && selectedCaptureWindow != null) {
|
||||
if (_captureMode == CaptureMode.Window && _selectedCaptureWindow != null) {
|
||||
// Go and process the capture
|
||||
DialogResult = DialogResult.OK;
|
||||
} else if (captureRect.Height > 0 && captureRect.Width > 0) {
|
||||
} else if (_captureRect.Height > 0 && _captureRect.Width > 0) {
|
||||
// correct the GUI width to real width if Region mode
|
||||
if (captureMode == CaptureMode.Region) {
|
||||
captureRect.Width += 1;
|
||||
captureRect.Height += 1;
|
||||
if (_captureMode == CaptureMode.Region) {
|
||||
_captureRect.Width += 1;
|
||||
_captureRect.Height += 1;
|
||||
}
|
||||
// Go and process the capture
|
||||
DialogResult = DialogResult.OK;
|
||||
|
@ -347,18 +343,18 @@ namespace Greenshot.Forms {
|
|||
/// <param name="currentMouse"></param>
|
||||
/// <returns></returns>
|
||||
private Point FixMouseCoordinates(Point currentMouse) {
|
||||
if (fixMode == FixMode.Initiated) {
|
||||
if (previousMousePos.X != currentMouse.X) {
|
||||
fixMode = FixMode.Vertical;
|
||||
} else if (previousMousePos.Y != currentMouse.Y) {
|
||||
fixMode = FixMode.Horizontal;
|
||||
if (_fixMode == FixMode.Initiated) {
|
||||
if (_previousMousePos.X != currentMouse.X) {
|
||||
_fixMode = FixMode.Vertical;
|
||||
} else if (_previousMousePos.Y != currentMouse.Y) {
|
||||
_fixMode = FixMode.Horizontal;
|
||||
}
|
||||
} else if (fixMode == FixMode.Vertical) {
|
||||
currentMouse = new Point(currentMouse.X, previousMousePos.Y);
|
||||
} else if (fixMode == FixMode.Horizontal) {
|
||||
currentMouse = new Point(previousMousePos.X, currentMouse.Y);
|
||||
} else if (_fixMode == FixMode.Vertical) {
|
||||
currentMouse = new Point(currentMouse.X, _previousMousePos.Y);
|
||||
} else if (_fixMode == FixMode.Horizontal) {
|
||||
currentMouse = new Point(_previousMousePos.X, currentMouse.Y);
|
||||
}
|
||||
previousMousePos = currentMouse;
|
||||
_previousMousePos = currentMouse;
|
||||
return currentMouse;
|
||||
}
|
||||
|
||||
|
@ -369,8 +365,8 @@ namespace Greenshot.Forms {
|
|||
/// <param name="e"></param>
|
||||
void OnMouseMove(object sender, MouseEventArgs e) {
|
||||
// Make sure the mouse coordinates are fixed, when pressing shift
|
||||
mouseMovePos = FixMouseCoordinates(WindowCapture.GetCursorLocation());
|
||||
mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(mouseMovePos);
|
||||
_mouseMovePos = FixMouseCoordinates(WindowCapture.GetCursorLocation());
|
||||
_mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(_mouseMovePos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -389,67 +385,66 @@ namespace Greenshot.Forms {
|
|||
/// update the frame, this only invalidates
|
||||
/// </summary>
|
||||
protected override void Animate() {
|
||||
Point lastPos = cursorPos.Clone();
|
||||
cursorPos = mouseMovePos.Clone();
|
||||
Point lastPos = _cursorPos;
|
||||
_cursorPos = _mouseMovePos;
|
||||
|
||||
if (selectedCaptureWindow != null && lastPos.Equals(cursorPos) && !isAnimating(zoomAnimator) && !isAnimating(windowAnimator)) {
|
||||
if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !isAnimating(_zoomAnimator) && !isAnimating(_windowAnimator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle lastCaptureRect = new Rectangle(captureRect.Location, captureRect.Size);
|
||||
WindowDetails lastWindow = selectedCaptureWindow;
|
||||
WindowDetails lastWindow = _selectedCaptureWindow;
|
||||
bool horizontalMove = false;
|
||||
bool verticalMove = false;
|
||||
|
||||
if (lastPos.X != cursorPos.X) {
|
||||
if (lastPos.X != _cursorPos.X) {
|
||||
horizontalMove = true;
|
||||
}
|
||||
if (lastPos.Y != cursorPos.Y) {
|
||||
if (lastPos.Y != _cursorPos.Y) {
|
||||
verticalMove = true;
|
||||
}
|
||||
|
||||
if (captureMode == CaptureMode.Region && mouseDown) {
|
||||
captureRect = GuiRectangle.GetGuiRectangle(cursorPos.X, cursorPos.Y, mX - cursorPos.X, mY - cursorPos.Y);
|
||||
if (_captureMode == CaptureMode.Region && _mouseDown) {
|
||||
_captureRect = GuiRectangle.GetGuiRectangle(_cursorPos.X, _cursorPos.Y, _mX - _cursorPos.X, _mY - _cursorPos.Y);
|
||||
}
|
||||
|
||||
// Iterate over the found windows and check if the current location is inside a window
|
||||
Point cursorPosition = Cursor.Position;
|
||||
selectedCaptureWindow = null;
|
||||
lock (windows) {
|
||||
foreach (WindowDetails window in windows) {
|
||||
_selectedCaptureWindow = null;
|
||||
lock (_windows) {
|
||||
foreach (WindowDetails window in _windows) {
|
||||
if (window.Contains(cursorPosition)) {
|
||||
// Only go over the children if we are in window mode
|
||||
if (CaptureMode.Window == captureMode) {
|
||||
selectedCaptureWindow = window.FindChildUnderPoint(cursorPosition);
|
||||
if (CaptureMode.Window == _captureMode) {
|
||||
_selectedCaptureWindow = window.FindChildUnderPoint(cursorPosition);
|
||||
} else {
|
||||
selectedCaptureWindow = window;
|
||||
_selectedCaptureWindow = window;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) {
|
||||
capture.CaptureDetails.Title = selectedCaptureWindow.Text;
|
||||
capture.CaptureDetails.AddMetaData("windowtitle", selectedCaptureWindow.Text);
|
||||
if (captureMode == CaptureMode.Window) {
|
||||
if (_selectedCaptureWindow != null && !_selectedCaptureWindow.Equals(lastWindow)) {
|
||||
_capture.CaptureDetails.Title = _selectedCaptureWindow.Text;
|
||||
_capture.CaptureDetails.AddMetaData("windowtitle", _selectedCaptureWindow.Text);
|
||||
if (_captureMode == CaptureMode.Window) {
|
||||
// Here we want to capture the window which is under the mouse
|
||||
captureRect = selectedCaptureWindow.WindowRectangle;
|
||||
_captureRect = _selectedCaptureWindow.WindowRectangle;
|
||||
// As the ClientRectangle is not in Bitmap coordinates, we need to correct.
|
||||
captureRect.Offset(-capture.ScreenBounds.Location.X, -capture.ScreenBounds.Location.Y);
|
||||
_captureRect.Offset(-_capture.ScreenBounds.Location.X, -_capture.ScreenBounds.Location.Y);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle invalidateRectangle = Rectangle.Empty;
|
||||
if (mouseDown && (captureMode != CaptureMode.Window)) {
|
||||
int x1 = Math.Min(mX, lastPos.X);
|
||||
int x2 = Math.Max(mX, lastPos.X);
|
||||
int y1 = Math.Min(mY, lastPos.Y);
|
||||
int y2 = Math.Max(mY, lastPos.Y);
|
||||
x1= Math.Min(x1, cursorPos.X);
|
||||
x2= Math.Max(x2, cursorPos.X);
|
||||
y1= Math.Min(y1, cursorPos.Y);
|
||||
y2= Math.Max(y2, cursorPos.Y);
|
||||
Rectangle invalidateRectangle;
|
||||
if (_mouseDown && (_captureMode != CaptureMode.Window)) {
|
||||
int x1 = Math.Min(_mX, lastPos.X);
|
||||
int x2 = Math.Max(_mX, lastPos.X);
|
||||
int y1 = Math.Min(_mY, lastPos.Y);
|
||||
int y2 = Math.Max(_mY, lastPos.Y);
|
||||
x1= Math.Min(x1, _cursorPos.X);
|
||||
x2= Math.Max(x2, _cursorPos.X);
|
||||
y1= Math.Min(y1, _cursorPos.Y);
|
||||
y2= Math.Max(y2, _cursorPos.Y);
|
||||
|
||||
// Safety correction
|
||||
x2 += 2;
|
||||
|
@ -458,79 +453,79 @@ namespace Greenshot.Forms {
|
|||
// Here we correct for text-size
|
||||
|
||||
// Calculate the size
|
||||
int textForWidth = Math.Max(Math.Abs(mX - cursorPos.X), Math.Abs(mX - lastPos.X));
|
||||
int textForHeight = Math.Max(Math.Abs(mY - cursorPos.Y), Math.Abs(mY - lastPos.Y));
|
||||
int textForWidth = Math.Max(Math.Abs(_mX - _cursorPos.X), Math.Abs(_mX - lastPos.X));
|
||||
int textForHeight = Math.Max(Math.Abs(_mY - _cursorPos.Y), Math.Abs(_mY - lastPos.Y));
|
||||
|
||||
using (Font rulerFont = new Font(FontFamily.GenericSansSerif, 8)) {
|
||||
Size measureWidth = TextRenderer.MeasureText(textForWidth.ToString(), rulerFont);
|
||||
Size measureWidth = TextRenderer.MeasureText(textForWidth.ToString(CultureInfo.InvariantCulture), rulerFont);
|
||||
x1 -= measureWidth.Width + 15;
|
||||
|
||||
Size measureHeight = TextRenderer.MeasureText(textForHeight.ToString(), rulerFont);
|
||||
y1 -= measureWidth.Height + 10;
|
||||
Size measureHeight = TextRenderer.MeasureText(textForHeight.ToString(CultureInfo.InvariantCulture), rulerFont);
|
||||
y1 -= measureHeight.Height + 10;
|
||||
}
|
||||
invalidateRectangle = new Rectangle(x1,y1, x2-x1, y2-y1);
|
||||
Invalidate(invalidateRectangle);
|
||||
} else if (captureMode != CaptureMode.Window) {
|
||||
} else if (_captureMode != CaptureMode.Window) {
|
||||
if (!isTerminalServerSession) {
|
||||
Rectangle allScreenBounds = WindowCapture.GetScreenBounds();
|
||||
allScreenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location);
|
||||
if (verticalMove) {
|
||||
// Before
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(allScreenBounds.Left, lastPos.Y - 2, this.Width + 2, 45);
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(allScreenBounds.Left, lastPos.Y - 2, Width + 2, 45);
|
||||
Invalidate(invalidateRectangle);
|
||||
// After
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(allScreenBounds.Left, cursorPos.Y - 2, this.Width + 2, 45);
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(allScreenBounds.Left, _cursorPos.Y - 2, Width + 2, 45);
|
||||
Invalidate(invalidateRectangle);
|
||||
}
|
||||
if (horizontalMove) {
|
||||
// Before
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(lastPos.X - 2, allScreenBounds.Top, 75, this.Height + 2);
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(lastPos.X - 2, allScreenBounds.Top, 75, Height + 2);
|
||||
Invalidate(invalidateRectangle);
|
||||
// After
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(cursorPos.X - 2, allScreenBounds.Top, 75, this.Height + 2);
|
||||
invalidateRectangle = GuiRectangle.GetGuiRectangle(_cursorPos.X - 2, allScreenBounds.Top, 75, Height + 2);
|
||||
Invalidate(invalidateRectangle);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) {
|
||||
if (_selectedCaptureWindow != null && !_selectedCaptureWindow.Equals(lastWindow)) {
|
||||
// Window changes, make new animation from current to target
|
||||
windowAnimator.ChangeDestination(captureRect, FramesForMillis(700));
|
||||
_windowAnimator.ChangeDestination(_captureRect, FramesForMillis(700));
|
||||
}
|
||||
}
|
||||
// always animate the Window area through to the last frame, so we see the fade-in/out untill the end
|
||||
// Using a safety "offset" to make sure the text is invalidated too
|
||||
const int SAFETY_SIZE = 30;
|
||||
const int safetySize = 30;
|
||||
// Check if the
|
||||
if (isAnimating(windowAnimator)) {
|
||||
invalidateRectangle = windowAnimator.Current;
|
||||
invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE);
|
||||
if (isAnimating(_windowAnimator)) {
|
||||
invalidateRectangle = _windowAnimator.Current;
|
||||
invalidateRectangle.Inflate(safetySize, safetySize);
|
||||
Invalidate(invalidateRectangle);
|
||||
invalidateRectangle = windowAnimator.Next();
|
||||
invalidateRectangle.Inflate(SAFETY_SIZE, SAFETY_SIZE);
|
||||
invalidateRectangle = _windowAnimator.Next();
|
||||
invalidateRectangle.Inflate(safetySize, safetySize);
|
||||
Invalidate(invalidateRectangle);
|
||||
// Check if this was the last of the windows animations in the normal region capture.
|
||||
if (captureMode != CaptureMode.Window && !isAnimating(windowAnimator)) {
|
||||
if (_captureMode != CaptureMode.Window && !isAnimating(_windowAnimator)) {
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (zoomAnimator != null && (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window)) {
|
||||
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
// Make sure we invalidate the old zoom area
|
||||
invalidateRectangle = zoomAnimator.Current;
|
||||
invalidateRectangle = _zoomAnimator.Current;
|
||||
invalidateRectangle.Offset(lastPos);
|
||||
Invalidate(invalidateRectangle);
|
||||
// Only verify if we are really showing the zoom, not the outgoing animation
|
||||
if (conf.ZoomerEnabled && captureMode != CaptureMode.Window) {
|
||||
VerifyZoomAnimation(cursorPos, false);
|
||||
if (Conf.ZoomerEnabled && _captureMode != CaptureMode.Window) {
|
||||
VerifyZoomAnimation(_cursorPos, false);
|
||||
}
|
||||
// The following logic is not needed, next always returns the current if there are no frames left
|
||||
// but it makes more sense if we want to change something in the logic
|
||||
if (isAnimating(zoomAnimator)) {
|
||||
invalidateRectangle = zoomAnimator.Next();
|
||||
if (isAnimating(_zoomAnimator)) {
|
||||
invalidateRectangle = _zoomAnimator.Next();
|
||||
} else {
|
||||
invalidateRectangle = zoomAnimator.Current;
|
||||
invalidateRectangle = _zoomAnimator.Current;
|
||||
}
|
||||
invalidateRectangle.Offset(cursorPos);
|
||||
invalidateRectangle.Offset(_cursorPos);
|
||||
Invalidate(invalidateRectangle);
|
||||
}
|
||||
// Force update "now"
|
||||
|
@ -559,27 +554,27 @@ namespace Greenshot.Forms {
|
|||
Size zoomSize = new Size(relativeZoomSize, relativeZoomSize);
|
||||
Point zoomOffset = new Point(20, 20);
|
||||
|
||||
Rectangle targetRectangle = zoomAnimator.Final;
|
||||
Rectangle targetRectangle = _zoomAnimator.Final;
|
||||
targetRectangle.Offset(pos);
|
||||
if (!screenBounds.Contains(targetRectangle) || (!allowZoomOverCaptureRect && captureRect.IntersectsWith(targetRectangle))) {
|
||||
if (!screenBounds.Contains(targetRectangle) || (!allowZoomOverCaptureRect && _captureRect.IntersectsWith(targetRectangle))) {
|
||||
Point destinationLocation = Point.Empty;
|
||||
Rectangle tl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height);
|
||||
Rectangle tr = new Rectangle(pos.X + zoomOffset.X, pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height);
|
||||
Rectangle bl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height);
|
||||
Rectangle br = new Rectangle(pos.X + zoomOffset.X, pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height);
|
||||
if (screenBounds.Contains(br) && (allowZoomOverCaptureRect || !captureRect.IntersectsWith(br))) {
|
||||
if (screenBounds.Contains(br) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(br))) {
|
||||
destinationLocation = new Point(zoomOffset.X, zoomOffset.Y);
|
||||
} else if (screenBounds.Contains(bl) && (allowZoomOverCaptureRect || !captureRect.IntersectsWith(bl))) {
|
||||
} else if (screenBounds.Contains(bl) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(bl))) {
|
||||
destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, zoomOffset.Y);
|
||||
} else if (screenBounds.Contains(tr) && (allowZoomOverCaptureRect || !captureRect.IntersectsWith(tr))) {
|
||||
} else if (screenBounds.Contains(tr) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(tr))) {
|
||||
destinationLocation = new Point(zoomOffset.X, -zoomOffset.Y - zoomSize.Width);
|
||||
} else if (screenBounds.Contains(tl) && (allowZoomOverCaptureRect || !captureRect.IntersectsWith(tl))) {
|
||||
} else if (screenBounds.Contains(tl) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(tl))) {
|
||||
destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width);
|
||||
}
|
||||
if (destinationLocation == Point.Empty && !allowZoomOverCaptureRect) {
|
||||
VerifyZoomAnimation(pos, true);
|
||||
} else {
|
||||
zoomAnimator.ChangeDestination(new Rectangle(destinationLocation, zoomSize));
|
||||
_zoomAnimator.ChangeDestination(new Rectangle(destinationLocation, zoomSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -591,15 +586,15 @@ namespace Greenshot.Forms {
|
|||
/// <param name="sourceRectangle"></param>
|
||||
/// <param name="destinationRectangle"></param>
|
||||
private void DrawZoom(Graphics graphics, Rectangle sourceRectangle, Rectangle destinationRectangle) {
|
||||
if (capturedImage == null) {
|
||||
if (_capturedImage == null) {
|
||||
return;
|
||||
}
|
||||
ImageAttributes attributes;
|
||||
|
||||
if (isZoomerTransparent) {
|
||||
if (_isZoomerTransparent) {
|
||||
//create a color matrix object to change the opacy
|
||||
ColorMatrix opacyMatrix = new ColorMatrix();
|
||||
opacyMatrix.Matrix33 = conf.ZoomerOpacity;
|
||||
opacyMatrix.Matrix33 = Conf.ZoomerOpacity;
|
||||
attributes = new ImageAttributes();
|
||||
attributes.SetColorMatrix(opacyMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
} else {
|
||||
|
@ -614,14 +609,14 @@ namespace Greenshot.Forms {
|
|||
using (GraphicsPath path = new GraphicsPath()) {
|
||||
path.AddEllipse(destinationRectangle);
|
||||
graphics.SetClip(path);
|
||||
if (!isZoomerTransparent) {
|
||||
graphics.FillRectangle(backgroundBrush, destinationRectangle);
|
||||
graphics.DrawImage(capturedImage, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel);
|
||||
if (!_isZoomerTransparent) {
|
||||
graphics.FillRectangle(BackgroundBrush, destinationRectangle);
|
||||
graphics.DrawImage(_capturedImage, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel);
|
||||
} else {
|
||||
graphics.DrawImage(capturedImage, destinationRectangle, sourceRectangle.X, sourceRectangle.Y, sourceRectangle.Width, sourceRectangle.Height, GraphicsUnit.Pixel, attributes);
|
||||
graphics.DrawImage(_capturedImage, destinationRectangle, sourceRectangle.X, sourceRectangle.Y, sourceRectangle.Width, sourceRectangle.Height, GraphicsUnit.Pixel, attributes);
|
||||
}
|
||||
}
|
||||
int alpha = (int)(255 * conf.ZoomerOpacity);
|
||||
int alpha = (int)(255 * Conf.ZoomerOpacity);
|
||||
Color opacyWhite = Color.FromArgb(alpha, 255, 255, 255);
|
||||
Color opacyBlack = Color.FromArgb(alpha, 0, 0, 0);
|
||||
|
||||
|
@ -685,22 +680,22 @@ namespace Greenshot.Forms {
|
|||
Graphics graphics = e.Graphics;
|
||||
Rectangle clipRectangle = e.ClipRectangle;
|
||||
//graphics.BitBlt((Bitmap)buffer, Point.Empty);
|
||||
graphics.DrawImageUnscaled(capturedImage, Point.Empty);
|
||||
graphics.DrawImageUnscaled(_capturedImage, Point.Empty);
|
||||
// Only draw Cursor if it's (partly) visible
|
||||
if (capture.Cursor != null && capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(capture.CursorLocation, capture.Cursor.Size))) {
|
||||
graphics.DrawIcon(capture.Cursor, capture.CursorLocation.X, capture.CursorLocation.Y);
|
||||
if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size))) {
|
||||
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
|
||||
}
|
||||
|
||||
if (mouseDown || captureMode == CaptureMode.Window || isAnimating(windowAnimator)) {
|
||||
captureRect.Intersect(new Rectangle(Point.Empty, capture.ScreenBounds.Size)); // crop what is outside the screen
|
||||
if (_mouseDown || _captureMode == CaptureMode.Window || isAnimating(_windowAnimator)) {
|
||||
_captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size)); // crop what is outside the screen
|
||||
|
||||
Rectangle fixedRect;
|
||||
//if (captureMode == CaptureMode.Window) {
|
||||
if (isAnimating(windowAnimator)) {
|
||||
if (isAnimating(_windowAnimator)) {
|
||||
// Use the animator
|
||||
fixedRect = windowAnimator.Current;
|
||||
fixedRect = _windowAnimator.Current;
|
||||
} else {
|
||||
fixedRect = captureRect;
|
||||
fixedRect = _captureRect;
|
||||
}
|
||||
|
||||
// TODO: enable when the screen capture code works reliable
|
||||
|
@ -712,17 +707,17 @@ namespace Greenshot.Forms {
|
|||
graphics.DrawRectangle(OverlayPen, fixedRect);
|
||||
|
||||
// rulers
|
||||
int dist = 8;
|
||||
const int dist = 8;
|
||||
|
||||
string captureWidth;
|
||||
string captureHeight;
|
||||
// The following fixes the very old incorrect size information bug
|
||||
if (captureMode == CaptureMode.Window) {
|
||||
captureWidth = captureRect.Width.ToString();
|
||||
captureHeight = captureRect.Height.ToString();
|
||||
if (_captureMode == CaptureMode.Window) {
|
||||
captureWidth = _captureRect.Width.ToString(CultureInfo.InvariantCulture);
|
||||
captureHeight = _captureRect.Height.ToString(CultureInfo.InvariantCulture);
|
||||
} else {
|
||||
captureWidth = (captureRect.Width + 1).ToString();
|
||||
captureHeight = (captureRect.Height + 1).ToString();
|
||||
captureWidth = (_captureRect.Width + 1).ToString(CultureInfo.InvariantCulture);
|
||||
captureHeight = (_captureRect.Height + 1).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
using (Font rulerFont = new Font(FontFamily.GenericSansSerif, 8)) {
|
||||
Size measureWidth = TextRenderer.MeasureText(captureWidth, rulerFont);
|
||||
|
@ -734,7 +729,7 @@ namespace Greenshot.Forms {
|
|||
|
||||
// horizontal ruler
|
||||
if (fixedRect.Width > hSpace + 3) {
|
||||
using (GraphicsPath p = Drawing.RoundedRectangle.Create2(
|
||||
using (GraphicsPath p = RoundedRectangle.Create2(
|
||||
fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3,
|
||||
fixedRect.Y - dist - 7,
|
||||
measureWidth.Width - 3,
|
||||
|
@ -752,7 +747,7 @@ namespace Greenshot.Forms {
|
|||
|
||||
// vertical ruler
|
||||
if (fixedRect.Height > vSpace + 3) {
|
||||
using (GraphicsPath p = Drawing.RoundedRectangle.Create2(
|
||||
using (GraphicsPath p = RoundedRectangle.Create2(
|
||||
fixedRect.X - measureHeight.Width + 1,
|
||||
fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2,
|
||||
measureHeight.Width - 3,
|
||||
|
@ -776,18 +771,18 @@ namespace Greenshot.Forms {
|
|||
// Prepare the font and text.
|
||||
using (Font sizeFont = new Font( FontFamily.GenericSansSerif, 12 )) {
|
||||
// When capturing a Region we need to add 1 to the height/width for correction
|
||||
string sizeText = null;
|
||||
if (captureMode == CaptureMode.Region) {
|
||||
string sizeText;
|
||||
if (_captureMode == CaptureMode.Region) {
|
||||
// correct the GUI width to real width for the shown size
|
||||
sizeText = (captureRect.Width + 1) + " x " + (captureRect.Height + 1);
|
||||
sizeText = (_captureRect.Width + 1) + " x " + (_captureRect.Height + 1);
|
||||
} else {
|
||||
sizeText = captureRect.Width + " x " + captureRect.Height;
|
||||
sizeText = _captureRect.Width + " x " + _captureRect.Height;
|
||||
}
|
||||
|
||||
// Calculate the scaled font size.
|
||||
SizeF extent = graphics.MeasureString( sizeText, sizeFont );
|
||||
float hRatio = captureRect.Height / (extent.Height * 2);
|
||||
float wRatio = captureRect.Width / (extent.Width * 2);
|
||||
float hRatio = _captureRect.Height / (extent.Height * 2);
|
||||
float wRatio = _captureRect.Width / (extent.Width * 2);
|
||||
float ratio = ( hRatio < wRatio ? hRatio : wRatio );
|
||||
float newSize = sizeFont.Size * ratio;
|
||||
|
||||
|
@ -798,8 +793,8 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
// Draw the size.
|
||||
using (Font newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold)) {
|
||||
PointF sizeLocation = new PointF( fixedRect.X + ( captureRect.Width / 2) - (extent.Width / 2), fixedRect.Y + (captureRect.Height / 2) - (sizeFont.GetHeight() / 2));
|
||||
graphics.DrawString(sizeText, sizeFont, Brushes.LightSeaGreen, sizeLocation);
|
||||
PointF sizeLocation = new PointF(fixedRect.X + (_captureRect.Width / 2) - (extent.Width / 2), fixedRect.Y + (_captureRect.Height / 2) - (newSizeFont.GetHeight() / 2));
|
||||
graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -807,21 +802,21 @@ namespace Greenshot.Forms {
|
|||
if (!isTerminalServerSession) {
|
||||
using (Pen pen = new Pen(Color.LightSeaGreen)) {
|
||||
pen.DashStyle = DashStyle.Dot;
|
||||
Rectangle screenBounds = capture.ScreenBounds;
|
||||
graphics.DrawLine(pen, cursorPos.X, screenBounds.Y, cursorPos.X, screenBounds.Height);
|
||||
graphics.DrawLine(pen, screenBounds.X, cursorPos.Y, screenBounds.Width, cursorPos.Y);
|
||||
Rectangle screenBounds = _capture.ScreenBounds;
|
||||
graphics.DrawLine(pen, _cursorPos.X, screenBounds.Y, _cursorPos.X, screenBounds.Height);
|
||||
graphics.DrawLine(pen, screenBounds.X, _cursorPos.Y, screenBounds.Width, _cursorPos.Y);
|
||||
}
|
||||
|
||||
string xy = cursorPos.X + " x " + cursorPos.Y;
|
||||
string xy = _cursorPos.X + " x " + _cursorPos.Y;
|
||||
using (Font f = new Font(FontFamily.GenericSansSerif, 8)) {
|
||||
Size xySize = TextRenderer.MeasureText(xy, f);
|
||||
using (GraphicsPath gp = Drawing.RoundedRectangle.Create2(cursorPos.X + 5, cursorPos.Y + 5, xySize.Width - 3, xySize.Height, 3)) {
|
||||
using (GraphicsPath gp = RoundedRectangle.Create2(_cursorPos.X + 5, _cursorPos.Y + 5, xySize.Width - 3, xySize.Height, 3)) {
|
||||
using (Brush bgBrush = new SolidBrush(Color.FromArgb(200, 217, 240, 227))) {
|
||||
graphics.FillPath(bgBrush, gp);
|
||||
}
|
||||
using (Pen pen = new Pen(Color.SeaGreen)) {
|
||||
graphics.DrawPath(pen, gp);
|
||||
Point coordinatePosition = new Point(cursorPos.X + 5, cursorPos.Y + 5);
|
||||
Point coordinatePosition = new Point(_cursorPos.X + 5, _cursorPos.Y + 5);
|
||||
graphics.DrawString(xy, f, pen.Brush, coordinatePosition);
|
||||
}
|
||||
}
|
||||
|
@ -830,14 +825,14 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
|
||||
// Zoom
|
||||
if (zoomAnimator != null && (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window)) {
|
||||
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
const int zoomSourceWidth = 25;
|
||||
const int zoomSourceHeight = 25;
|
||||
|
||||
Rectangle sourceRectangle = new Rectangle(cursorPos.X - (zoomSourceWidth / 2), cursorPos.Y - (zoomSourceHeight / 2), zoomSourceWidth, zoomSourceHeight);
|
||||
Rectangle sourceRectangle = new Rectangle(_cursorPos.X - (zoomSourceWidth / 2), _cursorPos.Y - (zoomSourceHeight / 2), zoomSourceWidth, zoomSourceHeight);
|
||||
|
||||
Rectangle destinationRectangle = zoomAnimator.Current;
|
||||
destinationRectangle.Offset(cursorPos);
|
||||
Rectangle destinationRectangle = _zoomAnimator.Current;
|
||||
destinationRectangle.Offset(_cursorPos);
|
||||
DrawZoom(graphics, sourceRectangle, destinationRectangle);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue