mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 05:23:24 -07:00
Optimized for Remote Desktop / Terminal Server Sessions, also made it possible to enable/disable the zoomer.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2356 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ddae26df89
commit
26fd909de0
2 changed files with 47 additions and 17 deletions
|
@ -68,7 +68,6 @@ namespace Greenshot.Forms {
|
||||||
private ICapture capture = null;
|
private ICapture capture = null;
|
||||||
private Image capturedImage = null;
|
private Image capturedImage = null;
|
||||||
private Timer timer = null;
|
private Timer timer = null;
|
||||||
private bool isZooming = true;
|
|
||||||
private Point previousMousePos = Point.Empty;
|
private Point previousMousePos = Point.Empty;
|
||||||
private FixMode fixMode = FixMode.None;
|
private FixMode fixMode = FixMode.None;
|
||||||
private RectangleAnimator windowAnimator = null;
|
private RectangleAnimator windowAnimator = null;
|
||||||
|
@ -89,12 +88,25 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if we need to optimize for RDP / Terminal Server sessions
|
||||||
|
/// </summary>
|
||||||
|
private static bool optimizeForTerminalServer {
|
||||||
|
get {
|
||||||
|
return conf.OptimizeForRDP || SystemInformation.TerminalServerSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the amount of frames that an animation takes
|
/// Calculate the amount of frames that an animation takes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="milliseconds"></param>
|
/// <param name="milliseconds"></param>
|
||||||
/// <returns></returns>
|
/// <returns>Number of frames, 1 if in Terminal Server Session</returns>
|
||||||
private static int calculateFrames(int milliseconds) {
|
private static int calculateFrames(int milliseconds) {
|
||||||
|
// If we are in a Terminal Server Session we return 1
|
||||||
|
if (optimizeForTerminalServer) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return milliseconds / VRefresh;
|
return milliseconds / VRefresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +185,7 @@ namespace Greenshot.Forms {
|
||||||
//
|
//
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
// Only double-buffer when we are not in a TerminalServerSession
|
// Only double-buffer when we are not in a TerminalServerSession
|
||||||
this.DoubleBuffered = !System.Windows.Forms.SystemInformation.TerminalServerSession;
|
this.DoubleBuffered = !optimizeForTerminalServer;
|
||||||
this.Text = "Greenshot capture form";
|
this.Text = "Greenshot capture form";
|
||||||
|
|
||||||
// Make sure we never capture the captureform
|
// Make sure we never capture the captureform
|
||||||
|
@ -198,9 +210,10 @@ namespace Greenshot.Forms {
|
||||||
if (captureMode == CaptureMode.Window) {
|
if (captureMode == CaptureMode.Window) {
|
||||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
}
|
}
|
||||||
// Initialize the zoom with a invalid position
|
|
||||||
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), calculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut);
|
// Set the zoomer animation
|
||||||
VerifyZoomAnimation(cursorPos, false);
|
InitializeZoomer(conf.ZoomerEnabled);
|
||||||
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
this.Bounds = capture.ScreenBounds;
|
this.Bounds = capture.ScreenBounds;
|
||||||
this.ResumeLayout();
|
this.ResumeLayout();
|
||||||
|
@ -216,6 +229,19 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an animation for the zoomer, depending on if it's active or not.
|
||||||
|
/// </summary>
|
||||||
|
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), calculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
|
VerifyZoomAnimation(cursorPos, false);
|
||||||
|
} else if (zoomAnimator != null) {
|
||||||
|
zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), calculateFrames(1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region key handling
|
#region key handling
|
||||||
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
||||||
if (e.KeyCode == Keys.ShiftKey) {
|
if (e.KeyCode == Keys.ShiftKey) {
|
||||||
|
@ -269,7 +295,9 @@ namespace Greenshot.Forms {
|
||||||
break;
|
break;
|
||||||
case Keys.Z:
|
case Keys.Z:
|
||||||
// Toggle zoom
|
// Toggle zoom
|
||||||
isZooming = !isZooming;
|
conf.ZoomerEnabled = !conf.ZoomerEnabled;
|
||||||
|
InitializeZoomer(conf.ZoomerEnabled);
|
||||||
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
case Keys.Space:
|
case Keys.Space:
|
||||||
// Toggle capture mode
|
// Toggle capture mode
|
||||||
|
@ -278,7 +306,7 @@ namespace Greenshot.Forms {
|
||||||
// Set the window capture mode
|
// Set the window capture mode
|
||||||
captureMode = CaptureMode.Window;
|
captureMode = CaptureMode.Window;
|
||||||
// "Fade out" Zoom
|
// "Fade out" Zoom
|
||||||
zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty));
|
InitializeZoomer(false);
|
||||||
// "Fade in" window
|
// "Fade in" window
|
||||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
captureRect = Rectangle.Empty;
|
captureRect = Rectangle.Empty;
|
||||||
|
@ -288,10 +316,9 @@ namespace Greenshot.Forms {
|
||||||
// Set the region capture mode
|
// Set the region capture mode
|
||||||
captureMode = CaptureMode.Region;
|
captureMode = CaptureMode.Region;
|
||||||
// "Fade out" window
|
// "Fade out" window
|
||||||
windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty));
|
windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), calculateFrames(700));
|
||||||
// Fade in zoom
|
// Fade in zoom
|
||||||
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), calculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut);
|
InitializeZoomer(conf.ZoomerEnabled);
|
||||||
VerifyZoomAnimation(cursorPos, false);
|
|
||||||
captureRect = Rectangle.Empty;
|
captureRect = Rectangle.Empty;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
|
@ -497,7 +524,7 @@ namespace Greenshot.Forms {
|
||||||
invalidateRectangle = new Rectangle(x1,y1, x2-x1, y2-y1);
|
invalidateRectangle = new Rectangle(x1,y1, x2-x1, y2-y1);
|
||||||
Invalidate(invalidateRectangle);
|
Invalidate(invalidateRectangle);
|
||||||
} else if (captureMode != CaptureMode.Window) {
|
} else if (captureMode != CaptureMode.Window) {
|
||||||
if (!conf.OptimizeForRDP) {
|
if (!optimizeForTerminalServer) {
|
||||||
Rectangle allScreenBounds = WindowCapture.GetScreenBounds();
|
Rectangle allScreenBounds = WindowCapture.GetScreenBounds();
|
||||||
allScreenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location);
|
allScreenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location);
|
||||||
if (verticalMove) {
|
if (verticalMove) {
|
||||||
|
@ -520,7 +547,7 @@ namespace Greenshot.Forms {
|
||||||
} else {
|
} else {
|
||||||
if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) {
|
if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) {
|
||||||
// Window changes, make new animation from current to target
|
// Window changes, make new animation from current to target
|
||||||
windowAnimator.ChangeDestination(captureRect, 10);
|
windowAnimator.ChangeDestination(captureRect, calculateFrames(700));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// always animate the Window area through to the last frame, so we see the fade-in/out untill the end
|
// always animate the Window area through to the last frame, so we see the fade-in/out untill the end
|
||||||
|
@ -540,13 +567,13 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window) {
|
if (zoomAnimator != null && (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window)) {
|
||||||
// Make sure we invalidate the old zoom area
|
// Make sure we invalidate the old zoom area
|
||||||
invalidateRectangle = zoomAnimator.Current;
|
invalidateRectangle = zoomAnimator.Current;
|
||||||
invalidateRectangle.Offset(lastPos);
|
invalidateRectangle.Offset(lastPos);
|
||||||
Invalidate(invalidateRectangle);
|
Invalidate(invalidateRectangle);
|
||||||
// Only verify if we are really showing the zoom, not the outgoing animation
|
// Only verify if we are really showing the zoom, not the outgoing animation
|
||||||
if (isZooming && captureMode != CaptureMode.Window) {
|
if (conf.ZoomerEnabled && captureMode != CaptureMode.Window) {
|
||||||
VerifyZoomAnimation(cursorPos, false);
|
VerifyZoomAnimation(cursorPos, false);
|
||||||
}
|
}
|
||||||
// The following logic is not needed, next always returns the current if there are no frames left
|
// The following logic is not needed, next always returns the current if there are no frames left
|
||||||
|
@ -813,7 +840,7 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!conf.OptimizeForRDP) {
|
if (!optimizeForTerminalServer) {
|
||||||
using (Pen pen = new Pen(Color.LightSeaGreen)) {
|
using (Pen pen = new Pen(Color.LightSeaGreen)) {
|
||||||
pen.DashStyle = DashStyle.Dot;
|
pen.DashStyle = DashStyle.Dot;
|
||||||
Rectangle screenBounds = capture.ScreenBounds;
|
Rectangle screenBounds = capture.ScreenBounds;
|
||||||
|
@ -839,7 +866,7 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zoom
|
// Zoom
|
||||||
if (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window) {
|
if (zoomAnimator != null && (isAnimating(zoomAnimator) || captureMode != CaptureMode.Window)) {
|
||||||
const int zoomSourceWidth = 25;
|
const int zoomSourceWidth = 25;
|
||||||
const int zoomSourceHeight = 25;
|
const int zoomSourceHeight = 25;
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,9 @@ namespace GreenshotPlugin.Core {
|
||||||
[IniProperty("LeftClickAction", Description = "Specify what action is made if the tray icon is left clicked", DefaultValue = "CONTEXT_MENU")]
|
[IniProperty("LeftClickAction", Description = "Specify what action is made if the tray icon is left clicked", DefaultValue = "CONTEXT_MENU")]
|
||||||
public LeftClickActions LeftClickAction;
|
public LeftClickActions LeftClickAction;
|
||||||
|
|
||||||
|
[IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")]
|
||||||
|
public bool ZoomerEnabled;
|
||||||
|
|
||||||
// Specifies what THIS build is
|
// Specifies what THIS build is
|
||||||
public BuildStates BuildState = BuildStates.UNSTABLE;
|
public BuildStates BuildState = BuildStates.UNSTABLE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue