mirror of
https://github.com/greenshot/greenshot
synced 2025-08-24 07:06:23 -07:00
Changed all usages of Point, Rectangle, RectangleF, Size to the Native versions of those from Dapplo.Windows.Common.
This commit is contained in:
parent
1cfb76a5ff
commit
53644d2d94
58 changed files with 557 additions and 633 deletions
|
@ -146,7 +146,7 @@ namespace Greenshot.Base.Controls
|
||||||
|
|
||||||
public void AlignToControl(Control alignTo)
|
public void AlignToControl(Control alignTo)
|
||||||
{
|
{
|
||||||
var screenBounds = WindowCapture.GetScreenBounds();
|
var screenBounds = DisplayInfo.ScreenBounds;
|
||||||
if (screenBounds.Contains(alignTo.Left, alignTo.Top - Height))
|
if (screenBounds.Contains(alignTo.Left, alignTo.Top - Height))
|
||||||
{
|
{
|
||||||
Location = new Point(alignTo.Left + (alignTo.Width / 2) - (Width / 2), alignTo.Top - Height);
|
Location = new Point(alignTo.Left + (alignTo.Width / 2) - (Width / 2), alignTo.Top - Height);
|
||||||
|
|
|
@ -316,9 +316,9 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
// find a suitable location
|
// find a suitable location
|
||||||
NativePoint location = Cursor.Position;
|
NativePoint location = Cursor.Position;
|
||||||
NativeRect menuRectangle = new NativeRect(location, menu.Size);
|
var menuRectangle = new NativeRect(location, menu.Size);
|
||||||
|
|
||||||
menuRectangle = menuRectangle.Intersect(WindowCapture.GetScreenBounds());
|
menuRectangle = menuRectangle.Intersect(DisplayInfo.ScreenBounds);
|
||||||
if (menuRectangle.Height < menu.Height)
|
if (menuRectangle.Height < menu.Height)
|
||||||
{
|
{
|
||||||
location = location.Offset(-40, -(menuRectangle.Height - menu.Height));
|
location = location.Offset(-40, -(menuRectangle.Height - menu.Height));
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using Dapplo.Windows.Common.Extensions;
|
using Dapplo.Windows.Common.Extensions;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
using Dapplo.Windows.User32;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
using Greenshot.Base.Interfaces.Ocr;
|
using Greenshot.Base.Interfaces.Ocr;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -49,7 +50,7 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
if (_screenBounds.IsEmpty)
|
if (_screenBounds.IsEmpty)
|
||||||
{
|
{
|
||||||
_screenBounds = WindowCapture.GetScreenBounds();
|
_screenBounds = DisplayInfo.ScreenBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _screenBounds;
|
return _screenBounds;
|
||||||
|
@ -164,7 +165,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Capture()
|
public Capture()
|
||||||
{
|
{
|
||||||
_screenBounds = WindowCapture.GetScreenBounds();
|
_screenBounds = DisplayInfo.ScreenBounds;
|
||||||
_captureDetails = new CaptureDetails();
|
_captureDetails = new CaptureDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
//private void MoveElements(List<ICaptureElement> listOfElements, int x, int y) {
|
//private void MoveElements(List<ICaptureElement> listOfElements, int x, int y) {
|
||||||
// foreach(ICaptureElement childElement in listOfElements) {
|
// foreach(ICaptureElement childElement in listOfElements) {
|
||||||
// Rectangle bounds = childElement.Bounds;
|
// NativeRect bounds = childElement.Bounds;
|
||||||
// bounds.Offset(x, y);
|
// bounds.Offset(x, y);
|
||||||
// childElement.Bounds = bounds;
|
// childElement.Bounds = bounds;
|
||||||
// MoveElements(childElement.Children, x, y);
|
// MoveElements(childElement.Children, x, y);
|
||||||
|
|
|
@ -20,15 +20,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
|
||||||
namespace Greenshot.Base.Core
|
namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the method signature which is used to capture a rectangle from the screen.
|
/// This is the method signature which is used to capture a rectangle from the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="captureBounds"></param>
|
/// <param name="captureBounds">NativeRect</param>
|
||||||
/// <returns>Captured Bitmap</returns>
|
/// <returns>Captured Bitmap</returns>
|
||||||
public delegate Bitmap CaptureScreenRectangleHandler(Rectangle captureBounds);
|
public delegate Bitmap CaptureScreenRectangleHandler(NativeRect captureBounds);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a hack to experiment with different screen capture routines
|
/// This is a hack to experiment with different screen capture routines
|
||||||
|
|
|
@ -31,6 +31,7 @@ using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Dapplo.Windows.Clipboard;
|
using Dapplo.Windows.Clipboard;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Gdi32.Enums;
|
using Dapplo.Windows.Gdi32.Enums;
|
||||||
using Dapplo.Windows.Gdi32.Structs;
|
using Dapplo.Windows.Gdi32.Structs;
|
||||||
using Dapplo.Windows.User32;
|
using Dapplo.Windows.User32;
|
||||||
|
@ -1121,7 +1122,7 @@ EndSelection:<<<<<<<4
|
||||||
private static byte[] BitmapToByteArray(Bitmap bitmap)
|
private static byte[] BitmapToByteArray(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
// Lock the bitmap's bits.
|
// Lock the bitmap's bits.
|
||||||
Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
var rect = new NativeRect(0, 0, bitmap.Width, bitmap.Height);
|
||||||
BitmapData bmpData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
BitmapData bmpData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
||||||
|
|
||||||
int absStride = Math.Abs(bmpData.Stride);
|
int absStride = Math.Abs(bmpData.Stride);
|
||||||
|
|
|
@ -322,7 +322,7 @@ namespace Greenshot.Base.Core
|
||||||
public bool ProcessEXIFOrientation { get; set; }
|
public bool ProcessEXIFOrientation { get; set; }
|
||||||
|
|
||||||
[IniProperty("LastCapturedRegion", Description = "The last used region, for reuse in the capture last region")]
|
[IniProperty("LastCapturedRegion", Description = "The last used region, for reuse in the capture last region")]
|
||||||
public Rectangle LastCapturedRegion { get; set; }
|
public NativeRect LastCapturedRegion { get; set; }
|
||||||
|
|
||||||
[IniProperty("Win10BorderCrop", Description = "The capture is cropped with these settings, e.g. when you don't want to color around it -1,-1"), DefaultValue("0,0")]
|
[IniProperty("Win10BorderCrop", Description = "The capture is cropped with these settings, e.g. when you don't want to color around it -1,-1"), DefaultValue("0,0")]
|
||||||
public NativeSize Win10BorderCrop { get; set; }
|
public NativeSize Win10BorderCrop { get; set; }
|
||||||
|
|
|
@ -23,6 +23,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
|
||||||
namespace Greenshot.Base.Core
|
namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
|
@ -84,7 +86,7 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Size of the underlying image
|
/// Size of the underlying image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Size Size { get; }
|
NativeSize Size { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Height of the image area that this fastbitmap covers
|
/// Height of the image area that this fastbitmap covers
|
||||||
|
@ -127,19 +129,19 @@ namespace Greenshot.Base.Core
|
||||||
bool HasAlphaChannel { get; }
|
bool HasAlphaChannel { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the stored bitmap to the destionation bitmap at the supplied point
|
/// Draw the stored bitmap to the destination bitmap at the supplied point
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics">Graphics</param>
|
/// <param name="graphics">Graphics</param>
|
||||||
/// <param name="destination">Point with location</param>
|
/// <param name="destination">NativePoint with location</param>
|
||||||
void DrawTo(Graphics graphics, Point destination);
|
void DrawTo(Graphics graphics, NativePoint destination);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the stored Bitmap on the Destination bitmap with the specified rectangle
|
/// Draw the stored Bitmap on the Destination bitmap with the specified rectangle
|
||||||
/// Be aware that the stored bitmap will be resized to the specified rectangle!!
|
/// Be aware that the stored bitmap will be resized to the specified rectangle!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics">Graphics</param>
|
/// <param name="graphics">Graphics</param>
|
||||||
/// <param name="destinationRect">Rectangle with destination</param>
|
/// <param name="destinationRect">NativeRect with destination</param>
|
||||||
void DrawTo(Graphics graphics, Rectangle destinationRect);
|
void DrawTo(Graphics graphics, NativeRect destinationRect);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return true if the coordinates are inside the FastBitmap
|
/// Return true if the coordinates are inside the FastBitmap
|
||||||
|
@ -214,7 +216,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IFastBitmapWithClip : IFastBitmap
|
public interface IFastBitmapWithClip : IFastBitmap
|
||||||
{
|
{
|
||||||
Rectangle Clip { get; set; }
|
NativeRect Clip { get; set; }
|
||||||
|
|
||||||
bool InvertClip { get; set; }
|
bool InvertClip { get; set; }
|
||||||
|
|
||||||
|
@ -267,14 +269,14 @@ namespace Greenshot.Base.Core
|
||||||
public const int ColorIndexB = 2;
|
public const int ColorIndexB = 2;
|
||||||
public const int ColorIndexA = 3;
|
public const int ColorIndexA = 3;
|
||||||
|
|
||||||
protected Rectangle Area;
|
protected NativeRect Area;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If this is set to true, the bitmap will be disposed when disposing the IFastBitmap
|
/// If this is set to true, the bitmap will be disposed when disposing the IFastBitmap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool NeedsDispose { get; set; }
|
public bool NeedsDispose { get; set; }
|
||||||
|
|
||||||
public Rectangle Clip { get; set; }
|
public NativeRect Clip { get; set; }
|
||||||
|
|
||||||
public bool InvertClip { get; set; }
|
public bool InvertClip { get; set; }
|
||||||
|
|
||||||
|
@ -290,7 +292,7 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
public static IFastBitmap Create(Bitmap source)
|
public static IFastBitmap Create(Bitmap source)
|
||||||
{
|
{
|
||||||
return Create(source, Rectangle.Empty);
|
return Create(source, NativeRect.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetResolution(float horizontal, float vertical)
|
public void SetResolution(float horizontal, float vertical)
|
||||||
|
@ -303,44 +305,37 @@ namespace Greenshot.Base.Core
|
||||||
/// The supplied rectangle specifies the area for which the FastBitmap does its thing
|
/// The supplied rectangle specifies the area for which the FastBitmap does its thing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">Bitmap to access</param>
|
/// <param name="source">Bitmap to access</param>
|
||||||
/// <param name="area">Rectangle which specifies the area to have access to, can be Rectangle.Empty for the whole image</param>
|
/// <param name="area">NativeRect which specifies the area to have access to, can be NativeRect.Empty for the whole image</param>
|
||||||
/// <returns>IFastBitmap</returns>
|
/// <returns>IFastBitmap</returns>
|
||||||
public static IFastBitmap Create(Bitmap source, Rectangle area)
|
public static IFastBitmap Create(Bitmap source, NativeRect area) =>
|
||||||
{
|
source.PixelFormat switch
|
||||||
switch (source.PixelFormat)
|
|
||||||
{
|
{
|
||||||
case PixelFormat.Format8bppIndexed:
|
PixelFormat.Format8bppIndexed => new FastChunkyBitmap(source, area),
|
||||||
return new FastChunkyBitmap(source, area);
|
PixelFormat.Format24bppRgb => new Fast24RgbBitmap(source, area),
|
||||||
case PixelFormat.Format24bppRgb:
|
PixelFormat.Format32bppRgb => new Fast32RgbBitmap(source, area),
|
||||||
return new Fast24RgbBitmap(source, area);
|
PixelFormat.Format32bppArgb => new Fast32ArgbBitmap(source, area),
|
||||||
case PixelFormat.Format32bppRgb:
|
PixelFormat.Format32bppPArgb => new Fast32ArgbBitmap(source, area),
|
||||||
return new Fast32RgbBitmap(source, area);
|
_ => throw new NotSupportedException($"Not supported PixelFormat {source.PixelFormat}")
|
||||||
case PixelFormat.Format32bppArgb:
|
};
|
||||||
case PixelFormat.Format32bppPArgb:
|
|
||||||
return new Fast32ArgbBitmap(source, area);
|
|
||||||
default:
|
|
||||||
throw new NotSupportedException($"Not supported Pixelformat {source.PixelFormat}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating a FastBitmap as a destination for the source
|
/// Factory for creating a FastBitmap as a destination for the source
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">Bitmap to clone</param>
|
/// <param name="source">Bitmap to clone</param>
|
||||||
/// <param name="pixelFormat">new Pixelformat</param>
|
/// <param name="pixelFormat">new PixelFormat</param>
|
||||||
/// <returns>IFastBitmap</returns>
|
/// <returns>IFastBitmap</returns>
|
||||||
public static IFastBitmap CreateCloneOf(Image source, PixelFormat pixelFormat)
|
public static IFastBitmap CreateCloneOf(Image source, PixelFormat pixelFormat)
|
||||||
{
|
{
|
||||||
return CreateCloneOf(source, pixelFormat, Rectangle.Empty);
|
return CreateCloneOf(source, pixelFormat, NativeRect.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating a FastBitmap as a destination for the source
|
/// Factory for creating a FastBitmap as a destination for the source
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">Bitmap to clone</param>
|
/// <param name="source">Bitmap to clone</param>
|
||||||
/// <param name="area">Area of the bitmap to access, can be Rectangle.Empty for the whole</param>
|
/// <param name="area">Area of the bitmap to access, can be NativeRect.Empty for the whole</param>
|
||||||
/// <returns>IFastBitmap</returns>
|
/// <returns>IFastBitmap</returns>
|
||||||
public static IFastBitmap CreateCloneOf(Image source, Rectangle area)
|
public static IFastBitmap CreateCloneOf(Image source, NativeRect area)
|
||||||
{
|
{
|
||||||
return CreateCloneOf(source, PixelFormat.DontCare, area);
|
return CreateCloneOf(source, PixelFormat.DontCare, area);
|
||||||
}
|
}
|
||||||
|
@ -350,9 +345,9 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">Bitmap to clone</param>
|
/// <param name="source">Bitmap to clone</param>
|
||||||
/// <param name="pixelFormat">Pixelformat of the cloned bitmap</param>
|
/// <param name="pixelFormat">Pixelformat of the cloned bitmap</param>
|
||||||
/// <param name="area">Area of the bitmap to access, can be Rectangle.Empty for the whole</param>
|
/// <param name="area">Area of the bitmap to access, can be NativeRect.Empty for the whole</param>
|
||||||
/// <returns>IFastBitmap</returns>
|
/// <returns>IFastBitmap</returns>
|
||||||
public static IFastBitmap CreateCloneOf(Image source, PixelFormat pixelFormat, Rectangle area)
|
public static IFastBitmap CreateCloneOf(Image source, PixelFormat pixelFormat, NativeRect area)
|
||||||
{
|
{
|
||||||
Bitmap destination = ImageHelper.CloneArea(source, area, pixelFormat);
|
Bitmap destination = ImageHelper.CloneArea(source, area, pixelFormat);
|
||||||
FastBitmap fastBitmap = Create(destination) as FastBitmap;
|
FastBitmap fastBitmap = Create(destination) as FastBitmap;
|
||||||
|
@ -369,11 +364,11 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating a FastBitmap as a destination
|
/// Factory for creating a FastBitmap as a destination
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newSize"></param>
|
/// <param name="newSize">NativeSize</param>
|
||||||
/// <param name="pixelFormat"></param>
|
/// <param name="pixelFormat">PixelFormat</param>
|
||||||
/// <param name="backgroundColor"></param>
|
/// <param name="backgroundColor">Color</param>
|
||||||
/// <returns>IFastBitmap</returns>
|
/// <returns>IFastBitmap</returns>
|
||||||
public static IFastBitmap CreateEmpty(Size newSize, PixelFormat pixelFormat, Color backgroundColor)
|
public static IFastBitmap CreateEmpty(NativeSize newSize, PixelFormat pixelFormat, Color backgroundColor)
|
||||||
{
|
{
|
||||||
Bitmap destination = ImageHelper.CreateEmpty(newSize.Width, newSize.Height, pixelFormat, backgroundColor, 96f, 96f);
|
Bitmap destination = ImageHelper.CreateEmpty(newSize.Width, newSize.Height, pixelFormat, backgroundColor, 96f, 96f);
|
||||||
IFastBitmap fastBitmap = Create(destination);
|
IFastBitmap fastBitmap = Create(destination);
|
||||||
|
@ -385,14 +380,14 @@ namespace Greenshot.Base.Core
|
||||||
/// Constructor which stores the image and locks it when called
|
/// Constructor which stores the image and locks it when called
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bitmap">Bitmap</param>
|
/// <param name="bitmap">Bitmap</param>
|
||||||
/// <param name="area">Rectangle</param>
|
/// <param name="area">NativeRect</param>
|
||||||
protected FastBitmap(Bitmap bitmap, Rectangle area)
|
protected FastBitmap(Bitmap bitmap, NativeRect area)
|
||||||
{
|
{
|
||||||
Bitmap = bitmap;
|
Bitmap = bitmap;
|
||||||
Rectangle bitmapArea = new Rectangle(Point.Empty, bitmap.Size);
|
var bitmapArea = new NativeRect(Point.Empty, bitmap.Size);
|
||||||
if (area != Rectangle.Empty)
|
if (area != NativeRect.Empty)
|
||||||
{
|
{
|
||||||
area.Intersect(bitmapArea);
|
area = area.Intersect(bitmapArea);
|
||||||
Area = area;
|
Area = area;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -413,11 +408,11 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the size of the image
|
/// Return the size of the image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Size Size
|
public NativeSize Size
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Area == Rectangle.Empty)
|
if (Area == NativeRect.Empty)
|
||||||
{
|
{
|
||||||
return Bitmap.Size;
|
return Bitmap.Size;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +428,7 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Area == Rectangle.Empty)
|
if (Area == NativeRect.Empty)
|
||||||
{
|
{
|
||||||
return Bitmap.Width;
|
return Bitmap.Width;
|
||||||
}
|
}
|
||||||
|
@ -449,7 +444,7 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Area == Rectangle.Empty)
|
if (Area == NativeRect.Empty)
|
||||||
{
|
{
|
||||||
return Bitmap.Height;
|
return Bitmap.Height;
|
||||||
}
|
}
|
||||||
|
@ -596,13 +591,13 @@ namespace Greenshot.Base.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the stored bitmap to the destionation bitmap at the supplied point
|
/// Draw the stored bitmap to the destination bitmap at the supplied point
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="destination"></param>
|
/// <param name="destination"></param>
|
||||||
public void DrawTo(Graphics graphics, Point destination)
|
public void DrawTo(Graphics graphics, NativePoint destination)
|
||||||
{
|
{
|
||||||
DrawTo(graphics, new Rectangle(destination, Area.Size));
|
DrawTo(graphics, new NativeRect(destination, Area.Size));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -610,8 +605,8 @@ namespace Greenshot.Base.Core
|
||||||
/// Be aware that the stored bitmap will be resized to the specified rectangle!!
|
/// Be aware that the stored bitmap will be resized to the specified rectangle!!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="destinationRect"></param>
|
/// <param name="destinationRect">NativeRect</param>
|
||||||
public void DrawTo(Graphics graphics, Rectangle destinationRect)
|
public void DrawTo(Graphics graphics, NativeRect destinationRect)
|
||||||
{
|
{
|
||||||
// Make sure this.bitmap is unlocked, if it was locked
|
// Make sure this.bitmap is unlocked, if it was locked
|
||||||
bool isLocked = BitsLocked;
|
bool isLocked = BitsLocked;
|
||||||
|
@ -715,7 +710,7 @@ namespace Greenshot.Base.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the implementation of the FastBitmat for the 8BPP pixelformat
|
/// This is the implementation of the FastBitmap for the 8BPP pixelformat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe class FastChunkyBitmap : FastBitmap
|
public unsafe class FastChunkyBitmap : FastBitmap
|
||||||
{
|
{
|
||||||
|
@ -723,7 +718,7 @@ namespace Greenshot.Base.Core
|
||||||
private readonly Color[] _colorEntries;
|
private readonly Color[] _colorEntries;
|
||||||
private readonly Dictionary<Color, byte> _colorCache = new Dictionary<Color, byte>();
|
private readonly Dictionary<Color, byte> _colorCache = new Dictionary<Color, byte>();
|
||||||
|
|
||||||
public FastChunkyBitmap(Bitmap source, Rectangle area) : base(source, area)
|
public FastChunkyBitmap(Bitmap source, NativeRect area) : base(source, area)
|
||||||
{
|
{
|
||||||
_colorEntries = Bitmap.Palette.Entries;
|
_colorEntries = Bitmap.Palette.Entries;
|
||||||
}
|
}
|
||||||
|
@ -825,7 +820,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe class Fast24RgbBitmap : FastBitmap
|
public unsafe class Fast24RgbBitmap : FastBitmap
|
||||||
{
|
{
|
||||||
public Fast24RgbBitmap(Bitmap source, Rectangle area) : base(source, area)
|
public Fast24RgbBitmap(Bitmap source, NativeRect area) : base(source, area)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,7 +886,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe class Fast32RgbBitmap : FastBitmap
|
public unsafe class Fast32RgbBitmap : FastBitmap
|
||||||
{
|
{
|
||||||
public Fast32RgbBitmap(Bitmap source, Rectangle area) : base(source, area)
|
public Fast32RgbBitmap(Bitmap source, NativeRect area) : base(source, area)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +956,7 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
public Color BackgroundBlendColor { get; set; }
|
public Color BackgroundBlendColor { get; set; }
|
||||||
|
|
||||||
public Fast32ArgbBitmap(Bitmap source, Rectangle area) : base(source, area)
|
public Fast32ArgbBitmap(Bitmap source, NativeRect area) : base(source, area)
|
||||||
{
|
{
|
||||||
BackgroundBlendColor = Color.White;
|
BackgroundBlendColor = Color.White;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
if (image is Bitmap && (image.Width * image.Height > 0))
|
if (image is Bitmap && (image.Width * image.Height > 0))
|
||||||
{
|
{
|
||||||
cropNativeRect.Intersect(new NativeRect(0, 0, image.Width, image.Height));
|
cropNativeRect = cropNativeRect.Intersect(new NativeRect(0, 0, image.Width, image.Height));
|
||||||
if (cropNativeRect.Width != 0 || cropNativeRect.Height != 0)
|
if (cropNativeRect.Width != 0 || cropNativeRect.Height != 0)
|
||||||
{
|
{
|
||||||
Image returnImage = CloneArea(image, cropNativeRect, PixelFormat.DontCare);
|
Image returnImage = CloneArea(image, cropNativeRect, PixelFormat.DontCare);
|
||||||
|
@ -769,7 +769,7 @@ namespace Greenshot.Base.Core
|
||||||
/// <param name="applySize"></param>
|
/// <param name="applySize"></param>
|
||||||
/// <param name="rect"></param>
|
/// <param name="rect"></param>
|
||||||
/// <param name="invert"></param>
|
/// <param name="invert"></param>
|
||||||
/// <returns></returns>
|
/// <returns>NativeRect</returns>
|
||||||
public static NativeRect CreateIntersectRectangle(NativeSize applySize, NativeRect rect, bool invert)
|
public static NativeRect CreateIntersectRectangle(NativeSize applySize, NativeRect rect, bool invert)
|
||||||
{
|
{
|
||||||
NativeRect myRect;
|
NativeRect myRect;
|
||||||
|
|
|
@ -598,54 +598,7 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
return bmpPngExtracted;
|
return bmpPngExtracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">The file (EXE or DLL) to get the icon from</param>
|
|
||||||
/// <param name="index">Index of the icon</param>
|
|
||||||
/// <param name="takeLarge">true if the large icon is wanted</param>
|
|
||||||
/// <returns>Icon</returns>
|
|
||||||
public static Icon ExtractAssociatedIcon(string location, int index, bool takeLarge)
|
|
||||||
{
|
|
||||||
NativeIconMethods.ExtractIconEx(location, index, out var large, out var small, 1);
|
|
||||||
Icon returnIcon = null;
|
|
||||||
bool isLarge = false;
|
|
||||||
bool isSmall = false;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (takeLarge && !IntPtr.Zero.Equals(large))
|
|
||||||
{
|
|
||||||
returnIcon = Icon.FromHandle(large);
|
|
||||||
isLarge = true;
|
|
||||||
}
|
|
||||||
else if (!IntPtr.Zero.Equals(small))
|
|
||||||
{
|
|
||||||
returnIcon = Icon.FromHandle(small);
|
|
||||||
isSmall = true;
|
|
||||||
}
|
|
||||||
else if (!IntPtr.Zero.Equals(large))
|
|
||||||
{
|
|
||||||
returnIcon = Icon.FromHandle(large);
|
|
||||||
isLarge = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (isLarge && !IntPtr.Zero.Equals(small))
|
|
||||||
{
|
|
||||||
NativeIconMethods.DestroyIcon(small);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSmall && !IntPtr.Zero.Equals(large))
|
|
||||||
{
|
|
||||||
NativeIconMethods.DestroyIcon(large);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an image from a stream, if an extension is supplied more formats are supported.
|
/// Create an image from a stream, if an extension is supplied more formats are supported.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Dapplo.Windows.Icons;
|
using Dapplo.Windows.Icons;
|
||||||
using Dapplo.Windows.Icons.Enums;
|
|
||||||
using Greenshot.Base.IniFile;
|
using Greenshot.Base.IniFile;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
@ -159,21 +159,10 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (Icon appIcon = IconHelper.ExtractAssociatedIcon<Icon>(path, index, CoreConfig.UseLargeIcons))
|
var appIcon = IconHelper.ExtractAssociatedIcon<Bitmap>(path, index, CoreConfig.UseLargeIcons);
|
||||||
{
|
Debug.Assert(appIcon != null && (appIcon.Width*appIcon.Height > 0), "Invalid icon");
|
||||||
if (appIcon != null)
|
Log.DebugFormat("Loaded icon for {0}, with dimensions {1}x{2}", path, appIcon.Width, appIcon.Height);
|
||||||
{
|
return appIcon;
|
||||||
return appIcon.ToBitmap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (Icon appIcon = IconHelper.GetFileExtensionIcon<Icon>(path, CoreConfig.UseLargeIcons ? IconSize.Large : IconSize.Small, false))
|
|
||||||
{
|
|
||||||
if (appIcon != null)
|
|
||||||
{
|
|
||||||
return appIcon.ToBitmap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception exIcon)
|
catch (Exception exIcon)
|
||||||
{
|
{
|
||||||
|
@ -196,27 +185,25 @@ namespace Greenshot.Base.Core
|
||||||
// Try to find a separator, so we insert ourselves after it
|
// Try to find a separator, so we insert ourselves after it
|
||||||
for (int i = 0; i < contextMenu.Items.Count; i++)
|
for (int i = 0; i < contextMenu.Items.Count; i++)
|
||||||
{
|
{
|
||||||
if (contextMenu.Items[i].GetType() == typeof(ToolStripSeparator))
|
if (contextMenu.Items[i].GetType() != typeof(ToolStripSeparator)) continue;
|
||||||
|
// Check if we need to add a new separator, which is done if the first found has a Tag with the value "PluginsAreAddedBefore"
|
||||||
|
if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag))
|
||||||
{
|
{
|
||||||
// Check if we need to add a new separator, which is done if the first found has a Tag with the value "PluginsAreAddedBefore"
|
var separator = new ToolStripSeparator
|
||||||
if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag))
|
|
||||||
{
|
{
|
||||||
var separator = new ToolStripSeparator
|
Tag = "PluginsAreAddedAfter",
|
||||||
{
|
Size = new Size(305, 6)
|
||||||
Tag = "PluginsAreAddedAfter",
|
};
|
||||||
Size = new Size(305, 6)
|
contextMenu.Items.Insert(i, separator);
|
||||||
};
|
|
||||||
contextMenu.Items.Insert(i, separator);
|
|
||||||
}
|
|
||||||
else if (!"PluginsAreAddedAfter".Equals(contextMenu.Items[i].Tag))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMenu.Items.Insert(i + 1, item);
|
|
||||||
addedItem = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (!"PluginsAreAddedAfter".Equals(contextMenu.Items[i].Tag))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu.Items.Insert(i + 1, item);
|
||||||
|
addedItem = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't insert the item, we just add it...
|
// If we didn't insert the item, we just add it...
|
||||||
|
|
|
@ -52,26 +52,6 @@ namespace Greenshot.Base.Core
|
||||||
private static readonly ILog Log = LogManager.GetLogger(typeof(WindowCapture));
|
private static readonly ILog Log = LogManager.GetLogger(typeof(WindowCapture));
|
||||||
private static readonly CoreConfiguration Configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
private static readonly CoreConfiguration Configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the bounds of all screens combined.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A Rectangle of the bounds of the entire display area.</returns>
|
|
||||||
public static NativeRect GetScreenBounds()
|
|
||||||
{
|
|
||||||
int left = 0, top = 0, bottom = 0, right = 0;
|
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
|
||||||
{
|
|
||||||
left = Math.Min(left, screen.Bounds.X);
|
|
||||||
top = Math.Min(top, screen.Bounds.Y);
|
|
||||||
int screenAbsRight = screen.Bounds.X + screen.Bounds.Width;
|
|
||||||
int screenAbsBottom = screen.Bounds.Y + screen.Bounds.Height;
|
|
||||||
right = Math.Max(right, screenAbsRight);
|
|
||||||
bottom = Math.Max(bottom, screenAbsBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Rectangle(left, top, (right + Math.Abs(left)), (bottom + Math.Abs(top)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7. This implementation
|
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7. This implementation
|
||||||
/// can conveniently be used when the cursor location is needed to deal with a fullscreen bitmap.
|
/// can conveniently be used when the cursor location is needed to deal with a fullscreen bitmap.
|
||||||
|
@ -93,10 +73,8 @@ namespace Greenshot.Base.Core
|
||||||
/// <returns>Point</returns>
|
/// <returns>Point</returns>
|
||||||
public static NativePoint GetLocationRelativeToScreenBounds(NativePoint locationRelativeToScreenOrigin)
|
public static NativePoint GetLocationRelativeToScreenBounds(NativePoint locationRelativeToScreenOrigin)
|
||||||
{
|
{
|
||||||
NativePoint ret = locationRelativeToScreenOrigin;
|
NativeRect bounds = DisplayInfo.ScreenBounds;
|
||||||
NativeRect bounds = GetScreenBounds();
|
return locationRelativeToScreenOrigin.Offset(-bounds.X, -bounds.Y);
|
||||||
ret.Offset(-bounds.X, -bounds.Y);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -152,9 +130,9 @@ namespace Greenshot.Base.Core
|
||||||
/// Helper method to create an exception that might explain what is wrong while capturing
|
/// Helper method to create an exception that might explain what is wrong while capturing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="method">string with current method</param>
|
/// <param name="method">string with current method</param>
|
||||||
/// <param name="captureBounds">Rectangle of what we want to capture</param>
|
/// <param name="captureBounds">NativeRect of what we want to capture</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static Exception CreateCaptureException(string method, Rectangle captureBounds)
|
private static Exception CreateCaptureException(string method, NativeRect captureBounds)
|
||||||
{
|
{
|
||||||
Exception exceptionToThrow = User32Api.CreateWin32Exception(method);
|
Exception exceptionToThrow = User32Api.CreateWin32Exception(method);
|
||||||
if (!captureBounds.IsEmpty)
|
if (!captureBounds.IsEmpty)
|
||||||
|
@ -224,9 +202,9 @@ namespace Greenshot.Base.Core
|
||||||
/// This method will use User32 code to capture the specified captureBounds from the screen
|
/// This method will use User32 code to capture the specified captureBounds from the screen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capture">ICapture where the captured Bitmap will be stored</param>
|
/// <param name="capture">ICapture where the captured Bitmap will be stored</param>
|
||||||
/// <param name="captureBounds">Rectangle with the bounds to capture</param>
|
/// <param name="captureBounds">NativeRect with the bounds to capture</param>
|
||||||
/// <returns>A Capture Object with a part of the Screen as an Image</returns>
|
/// <returns>A Capture Object with a part of the Screen as an Image</returns>
|
||||||
public static ICapture CaptureRectangle(ICapture capture, Rectangle captureBounds)
|
public static ICapture CaptureRectangle(ICapture capture, NativeRect captureBounds)
|
||||||
{
|
{
|
||||||
if (capture == null)
|
if (capture == null)
|
||||||
{
|
{
|
||||||
|
@ -262,9 +240,9 @@ namespace Greenshot.Base.Core
|
||||||
/// This method will use User32 code to capture the specified captureBounds from the screen
|
/// This method will use User32 code to capture the specified captureBounds from the screen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capture">ICapture where the captured Bitmap will be stored</param>
|
/// <param name="capture">ICapture where the captured Bitmap will be stored</param>
|
||||||
/// <param name="captureBounds">Rectangle with the bounds to capture</param>
|
/// <param name="captureBounds">NativeRect with the bounds to capture</param>
|
||||||
/// <returns>A Capture Object with a part of the Screen as an Image</returns>
|
/// <returns>A Capture Object with a part of the Screen as an Image</returns>
|
||||||
public static ICapture CaptureRectangleFromDesktopScreen(ICapture capture, Rectangle captureBounds)
|
public static ICapture CaptureRectangleFromDesktopScreen(ICapture capture, NativeRect captureBounds)
|
||||||
{
|
{
|
||||||
if (capture == null)
|
if (capture == null)
|
||||||
{
|
{
|
||||||
|
@ -279,9 +257,9 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method will use User32 code to capture the specified captureBounds from the screen
|
/// This method will use User32 code to capture the specified captureBounds from the screen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="captureBounds">Rectangle with the bounds to capture</param>
|
/// <param name="captureBounds">NativeRect with the bounds to capture</param>
|
||||||
/// <returns>Bitmap which is captured from the screen at the location specified by the captureBounds</returns>
|
/// <returns>Bitmap which is captured from the screen at the location specified by the captureBounds</returns>
|
||||||
public static Bitmap CaptureRectangle(Rectangle captureBounds)
|
public static Bitmap CaptureRectangle(NativeRect captureBounds)
|
||||||
{
|
{
|
||||||
Bitmap returnBitmap = null;
|
Bitmap returnBitmap = null;
|
||||||
if (captureBounds.Height <= 0 || captureBounds.Width <= 0)
|
if (captureBounds.Height <= 0 || captureBounds.Width <= 0)
|
||||||
|
@ -388,17 +366,16 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
using Bitmap tmpBitmap = Image.FromHbitmap(safeDibSectionHandle.DangerousGetHandle());
|
using Bitmap tmpBitmap = Image.FromHbitmap(safeDibSectionHandle.DangerousGetHandle());
|
||||||
// Create a new bitmap which has a transparent background
|
// Create a new bitmap which has a transparent background
|
||||||
returnBitmap = ImageHelper.CreateEmpty(tmpBitmap.Width, tmpBitmap.Height, PixelFormat.Format32bppArgb, Color.Transparent,
|
returnBitmap = ImageHelper.CreateEmpty(tmpBitmap.Width, tmpBitmap.Height, PixelFormat.Format32bppArgb, Color.Transparent, tmpBitmap.HorizontalResolution, tmpBitmap.VerticalResolution);
|
||||||
tmpBitmap.HorizontalResolution, tmpBitmap.VerticalResolution);
|
|
||||||
// Content will be copied here
|
// Content will be copied here
|
||||||
using Graphics graphics = Graphics.FromImage(returnBitmap);
|
using Graphics graphics = Graphics.FromImage(returnBitmap);
|
||||||
// For all screens copy the content to the new bitmap
|
// For all screens copy the content to the new bitmap
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
|
||||||
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
{
|
{
|
||||||
Rectangle screenBounds = screen.Bounds;
|
// Make sure the bounds are offset to the capture bounds
|
||||||
// Make sure the bounds are offsetted to the capture bounds
|
var displayBounds = displayInfo.Bounds.Offset(-captureBounds.X, -captureBounds.Y);
|
||||||
screenBounds.Offset(-captureBounds.X, -captureBounds.Y);
|
graphics.DrawImage(tmpBitmap, displayBounds, displayBounds.X, displayBounds.Y, displayBounds.Width, displayBounds.Height, GraphicsUnit.Pixel);
|
||||||
graphics.DrawImage(tmpBitmap, screenBounds, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height, GraphicsUnit.Pixel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -498,15 +498,11 @@ namespace Greenshot.Base.Core
|
||||||
{
|
{
|
||||||
if (Visible)
|
if (Visible)
|
||||||
{
|
{
|
||||||
Rectangle windowRectangle = WindowRectangle;
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
foreach (var screen in Screen.AllScreens)
|
|
||||||
{
|
{
|
||||||
if (screen.Bounds.Contains(windowRectangle))
|
if (WindowRectangle.Equals(displayInfo.Bounds))
|
||||||
{
|
{
|
||||||
if (windowRectangle.Equals(screen.Bounds))
|
return true;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,32 +548,31 @@ namespace Greenshot.Base.Core
|
||||||
|
|
||||||
if (IsApp)
|
if (IsApp)
|
||||||
{
|
{
|
||||||
Rectangle windowRectangle = WindowRectangle;
|
var windowRectangle = WindowRectangle;
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
|
||||||
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
{
|
{
|
||||||
if (screen.Bounds.Contains(windowRectangle))
|
if (!displayInfo.Bounds.Contains(windowRectangle)) continue;
|
||||||
|
if (windowRectangle.Equals(displayInfo.Bounds))
|
||||||
{
|
{
|
||||||
if (windowRectangle.Equals(screen.Bounds))
|
// Fullscreen, it's "visible" when AppVisibilityOnMonitor says yes
|
||||||
|
// Although it might be the other App, this is not "very" important
|
||||||
|
NativeRect rect = displayInfo.Bounds;
|
||||||
|
IntPtr monitor = User32Api.MonitorFromRect(ref rect, MonitorFrom.DefaultToNull);
|
||||||
|
if (monitor != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
// Fullscreen, it's "visible" when AppVisibilityOnMonitor says yes
|
MONITOR_APP_VISIBILITY? monitorAppVisibility = AppVisibility?.GetAppVisibilityOnMonitor(monitor);
|
||||||
// Although it might be the other App, this is not "very" important
|
//LOG.DebugFormat("App {0} visible: {1} on {2}", Text, monitorAppVisibility, screen.Bounds);
|
||||||
NativeRect rect = screen.Bounds;
|
if (monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE)
|
||||||
IntPtr monitor = User32Api.MonitorFromRect(ref rect, MonitorFrom.DefaultToNull);
|
|
||||||
if (monitor != IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
MONITOR_APP_VISIBILITY? monitorAppVisibility = AppVisibility?.GetAppVisibilityOnMonitor(monitor);
|
return true;
|
||||||
//LOG.DebugFormat("App {0} visible: {1} on {2}", Text, monitorAppVisibility, screen.Bounds);
|
|
||||||
if (monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
// Is only partly on the screen, when this happens the app is always visible!
|
{
|
||||||
return true;
|
// Is only partly on the screen, when this happens the app is always visible!
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +630,7 @@ namespace Greenshot.Base.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle _previousWindowRectangle = Rectangle.Empty;
|
private NativeRect _previousWindowRectangle = NativeRect.Empty;
|
||||||
private long _lastWindowRectangleRetrieveTime;
|
private long _lastWindowRectangleRetrieveTime;
|
||||||
private const long CacheTime = TimeSpan.TicksPerSecond * 2;
|
private const long CacheTime = TimeSpan.TicksPerSecond * 2;
|
||||||
|
|
||||||
|
@ -694,13 +689,13 @@ namespace Greenshot.Base.Core
|
||||||
// Only if the border size can be retrieved
|
// Only if the border size can be retrieved
|
||||||
if (GetBorderSize(out var size))
|
if (GetBorderSize(out var size))
|
||||||
{
|
{
|
||||||
windowRect = new Rectangle(windowRect.X + size.Width, windowRect.Y + size.Height, windowRect.Width - (2 * size.Width),
|
windowRect = new NativeRect(windowRect.X + size.Width, windowRect.Y + size.Height, windowRect.Width - (2 * size.Width),
|
||||||
windowRect.Height - (2 * size.Height));
|
windowRect.Height - (2 * size.Height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastWindowRectangleRetrieveTime = now;
|
_lastWindowRectangleRetrieveTime = now;
|
||||||
// Try to return something valid, by getting returning the previous size if the window doesn't have a Rectangle anymore
|
// Try to return something valid, by getting returning the previous size if the window doesn't have a NativeRect anymore
|
||||||
if (windowRect.IsEmpty)
|
if (windowRect.IsEmpty)
|
||||||
{
|
{
|
||||||
return _previousWindowRectangle;
|
return _previousWindowRectangle;
|
||||||
|
@ -717,31 +712,23 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the location of the window relative to the screen.
|
/// Gets the location of the window relative to the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Point Location
|
public NativePoint Location
|
||||||
{
|
{
|
||||||
get
|
get => WindowRectangle.Location;
|
||||||
{
|
|
||||||
Rectangle tmpRectangle = WindowRectangle;
|
|
||||||
return new Point(tmpRectangle.Left, tmpRectangle.Top);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the size of the window.
|
/// Gets the size of the window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Size Size
|
public NativeSize Size
|
||||||
{
|
{
|
||||||
get
|
get => WindowRectangle.Size;
|
||||||
{
|
|
||||||
Rectangle tmpRectangle = WindowRectangle;
|
|
||||||
return new Size(tmpRectangle.Right - tmpRectangle.Left, tmpRectangle.Bottom - tmpRectangle.Top);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the client rectangle, this is the part of the window inside the borders (drawable area)
|
/// Get the client rectangle, this is the part of the window inside the borders (drawable area)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Rectangle ClientRectangle
|
public NativeRect ClientRectangle
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -760,7 +747,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="p">Point with the coordinates to check</param>
|
/// <param name="p">Point with the coordinates to check</param>
|
||||||
/// <returns>true if the point lies within</returns>
|
/// <returns>true if the point lies within</returns>
|
||||||
public bool Contains(Point p)
|
public bool Contains(NativePoint p)
|
||||||
{
|
{
|
||||||
return WindowRectangle.Contains(p);
|
return WindowRectangle.Contains(p);
|
||||||
}
|
}
|
||||||
|
@ -891,12 +878,13 @@ namespace Greenshot.Base.Core
|
||||||
if (!workingArea.AreRectangleCornersVisisble(windowRectangle))
|
if (!workingArea.AreRectangleCornersVisisble(windowRectangle))
|
||||||
{
|
{
|
||||||
// If none found we find the biggest screen
|
// If none found we find the biggest screen
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
|
||||||
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
{
|
{
|
||||||
Rectangle newWindowRectangle = new Rectangle(screen.WorkingArea.Location, windowRectangle.Size);
|
var newWindowRectangle = new NativeRect(displayInfo.WorkingArea.Location, windowRectangle.Size);
|
||||||
if (workingArea.AreRectangleCornersVisisble(newWindowRectangle))
|
if (workingArea.AreRectangleCornersVisisble(newWindowRectangle))
|
||||||
{
|
{
|
||||||
formLocation = screen.Bounds.Location;
|
formLocation = displayInfo.Bounds.Location;
|
||||||
doesCaptureFit = true;
|
doesCaptureFit = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1169,7 +1157,7 @@ namespace Greenshot.Base.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method to get the window size for DWM Windows
|
/// Helper method to get the window size for DWM Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rectangle">out Rectangle</param>
|
/// <param name="rectangle">out NativeRect</param>
|
||||||
/// <returns>bool true if it worked</returns>
|
/// <returns>bool true if it worked</returns>
|
||||||
private bool GetExtendedFrameBounds(out NativeRect rectangle)
|
private bool GetExtendedFrameBounds(out NativeRect rectangle)
|
||||||
{
|
{
|
||||||
|
@ -1180,7 +1168,7 @@ namespace Greenshot.Base.Core
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rectangle = Rectangle.Empty;
|
rectangle = NativeRect.Empty;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,7 +1182,7 @@ namespace Greenshot.Base.Core
|
||||||
var windowInfo = new WindowInfo();
|
var windowInfo = new WindowInfo();
|
||||||
// Get the Window Info for this window
|
// Get the Window Info for this window
|
||||||
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
||||||
rectangle = result ? windowInfo.ClientBounds : Rectangle.Empty;
|
rectangle = result ? windowInfo.ClientBounds : NativeRect.Empty;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,7 +1196,7 @@ namespace Greenshot.Base.Core
|
||||||
var windowInfo = new WindowInfo();
|
var windowInfo = new WindowInfo();
|
||||||
// Get the Window Info for this window
|
// Get the Window Info for this window
|
||||||
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
||||||
rectangle = result ? windowInfo.Bounds : Rectangle.Empty;
|
rectangle = result ? windowInfo.Bounds : NativeRect.Empty;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1210,7 @@ namespace Greenshot.Base.Core
|
||||||
var windowInfo = new WindowInfo();
|
var windowInfo = new WindowInfo();
|
||||||
// Get the Window Info for this window
|
// Get the Window Info for this window
|
||||||
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
bool result = User32Api.GetWindowInfo(Handle, ref windowInfo);
|
||||||
size = result ? windowInfo.BorderSize : Size.Empty;
|
size = result ? windowInfo.BorderSize : NativeSize.Empty;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1403,7 +1391,7 @@ namespace Greenshot.Base.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Image PrintWindow()
|
public Image PrintWindow()
|
||||||
{
|
{
|
||||||
Rectangle windowRect = WindowRectangle;
|
NativeRect windowRect = WindowRectangle;
|
||||||
// Start the capture
|
// Start the capture
|
||||||
Exception exceptionOccurred = null;
|
Exception exceptionOccurred = null;
|
||||||
Image returnImage;
|
Image returnImage;
|
||||||
|
@ -1561,7 +1549,7 @@ namespace Greenshot.Base.Core
|
||||||
/// <param name="window"></param>
|
/// <param name="window"></param>
|
||||||
/// <param name="screenBounds"></param>
|
/// <param name="screenBounds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static bool IsVisible(WindowDetails window, Rectangle screenBounds)
|
private static bool IsVisible(WindowDetails window, NativeRect screenBounds)
|
||||||
{
|
{
|
||||||
// Ignore invisible
|
// Ignore invisible
|
||||||
if (!window.Visible)
|
if (!window.Visible)
|
||||||
|
@ -1603,7 +1591,7 @@ namespace Greenshot.Base.Core
|
||||||
/// <returns>List WindowDetails with all the visible top level windows</returns>
|
/// <returns>List WindowDetails with all the visible top level windows</returns>
|
||||||
public static IEnumerable<WindowDetails> GetVisibleWindows()
|
public static IEnumerable<WindowDetails> GetVisibleWindows()
|
||||||
{
|
{
|
||||||
Rectangle screenBounds = WindowCapture.GetScreenBounds();
|
var screenBounds = DisplayInfo.ScreenBounds;
|
||||||
foreach (var window in GetAppWindows())
|
foreach (var window in GetAppWindows())
|
||||||
{
|
{
|
||||||
if (IsVisible(window, screenBounds))
|
if (IsVisible(window, screenBounds))
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="1.0.21" />
|
||||||
<PackageReference Include="Dapplo.Windows.Dpi" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Dpi" Version="1.0.21" />
|
||||||
<PackageReference Include="Dapplo.Windows.Gdi32" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Gdi32" Version="1.0.21" />
|
||||||
<PackageReference Include="Dapplo.Windows.Icons" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Icons" Version="1.0.21" />
|
||||||
<PackageReference Include="Dapplo.Windows.Kernel32" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Kernel32" Version="1.0.21" />
|
||||||
<PackageReference Include="Dapplo.Windows.Multimedia" Version="1.0.19" />
|
<PackageReference Include="Dapplo.Windows.Multimedia" Version="1.0.21" />
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
|
||||||
<PackageReference Include="log4net" version="2.0.14" />
|
<PackageReference Include="log4net" version="2.0.14" />
|
||||||
<PackageReference Include="Svg" Version="3.4.1" />
|
<PackageReference Include="Svg" Version="3.4.1" />
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Greenshot.Base.Interfaces.Drawing
|
||||||
|
|
||||||
NativeRect DrawingBounds { get; }
|
NativeRect DrawingBounds { get; }
|
||||||
|
|
||||||
void ApplyBounds(RectangleF newBounds);
|
void ApplyBounds(NativeRectFloat newBounds);
|
||||||
|
|
||||||
bool HasFilters { get; }
|
bool HasFilters { get; }
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace Greenshot.Base.Interfaces
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Crops the capture to the specified rectangle (with Bitmap coordinates!)
|
/// Crops the capture to the specified rectangle (with Bitmap coordinates!)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropRectangle">Rectangle with bitmap coordinates</param>
|
/// <param name="cropRectangle">NativeRect with bitmap coordinates</param>
|
||||||
bool Crop(NativeRect cropRectangle);
|
bool Crop(NativeRect cropRectangle);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -58,12 +58,12 @@ namespace Greenshot.Base.Interfaces.Ocr
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the bounds of the words
|
/// Calculate the bounds of the words
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Rectangle</returns>
|
/// <returns>NativeRect</returns>
|
||||||
private NativeRect CalculateBounds()
|
private NativeRect CalculateBounds()
|
||||||
{
|
{
|
||||||
if (Words.Length == 0)
|
if (Words.Length == 0)
|
||||||
{
|
{
|
||||||
return Rectangle.Empty;
|
return NativeRect.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = Words[0].Bounds;
|
var result = Words[0].Bounds;
|
||||||
|
@ -92,9 +92,7 @@ namespace Greenshot.Base.Interfaces.Ocr
|
||||||
{
|
{
|
||||||
foreach (var word in Words)
|
foreach (var word in Words)
|
||||||
{
|
{
|
||||||
var location = word.Bounds;
|
word.Bounds = word.Bounds.Offset(x, y);
|
||||||
location.Offset(x, y);
|
|
||||||
word.Bounds = location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculatedBounds = null;
|
_calculatedBounds = null;
|
||||||
|
|
|
@ -152,9 +152,9 @@ namespace Greenshot.Editor.Configuration
|
||||||
|
|
||||||
public void ResetEditorPlacement()
|
public void ResetEditorPlacement()
|
||||||
{
|
{
|
||||||
WindowNormalPosition = new Rectangle(100, 100, 400, 400);
|
WindowNormalPosition = new NativeRect(100, 100, 400, 400);
|
||||||
WindowMaxPosition = new Point(-1, -1);
|
WindowMaxPosition = new NativePoint(-1, -1);
|
||||||
WindowMinPosition = new Point(-1, -1);
|
WindowMinPosition = new NativePoint(-1, -1);
|
||||||
WindowPlacementFlags = 0;
|
WindowPlacementFlags = 0;
|
||||||
ShowWindowCommand = ShowWindowCommands.Normal;
|
ShowWindowCommand = ShowWindowCommands.Normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Controls;
|
using Greenshot.Base.Controls;
|
||||||
using ColorDialog = Greenshot.Editor.Forms.ColorDialog;
|
using ColorDialog = Greenshot.Editor.Forms.ColorDialog;
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ namespace Greenshot.Editor.Controls
|
||||||
if (Image != null)
|
if (Image != null)
|
||||||
{
|
{
|
||||||
using Graphics graphics = Graphics.FromImage(Image);
|
using Graphics graphics = Graphics.FromImage(Image);
|
||||||
graphics.FillRectangle(brush, new Rectangle(4, 17, 16, 3));
|
graphics.FillRectangle(brush, new NativeRect(4, 17, 16, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup GDI Object
|
// cleanup GDI Object
|
||||||
|
|
|
@ -23,6 +23,7 @@ using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Controls
|
namespace Greenshot.Editor.Controls
|
||||||
{
|
{
|
||||||
|
@ -113,12 +114,12 @@ namespace Greenshot.Editor.Controls
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method to draw the string
|
/// Helper method to draw the string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics">Graphics</param>
|
||||||
/// <param name="fontFamily"></param>
|
/// <param name="fontFamily">FontFamily</param>
|
||||||
/// <param name="fontStyle"></param>
|
/// <param name="fontStyle">FontStyle</param>
|
||||||
/// <param name="bounds"></param>
|
/// <param name="bounds">NativeRect</param>
|
||||||
/// <param name="text"></param>
|
/// <param name="text">string</param>
|
||||||
private void DrawText(Graphics graphics, FontFamily fontFamily, FontStyle fontStyle, Rectangle bounds, string text)
|
private void DrawText(Graphics graphics, FontFamily fontFamily, FontStyle fontStyle, NativeRect bounds, string text)
|
||||||
{
|
{
|
||||||
using Font font = new Font(fontFamily, Font.Size + 5, fontStyle, GraphicsUnit.Pixel);
|
using Font font = new Font(fontFamily, Font.Size + 5, fontStyle, GraphicsUnit.Pixel);
|
||||||
// Make sure the text is visible by centering it in the line
|
// Make sure the text is visible by centering it in the line
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Controls;
|
using Greenshot.Base.Controls;
|
||||||
using ColorDialog = Greenshot.Editor.Forms.ColorDialog;
|
using ColorDialog = Greenshot.Editor.Forms.ColorDialog;
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ namespace Greenshot.Editor.Controls
|
||||||
if (Image != null)
|
if (Image != null)
|
||||||
{
|
{
|
||||||
using Graphics graphics = Graphics.FromImage(Image);
|
using Graphics graphics = Graphics.FromImage(Image);
|
||||||
graphics.FillRectangle(brush, new Rectangle(0, 13, 16, 3));
|
graphics.FillRectangle(brush, new NativeRect(0, 13, 16, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup GDI Object
|
// cleanup GDI Object
|
||||||
|
|
|
@ -34,8 +34,8 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
{
|
{
|
||||||
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
|
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
|
||||||
|
|
||||||
private static readonly Size DefaultSize = new Size(6, 6);
|
private static readonly NativeSize DefaultSize = new NativeSize(6, 6);
|
||||||
protected Size _size;
|
protected NativeSize _size;
|
||||||
|
|
||||||
public AbstractAdorner(IDrawableContainer owner)
|
public AbstractAdorner(IDrawableContainer owner)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the location of the adorner
|
/// Return the location of the adorner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Point Location { get; set; }
|
public virtual NativePoint Location { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the bounds of the Adorner
|
/// Return the bounds of the Adorner
|
||||||
|
@ -112,12 +112,12 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the bounds of the Adorner as displayed on the parent Surface
|
/// Return the bounds of the Adorner as displayed on the parent Surface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual Rectangle BoundsOnSurface
|
protected virtual NativeRect BoundsOnSurface
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Point displayLocation = Owner.Parent.ToSurfaceCoordinates(Location);
|
NativePoint displayLocation = Owner.Parent.ToSurfaceCoordinates(Location);
|
||||||
return new Rectangle(displayLocation.X - _size.Width / 2, displayLocation.Y - _size.Height / 2, _size.Width, _size.Height);
|
return new NativeRect(displayLocation.X - _size.Width / 2, displayLocation.Y - _size.Height / 2, _size.Width, _size.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Helpers;
|
using Greenshot.Editor.Helpers;
|
||||||
|
|
||||||
|
@ -31,8 +32,8 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MoveAdorner : AbstractAdorner
|
public class MoveAdorner : AbstractAdorner
|
||||||
{
|
{
|
||||||
private Rectangle _boundsBeforeResize = Rectangle.Empty;
|
private NativeRect _boundsBeforeResize = NativeRect.Empty;
|
||||||
private RectangleF _boundsAfterResize = RectangleF.Empty;
|
private NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty;
|
||||||
|
|
||||||
public Positions Position { get; private set; }
|
public Positions Position { get; private set; }
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
|
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
|
||||||
{
|
{
|
||||||
EditStatus = EditStatus.RESIZING;
|
EditStatus = EditStatus.RESIZING;
|
||||||
_boundsBeforeResize = new Rectangle(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
_boundsBeforeResize = new NativeRect(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
||||||
_boundsAfterResize = _boundsBeforeResize;
|
_boundsAfterResize = _boundsBeforeResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +75,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
Owner.MakeBoundsChangeUndoable(false);
|
Owner.MakeBoundsChangeUndoable(false);
|
||||||
|
|
||||||
// reset "workbench" rectangle to current bounds
|
// reset "workbench" rectangle to current bounds
|
||||||
_boundsAfterResize.X = _boundsBeforeResize.X;
|
_boundsAfterResize = _boundsBeforeResize;
|
||||||
_boundsAfterResize.Y = _boundsBeforeResize.Y;
|
|
||||||
_boundsAfterResize.Width = _boundsBeforeResize.Width;
|
|
||||||
_boundsAfterResize.Height = _boundsBeforeResize.Height;
|
|
||||||
|
|
||||||
// calculate scaled rectangle
|
// calculate scaled rectangle
|
||||||
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
||||||
|
@ -91,7 +89,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the location of the adorner
|
/// Return the location of the adorner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override Point Location
|
public override NativePoint Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -132,7 +130,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Point(x, y);
|
return new NativePoint(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Helpers;
|
using Greenshot.Editor.Helpers;
|
||||||
|
|
||||||
|
@ -31,8 +32,8 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ResizeAdorner : AbstractAdorner
|
public class ResizeAdorner : AbstractAdorner
|
||||||
{
|
{
|
||||||
private Rectangle _boundsBeforeResize = Rectangle.Empty;
|
private NativeRect _boundsBeforeResize = NativeRect.Empty;
|
||||||
private RectangleF _boundsAfterResize = RectangleF.Empty;
|
private NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty;
|
||||||
|
|
||||||
public Positions Position { get; private set; }
|
public Positions Position { get; private set; }
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
|
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
|
||||||
{
|
{
|
||||||
EditStatus = EditStatus.RESIZING;
|
EditStatus = EditStatus.RESIZING;
|
||||||
_boundsBeforeResize = new Rectangle(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
_boundsBeforeResize = new NativeRect(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
||||||
_boundsAfterResize = _boundsBeforeResize;
|
_boundsAfterResize = _boundsBeforeResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +103,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
Owner.MakeBoundsChangeUndoable(false);
|
Owner.MakeBoundsChangeUndoable(false);
|
||||||
|
|
||||||
// reset "workbench" rectangle to current bounds
|
// reset "workbench" rectangle to current bounds
|
||||||
_boundsAfterResize.X = _boundsBeforeResize.X;
|
_boundsAfterResize = _boundsBeforeResize;
|
||||||
_boundsAfterResize.Y = _boundsBeforeResize.Y;
|
|
||||||
_boundsAfterResize.Width = _boundsBeforeResize.Width;
|
|
||||||
_boundsAfterResize.Height = _boundsBeforeResize.Height;
|
|
||||||
|
|
||||||
// calculate scaled rectangle
|
// calculate scaled rectangle
|
||||||
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
||||||
|
@ -119,7 +117,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the location of the adorner
|
/// Return the location of the adorner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override Point Location
|
public override NativePoint Location
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Adorners
|
namespace Greenshot.Editor.Drawing.Adorners
|
||||||
|
@ -61,30 +63,30 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.Invalidate();
|
Owner.Invalidate();
|
||||||
Point newGripperLocation = new Point(mouseEventArgs.X, mouseEventArgs.Y);
|
NativePoint newGripperLocation = new NativePoint(mouseEventArgs.X, mouseEventArgs.Y);
|
||||||
Rectangle imageBounds = new Rectangle(0, 0, Owner.Parent.Image.Width, Owner.Parent.Image.Height);
|
NativeRect imageBounds = new NativeRect(0, 0, Owner.Parent.Image.Width, Owner.Parent.Image.Height);
|
||||||
// Check if gripper inside the parent (surface), if not we need to move it inside
|
// Check if gripper inside the parent (surface), if not we need to move it inside
|
||||||
// This was made for BUG-1682
|
// This was made for BUG-1682
|
||||||
if (!imageBounds.Contains(newGripperLocation))
|
if (!imageBounds.Contains(newGripperLocation))
|
||||||
{
|
{
|
||||||
if (newGripperLocation.X > imageBounds.Right)
|
if (newGripperLocation.X > imageBounds.Right)
|
||||||
{
|
{
|
||||||
newGripperLocation.X = imageBounds.Right - 5;
|
newGripperLocation = newGripperLocation.ChangeX(imageBounds.Right - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newGripperLocation.X < imageBounds.Left)
|
if (newGripperLocation.X < imageBounds.Left)
|
||||||
{
|
{
|
||||||
newGripperLocation.X = imageBounds.Left;
|
newGripperLocation = newGripperLocation.ChangeX(imageBounds.Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newGripperLocation.Y > imageBounds.Bottom)
|
if (newGripperLocation.Y > imageBounds.Bottom)
|
||||||
{
|
{
|
||||||
newGripperLocation.Y = imageBounds.Bottom - 5;
|
newGripperLocation = newGripperLocation.ChangeY(imageBounds.Bottom - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newGripperLocation.Y < imageBounds.Top)
|
if (newGripperLocation.Y < imageBounds.Top)
|
||||||
{
|
{
|
||||||
newGripperLocation.Y = imageBounds.Top;
|
newGripperLocation = newGripperLocation.ChangeY(imageBounds.Top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ namespace Greenshot.Editor.Drawing.Adorners
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point[] points = new[]
|
Point[] points = new Point[]
|
||||||
{
|
{
|
||||||
Location
|
Location
|
||||||
};
|
};
|
||||||
|
|
|
@ -227,10 +227,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
//allow only horizontal changes
|
//allow only horizontal changes
|
||||||
if (_parent?.Image is { } image)
|
if (_parent?.Image is { } image)
|
||||||
{
|
{
|
||||||
_boundsAfterResize.X = 0;
|
_boundsAfterResize = new NativeRectFloat(0, _boundsBeforeResize.Top, image.Width, y - _boundsAfterResize.Top);
|
||||||
_boundsAfterResize.Y = _boundsBeforeResize.Top;
|
|
||||||
_boundsAfterResize.Width = image.Width;
|
|
||||||
_boundsAfterResize.Height = y - _boundsAfterResize.Top;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -240,23 +237,18 @@ namespace Greenshot.Editor.Drawing
|
||||||
//allow only vertical changes
|
//allow only vertical changes
|
||||||
if (_parent?.Image is { } image)
|
if (_parent?.Image is { } image)
|
||||||
{
|
{
|
||||||
_boundsAfterResize.X = _boundsBeforeResize.Left;
|
_boundsAfterResize = new NativeRectFloat(_boundsBeforeResize.Left, 0, x - _boundsAfterResize.Left, image.Height);
|
||||||
_boundsAfterResize.Y = 0;
|
|
||||||
_boundsAfterResize.Width = x - _boundsAfterResize.Left;
|
|
||||||
_boundsAfterResize.Height = image.Height;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// reset "workbench" rectangle to current bounds
|
// reset "workbench" rectangle to current bounds
|
||||||
_boundsAfterResize.X = _boundsBeforeResize.Left;
|
_boundsAfterResize = new NativeRectFloat(
|
||||||
_boundsAfterResize.Y = _boundsBeforeResize.Top;
|
_boundsBeforeResize.Left, _boundsBeforeResize.Top,
|
||||||
_boundsAfterResize.Width = x - _boundsAfterResize.Left;
|
x - _boundsAfterResize.Left, y - _boundsAfterResize.Top);
|
||||||
_boundsAfterResize.Height = y - _boundsAfterResize.Top;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
|
ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ using System.Drawing.Drawing2D;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -124,6 +125,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
cursor.DrawStretched(graphics, Bounds);
|
cursor.DrawStretched(graphics, Bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Size DefaultSize => cursor?.Size ?? new Size(16, 16);
|
public override NativeSize DefaultSize => cursor?.Size ?? new NativeSize(16, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -263,7 +263,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
// "workbench" rectangle - used for calculating bounds during resizing (to be applied to this DrawableContainer afterwards)
|
// "workbench" rectangle - used for calculating bounds during resizing (to be applied to this DrawableContainer afterwards)
|
||||||
protected RectangleF _boundsAfterResize = RectangleF.Empty;
|
protected NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty;
|
||||||
|
|
||||||
public NativeRect Bounds
|
public NativeRect Bounds
|
||||||
{
|
{
|
||||||
|
@ -277,7 +277,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ApplyBounds(RectangleF newBounds)
|
public virtual void ApplyBounds(NativeRectFloat newBounds)
|
||||||
{
|
{
|
||||||
Left = Round(newBounds.Left);
|
Left = Round(newBounds.Left);
|
||||||
Top = Round(newBounds.Top);
|
Top = Round(newBounds.Top);
|
||||||
|
@ -528,10 +528,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|
||||||
// reset "workbench" rectangle to current bounds
|
// reset "workbench" rectangle to current bounds
|
||||||
_boundsAfterResize.X = _boundsBeforeResize.Left;
|
_boundsAfterResize = _boundsBeforeResize;
|
||||||
_boundsAfterResize.Y = _boundsBeforeResize.Top;
|
|
||||||
_boundsAfterResize.Width = x - _boundsAfterResize.Left;
|
|
||||||
_boundsAfterResize.Height = y - _boundsAfterResize.Top;
|
|
||||||
|
|
||||||
ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
|
ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
|
||||||
|
|
||||||
|
@ -675,7 +672,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public virtual bool HasDefaultSize => false;
|
public virtual bool HasDefaultSize => false;
|
||||||
|
|
||||||
public virtual Size DefaultSize => throw new NotSupportedException("Object doesn't have a default size");
|
public virtual NativeSize DefaultSize => throw new NotSupportedException("Object doesn't have a default size");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows to override the initializing of the fields, so we can actually have our own defaults
|
/// Allows to override the initializing of the fields, so we can actually have our own defaults
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <param name="lineColor"></param>
|
/// <param name="lineColor"></param>
|
||||||
/// <param name="fillColor"></param>
|
/// <param name="fillColor"></param>
|
||||||
/// <param name="shadow"></param>
|
/// <param name="shadow"></param>
|
||||||
public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow)
|
public static void DrawEllipse(NativeRect rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow)
|
||||||
{
|
{
|
||||||
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||||
// draw shadow before anything else
|
// draw shadow before anything else
|
||||||
|
@ -152,7 +152,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
return EllipseClickableAt(rect, lineThickness, fillColor, x, y);
|
return EllipseClickableAt(rect, lineThickness, fillColor, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool EllipseClickableAt(Rectangle rect, int lineThickness, Color fillColor, int x, int y)
|
public static bool EllipseClickableAt(NativeRect rect, int lineThickness, Color fillColor, int x, int y)
|
||||||
{
|
{
|
||||||
// If we clicked inside the rectangle and it's visible we are clickable at.
|
// If we clicked inside the rectangle and it's visible we are clickable at.
|
||||||
if (!Color.Transparent.Equals(fillColor))
|
if (!Color.Transparent.Equals(fillColor))
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Drawing.Fields;
|
using Greenshot.Editor.Drawing.Fields;
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode);
|
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode);
|
||||||
|
|
||||||
protected void OnPropertyChanged(string propertyName)
|
protected void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Gdi32;
|
using Dapplo.Windows.Gdi32;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
|
@ -50,10 +51,10 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
|
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
|
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
|
||||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0)
|
if (applyRect.Width == 0 || applyRect.Height == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,6 +23,7 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Drawing.Fields;
|
using Greenshot.Editor.Drawing.Fields;
|
||||||
|
@ -42,11 +43,11 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="applyBitmap"></param>
|
/// <param name="applyBitmap"></param>
|
||||||
/// <param name="rect"></param>
|
/// <param name="rect">NativeRect</param>
|
||||||
/// <param name="renderMode"></param>
|
/// <param name="renderMode"></param>
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0)
|
if (applyRect.Width == 0 || applyRect.Height == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,13 +23,14 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Filters
|
namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of GrayscaleFilter.
|
/// GrayscaleFilter makes the image grey
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class GrayscaleFilter : AbstractFilter
|
public class GrayscaleFilter : AbstractFilter
|
||||||
|
@ -38,9 +39,9 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0)
|
if (applyRect.Width == 0 || applyRect.Height == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,12 +22,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Drawing.Fields;
|
using Greenshot.Editor.Drawing.Fields;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Filters
|
namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This filter highlights an area
|
||||||
|
/// </summary>
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class HighlightFilter : AbstractFilter
|
public class HighlightFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
|
@ -41,11 +45,11 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="applyBitmap"></param>
|
/// <param name="applyBitmap"></param>
|
||||||
/// <param name="rect"></param>
|
/// <param name="rect">NativeRect</param>
|
||||||
/// <param name="renderMode"></param>
|
/// <param name="renderMode"></param>
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0)
|
if (applyRect.Width == 0 || applyRect.Height == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Filters
|
namespace Greenshot.Editor.Drawing.Filters
|
||||||
|
@ -28,7 +29,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
public interface IFilter : INotifyPropertyChanged, IFieldHolder
|
public interface IFilter : INotifyPropertyChanged, IFieldHolder
|
||||||
{
|
{
|
||||||
DrawableContainer Parent { get; set; }
|
DrawableContainer Parent { get; set; }
|
||||||
void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode);
|
void Apply(Graphics graphics, Bitmap bmp, NativeRect rect, RenderMode renderMode);
|
||||||
DrawableContainer GetParent();
|
DrawableContainer GetParent();
|
||||||
bool Invert { get; set; }
|
bool Invert { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Drawing.Fields;
|
using Greenshot.Editor.Drawing.Fields;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Filters
|
namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Magnify an area
|
||||||
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class MagnifierFilter : AbstractFilter
|
public class MagnifierFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
|
@ -36,9 +40,9 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0)
|
if (applyRect.Width == 0 || applyRect.Height == 0)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +66,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
int halfHeight = rect.Height / 2;
|
int halfHeight = rect.Height / 2;
|
||||||
int newWidth = rect.Width / magnificationFactor;
|
int newWidth = rect.Width / magnificationFactor;
|
||||||
int newHeight = rect.Height / magnificationFactor;
|
int newHeight = rect.Height / magnificationFactor;
|
||||||
Rectangle source = new Rectangle(rect.X + halfWidth - newWidth / 2, rect.Y + halfHeight - newHeight / 2, newWidth, newHeight);
|
var source = new NativeRect(rect.X + halfWidth - newWidth / 2, rect.Y + halfHeight - newHeight / 2, newWidth, newHeight);
|
||||||
graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel);
|
graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel);
|
||||||
graphics.Restore(state);
|
graphics.Restore(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Drawing.Fields;
|
using Greenshot.Editor.Drawing.Fields;
|
||||||
|
@ -29,6 +30,9 @@ using Greenshot.Editor.Helpers;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Drawing.Filters
|
namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Pixelate an area
|
||||||
|
/// </summary>
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class PixelizationFilter : AbstractFilter
|
public class PixelizationFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
|
@ -37,7 +41,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
||||||
{
|
{
|
||||||
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
||||||
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
|
@ -44,8 +44,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
};
|
};
|
||||||
|
|
||||||
[NonSerialized] private GraphicsPath freehandPath = new GraphicsPath();
|
[NonSerialized] private GraphicsPath freehandPath = new GraphicsPath();
|
||||||
private Rectangle myBounds = Rectangle.Empty;
|
private NativeRect myBounds = NativeRect.Empty;
|
||||||
private Point lastMouse = Point.Empty;
|
private NativePoint lastMouse = NativePoint.Empty;
|
||||||
private readonly List<Point> capturePoints = new List<Point>();
|
private readonly List<Point> capturePoints = new List<Point>();
|
||||||
private bool isRecalculated;
|
private bool isRecalculated;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -133,6 +134,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public override bool HasDefaultSize => true;
|
public override bool HasDefaultSize => true;
|
||||||
|
|
||||||
public override Size DefaultSize => icon?.Size ?? new Size(16, 16);
|
public override NativeSize DefaultSize => icon?.Size ?? new NativeSize(16, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Effects;
|
using Greenshot.Base.Effects;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
|
@ -264,6 +265,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public override bool HasDefaultSize => true;
|
public override bool HasDefaultSize => true;
|
||||||
|
|
||||||
public override Size DefaultSize => _image?.Size ?? new Size(32, 32);
|
public override NativeSize DefaultSize => _image?.Size ?? new NativeSize(32, 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
|
|
||||||
|
@ -39,14 +40,14 @@ namespace Greenshot.Editor.Drawing
|
||||||
public MetafileContainer(Metafile metafile, ISurface parent) : base(parent)
|
public MetafileContainer(Metafile metafile, ISurface parent) : base(parent)
|
||||||
{
|
{
|
||||||
_metafile = metafile;
|
_metafile = metafile;
|
||||||
Size = new Size(metafile.Width/4, metafile.Height/4);
|
Size = new NativeSize(metafile.Width/4, metafile.Height/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Image ComputeBitmap()
|
protected override Image ComputeBitmap()
|
||||||
{
|
{
|
||||||
var image = ImageHelper.CreateEmpty(Width, Height, PixelFormat.Format32bppArgb, Color.Transparent);
|
var image = ImageHelper.CreateEmpty(Width, Height, PixelFormat.Format32bppArgb, Color.Transparent);
|
||||||
|
|
||||||
var dstRect = new Rectangle(0, 0, Width, Height);
|
var dstRect = new NativeRect(0, 0, Width, Height);
|
||||||
using (Graphics graphics = Graphics.FromImage(image))
|
using (Graphics graphics = Graphics.FromImage(image))
|
||||||
{
|
{
|
||||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
@ -75,6 +76,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public override bool HasDefaultSize => true;
|
public override bool HasDefaultSize => true;
|
||||||
|
|
||||||
public override Size DefaultSize => new Size(_metafile.Width, _metafile.Height);
|
public override NativeSize DefaultSize => new NativeSize(_metafile.Width, _metafile.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -80,14 +80,14 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method can also be used from other containers, if the right values are passed!
|
/// This method can also be used from other containers, if the right values are passed!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rect"></param>
|
/// <param name="rect">NativeRect</param>
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="rm"></param>
|
/// <param name="rm"></param>
|
||||||
/// <param name="lineThickness"></param>
|
/// <param name="lineThickness"></param>
|
||||||
/// <param name="lineColor"></param>
|
/// <param name="lineColor"></param>
|
||||||
/// <param name="fillColor"></param>
|
/// <param name="fillColor"></param>
|
||||||
/// <param name="shadow"></param>
|
/// <param name="shadow"></param>
|
||||||
public static void DrawRectangle(Rectangle rect, Graphics graphics, RenderMode rm, int lineThickness, Color lineColor, Color fillColor, bool shadow)
|
public static void DrawRectangle(NativeRect rect, Graphics graphics, RenderMode rm, int lineThickness, Color lineColor, Color fillColor, bool shadow)
|
||||||
{
|
{
|
||||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
@ -143,7 +143,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
return RectangleClickableAt(rect, lineThickness, fillColor, x, y);
|
return RectangleClickableAt(rect, lineThickness, fillColor, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool RectangleClickableAt(Rectangle rect, int lineThickness, Color fillColor, int x, int y)
|
public static bool RectangleClickableAt(NativeRect rect, int lineThickness, Color fillColor, int x, int y)
|
||||||
{
|
{
|
||||||
// If we clicked inside the rectangle and it's visible we are clickable at.
|
// If we clicked inside the rectangle and it's visible we are clickable at.
|
||||||
if (!Color.Transparent.Equals(fillColor))
|
if (!Color.Transparent.Equals(fillColor))
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SpeechbubbleContainer : TextContainer
|
public class SpeechbubbleContainer : TextContainer
|
||||||
{
|
{
|
||||||
private Point _initialGripperPoint;
|
private NativePoint _initialGripperPoint;
|
||||||
|
|
||||||
// Only used for serializing the TargetGripper location
|
// Only used for serializing the TargetGripper location
|
||||||
private Point _storedTargetGripperLocation;
|
private Point _storedTargetGripperLocation;
|
||||||
|
@ -120,8 +120,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
int xOffset = leftAligned ? -20 : 20;
|
int xOffset = leftAligned ? -20 : 20;
|
||||||
int yOffset = topAligned ? -20 : 20;
|
int yOffset = topAligned ? -20 : 20;
|
||||||
|
|
||||||
Point newGripperLocation = _initialGripperPoint;
|
NativePoint newGripperLocation = _initialGripperPoint.Offset(xOffset, yOffset);
|
||||||
newGripperLocation.Offset(xOffset, yOffset);
|
|
||||||
|
|
||||||
if (TargetAdorner.Location != newGripperLocation)
|
if (TargetAdorner.Location != newGripperLocation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
newParentSurface.AddStepLabel(this);
|
newParentSurface.AddStepLabel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Size DefaultSize => new Size(30, 30);
|
public override NativeSize DefaultSize => new NativeSize(30, 30);
|
||||||
|
|
||||||
public override bool InitContent()
|
public override bool InitContent()
|
||||||
{
|
{
|
||||||
|
|
|
@ -530,8 +530,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
// check if cursor is captured, and visible
|
// check if cursor is captured, and visible
|
||||||
if (capture.Cursor != null && capture.CursorVisible)
|
if (capture.Cursor != null && capture.CursorVisible)
|
||||||
{
|
{
|
||||||
Rectangle cursorRect = new Rectangle(capture.CursorLocation, capture.Cursor.Size);
|
var cursorRect = new NativeRect(capture.CursorLocation, capture.Cursor.Size);
|
||||||
Rectangle captureRect = new Rectangle(Point.Empty, capture.Image.Size);
|
var captureRect = new NativeRect(NativePoint.Empty, capture.Image.Size);
|
||||||
// check if cursor is on the capture, otherwise we leave it out.
|
// check if cursor is on the capture, otherwise we leave it out.
|
||||||
if (cursorRect.IntersectsWith(captureRect))
|
if (cursorRect.IntersectsWith(captureRect))
|
||||||
{
|
{
|
||||||
|
@ -940,7 +940,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void OnDragDrop(object sender, DragEventArgs e)
|
private void OnDragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
Point mouse = PointToClient(new Point(e.X, e.Y));
|
NativePoint mouse = PointToClient(new NativePoint(e.X, e.Y));
|
||||||
if (e.Data.GetDataPresent("Text"))
|
if (e.Data.GetDataPresent("Text"))
|
||||||
{
|
{
|
||||||
string possibleUrl = ClipboardHelper.GetText(e.Data);
|
string possibleUrl = ClipboardHelper.GetText(e.Data);
|
||||||
|
@ -965,7 +965,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
drawableContainer.Top = mouse.Y;
|
drawableContainer.Top = mouse.Y;
|
||||||
FitContainer(drawableContainer);
|
FitContainer(drawableContainer);
|
||||||
AddElement(drawableContainer);
|
AddElement(drawableContainer);
|
||||||
mouse.Offset(10, 10);
|
mouse = mouse.Offset(10, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,11 +974,11 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Auto crop the image
|
/// Auto crop the image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropArea">Rectangle with optional area to find a crop region</param>
|
/// <param name="cropArea">NativeRect with optional area to find a crop region</param>
|
||||||
/// <returns>true if cropped</returns>
|
/// <returns>true if cropped</returns>
|
||||||
public bool AutoCrop(Rectangle? cropArea = null)
|
public bool AutoCrop(NativeRect? cropArea = null)
|
||||||
{
|
{
|
||||||
Rectangle cropRectangle;
|
NativeRect cropRectangle;
|
||||||
using (Image tmpImage = GetImageForExport())
|
using (Image tmpImage = GetImageForExport())
|
||||||
{
|
{
|
||||||
cropRectangle = ImageHelper.FindAutoCropRectangle(tmpImage, conf.AutoCropDifference, cropArea);
|
cropRectangle = ImageHelper.FindAutoCropRectangle(tmpImage, conf.AutoCropDifference, cropArea);
|
||||||
|
@ -1031,7 +1031,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Rectangle imageRectangle = new Rectangle(Point.Empty, Image.Size);
|
var imageRectangle = new NativeRect(NativePoint.Empty, Image.Size);
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
Image newImage = ImageHelper.ApplyEffect(Image, effect, matrix);
|
Image newImage = ImageHelper.ApplyEffect(Image, effect, matrix);
|
||||||
if (newImage != null)
|
if (newImage != null)
|
||||||
|
@ -1042,7 +1042,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
MakeUndoable(new SurfaceBackgroundChangeMemento(this, matrix), false);
|
MakeUndoable(new SurfaceBackgroundChangeMemento(this, matrix), false);
|
||||||
SetImage(newImage, false);
|
SetImage(newImage, false);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new Rectangle(Point.Empty, newImage.Size)))
|
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new NativeRect(NativePoint.Empty, newImage.Size)))
|
||||||
{
|
{
|
||||||
_surfaceSizeChanged(this, null);
|
_surfaceSizeChanged(this, null);
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1066,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <param name="cropRectangle">Rectangle adapted to the dimensions of the image</param>
|
/// <param name="cropRectangle">Rectangle adapted to the dimensions of the image</param>
|
||||||
/// <param name="cropMode">CropModes</param>
|
/// <param name="cropMode">CropModes</param>
|
||||||
/// <returns>true if this is possible</returns>
|
/// <returns>true if this is possible</returns>
|
||||||
public bool IsCropPossible(ref Rectangle cropRectangle, CropContainer.CropModes cropMode)
|
public bool IsCropPossible(ref NativeRect cropRectangle, CropContainer.CropModes cropMode)
|
||||||
{
|
{
|
||||||
cropRectangle = new NativeRect(cropRectangle.Left, cropRectangle.Top, cropRectangle.Width, cropRectangle.Height).Normalize();
|
cropRectangle = new NativeRect(cropRectangle.Left, cropRectangle.Top, cropRectangle.Width, cropRectangle.Height).Normalize();
|
||||||
//Fitting the rectangle to the dimensions of the image
|
//Fitting the rectangle to the dimensions of the image
|
||||||
|
@ -1199,13 +1199,13 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Crop the surface
|
/// Crop the surface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropRectangle">rectangle that remains</param>
|
/// <param name="cropRectangle">NativeRect that remains</param>
|
||||||
/// <returns>bool</returns>
|
/// <returns>bool</returns>
|
||||||
public bool ApplyCrop(Rectangle cropRectangle)
|
public bool ApplyCrop(NativeRect cropRectangle)
|
||||||
{
|
{
|
||||||
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Default)) return false;
|
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Default)) return false;
|
||||||
|
|
||||||
Rectangle imageRectangle = new Rectangle(Point.Empty, Image.Size);
|
var imageRectangle = new NativeRect(NativePoint.Empty, Image.Size);
|
||||||
Bitmap tmpImage;
|
Bitmap tmpImage;
|
||||||
// Make sure we have information, this this fails
|
// Make sure we have information, this this fails
|
||||||
try
|
try
|
||||||
|
@ -1229,7 +1229,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
// Do not dispose otherwise we can't undo the image!
|
// Do not dispose otherwise we can't undo the image!
|
||||||
SetImage(tmpImage, false);
|
SetImage(tmpImage, false);
|
||||||
_elements.Transform(matrix);
|
_elements.Transform(matrix);
|
||||||
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new Rectangle(Point.Empty, tmpImage.Size)))
|
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new NativeRect(NativePoint.Empty, tmpImage.Size)))
|
||||||
{
|
{
|
||||||
_surfaceSizeChanged(this, null);
|
_surfaceSizeChanged(this, null);
|
||||||
}
|
}
|
||||||
|
@ -1242,15 +1242,15 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// Crop out the surface
|
/// Crop out the surface
|
||||||
/// Splits the image in 3 parts(top, middle, bottom). Crop out the middle and joins top and bottom.
|
/// Splits the image in 3 parts(top, middle, bottom). Crop out the middle and joins top and bottom.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropRectangle">rectangle of the middle part</param>
|
/// <param name="cropRectangle">NativeRect of the middle part</param>
|
||||||
/// <returns>bool</returns>
|
/// <returns>bool</returns>
|
||||||
private bool ApplyHorizontalCrop(Rectangle cropRectangle)
|
private bool ApplyHorizontalCrop(NativeRect cropRectangle)
|
||||||
{
|
{
|
||||||
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Horizontal)) return false;
|
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Horizontal)) return false;
|
||||||
|
|
||||||
var imageRectangle = new Rectangle(Point.Empty, Image.Size);
|
var imageRectangle = new NativeRect(NativePoint.Empty, Image.Size);
|
||||||
var topRectangle = new Rectangle(0, 0, Image.Size.Width, cropRectangle.Top);
|
var topRectangle = new NativeRect(0, 0, Image.Size.Width, cropRectangle.Top);
|
||||||
var bottomRectangle = new Rectangle(0, cropRectangle.Top + cropRectangle.Height, Image.Size.Width, Image.Size.Height - cropRectangle.Top - cropRectangle.Height);
|
var bottomRectangle = new NativeRect(0, cropRectangle.Top + cropRectangle.Height, Image.Size.Width, Image.Size.Height - cropRectangle.Top - cropRectangle.Height);
|
||||||
|
|
||||||
Bitmap newImage;
|
Bitmap newImage;
|
||||||
try
|
try
|
||||||
|
@ -1262,12 +1262,12 @@ namespace Greenshot.Editor.Drawing
|
||||||
var insertPositionTop = 0;
|
var insertPositionTop = 0;
|
||||||
if (topRectangle.Height > 0)
|
if (topRectangle.Height > 0)
|
||||||
{
|
{
|
||||||
graphics.DrawImage(Image, new Rectangle(0, insertPositionTop, topRectangle.Width, topRectangle.Height), topRectangle, GraphicsUnit.Pixel);
|
graphics.DrawImage(Image, new NativeRect(0, insertPositionTop, topRectangle.Width, topRectangle.Height), topRectangle, GraphicsUnit.Pixel);
|
||||||
insertPositionTop += topRectangle.Height;
|
insertPositionTop += topRectangle.Height;
|
||||||
}
|
}
|
||||||
if (bottomRectangle.Height > 0)
|
if (bottomRectangle.Height > 0)
|
||||||
{
|
{
|
||||||
graphics.DrawImage(Image, new Rectangle(0, insertPositionTop, bottomRectangle.Width, bottomRectangle.Height), bottomRectangle, GraphicsUnit.Pixel);
|
graphics.DrawImage(Image, new NativeRect(0, insertPositionTop, bottomRectangle.Width, bottomRectangle.Height), bottomRectangle, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1287,7 +1287,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
SetImage(newImage, false);
|
SetImage(newImage, false);
|
||||||
|
|
||||||
_elements.Transform(matrix);
|
_elements.Transform(matrix);
|
||||||
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new Rectangle(Point.Empty, newImage.Size)))
|
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new NativeRect(NativePoint.Empty, newImage.Size)))
|
||||||
{
|
{
|
||||||
_surfaceSizeChanged(this, null);
|
_surfaceSizeChanged(this, null);
|
||||||
}
|
}
|
||||||
|
@ -1300,15 +1300,15 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// Crop out the surface
|
/// Crop out the surface
|
||||||
/// Splits the image in 3 parts(left, middle, right). Crop out the middle and joins top and bottom.
|
/// Splits the image in 3 parts(left, middle, right). Crop out the middle and joins top and bottom.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropRectangle">rectangle of the middle part</param>
|
/// <param name="cropRectangle">NativeRect of the middle part</param>
|
||||||
/// <returns>bool</returns>
|
/// <returns>bool</returns>
|
||||||
private bool ApplyVerticalCrop(Rectangle cropRectangle)
|
private bool ApplyVerticalCrop(NativeRect cropRectangle)
|
||||||
{
|
{
|
||||||
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Vertical)) return false;
|
if (!IsCropPossible(ref cropRectangle, CropContainer.CropModes.Vertical)) return false;
|
||||||
|
|
||||||
var imageRectangle = new Rectangle(Point.Empty, Image.Size);
|
var imageRectangle = new NativeRect(NativePoint.Empty, Image.Size);
|
||||||
var leftRectangle = new Rectangle(0, 0, cropRectangle.Left, Image.Size.Height);
|
var leftRectangle = new NativeRect(0, 0, cropRectangle.Left, Image.Size.Height);
|
||||||
var rightRectangle = new Rectangle(cropRectangle.Left + cropRectangle.Width, 0, Image.Size.Width - cropRectangle.Width - cropRectangle.Left, Image.Size.Height);
|
var rightRectangle = new NativeRect(cropRectangle.Left + cropRectangle.Width, 0, Image.Size.Width - cropRectangle.Width - cropRectangle.Left, Image.Size.Height);
|
||||||
Bitmap newImage;
|
Bitmap newImage;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1319,13 +1319,13 @@ namespace Greenshot.Editor.Drawing
|
||||||
var insertPositionLeft = 0;
|
var insertPositionLeft = 0;
|
||||||
if (leftRectangle.Width > 0)
|
if (leftRectangle.Width > 0)
|
||||||
{
|
{
|
||||||
graphics.DrawImage(Image, new Rectangle(insertPositionLeft, 0, leftRectangle.Width, leftRectangle.Height), leftRectangle , GraphicsUnit.Pixel);
|
graphics.DrawImage(Image, new NativeRect(insertPositionLeft, 0, leftRectangle.Width, leftRectangle.Height), leftRectangle , GraphicsUnit.Pixel);
|
||||||
insertPositionLeft += leftRectangle.Width;
|
insertPositionLeft += leftRectangle.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rightRectangle.Width > 0)
|
if (rightRectangle.Width > 0)
|
||||||
{
|
{
|
||||||
graphics.DrawImage(Image, new Rectangle(insertPositionLeft, 0, rightRectangle.Width, rightRectangle.Height), rightRectangle, GraphicsUnit.Pixel);
|
graphics.DrawImage(Image, new NativeRect(insertPositionLeft, 0, rightRectangle.Width, rightRectangle.Height), rightRectangle, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1345,7 +1345,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
SetImage(newImage, false);
|
SetImage(newImage, false);
|
||||||
|
|
||||||
_elements.Transform(matrix);
|
_elements.Transform(matrix);
|
||||||
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new Rectangle(Point.Empty, newImage.Size)))
|
if (_surfaceSizeChanged != null && !imageRectangle.Equals(new NativeRect(NativePoint.Empty, newImage.Size)))
|
||||||
{
|
{
|
||||||
_surfaceSizeChanged(this, null);
|
_surfaceSizeChanged(this, null);
|
||||||
}
|
}
|
||||||
|
@ -1735,8 +1735,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
private void SurfacePaint(object sender, PaintEventArgs paintEventArgs)
|
private void SurfacePaint(object sender, PaintEventArgs paintEventArgs)
|
||||||
{
|
{
|
||||||
Graphics targetGraphics = paintEventArgs.Graphics;
|
Graphics targetGraphics = paintEventArgs.Graphics;
|
||||||
Rectangle targetClipRectangle = paintEventArgs.ClipRectangle;
|
NativeRect targetClipRectangle = paintEventArgs.ClipRectangle;
|
||||||
if (Rectangle.Empty.Equals(targetClipRectangle))
|
if (targetClipRectangle.IsEmpty)
|
||||||
{
|
{
|
||||||
LOG.Debug("Empty cliprectangle??");
|
LOG.Debug("Empty cliprectangle??");
|
||||||
return;
|
return;
|
||||||
|
@ -1750,18 +1750,16 @@ namespace Greenshot.Editor.Drawing
|
||||||
int verticalCorrection = targetClipRectangle.Top % (int) _zoomFactor.Numerator;
|
int verticalCorrection = targetClipRectangle.Top % (int) _zoomFactor.Numerator;
|
||||||
if (horizontalCorrection != 0)
|
if (horizontalCorrection != 0)
|
||||||
{
|
{
|
||||||
targetClipRectangle.X -= horizontalCorrection;
|
targetClipRectangle = targetClipRectangle.ChangeX(-horizontalCorrection).ChangeWidth(horizontalCorrection);
|
||||||
targetClipRectangle.Width += horizontalCorrection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verticalCorrection != 0)
|
if (verticalCorrection != 0)
|
||||||
{
|
{
|
||||||
targetClipRectangle.Y -= verticalCorrection;
|
targetClipRectangle = targetClipRectangle.ChangeY(-verticalCorrection).ChangeHeight(verticalCorrection);
|
||||||
targetClipRectangle.Height += verticalCorrection;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle imageClipRectangle = ZoomClipRectangle(targetClipRectangle, _zoomFactor.Inverse(), 2);
|
NativeRect imageClipRectangle = ZoomClipRectangle(targetClipRectangle, _zoomFactor.Inverse(), 2);
|
||||||
|
|
||||||
if (_elements.HasIntersectingFilters(imageClipRectangle) || _zoomFactor > Fraction.Identity)
|
if (_elements.HasIntersectingFilters(imageClipRectangle) || _zoomFactor > Fraction.Identity)
|
||||||
{
|
{
|
||||||
|
@ -1842,7 +1840,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSmoothImage(Graphics targetGraphics, Image image, Rectangle imageClipRectangle)
|
private void DrawSmoothImage(Graphics targetGraphics, Image image, NativeRect imageClipRectangle)
|
||||||
{
|
{
|
||||||
var state = targetGraphics.Save();
|
var state = targetGraphics.Save();
|
||||||
targetGraphics.SmoothingMode = SmoothingMode.HighQuality;
|
targetGraphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
@ -1855,7 +1853,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
targetGraphics.Restore(state);
|
targetGraphics.Restore(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSharpImage(Graphics targetGraphics, Image image, Rectangle imageClipRectangle)
|
private void DrawSharpImage(Graphics targetGraphics, Image image, NativeRect imageClipRectangle)
|
||||||
{
|
{
|
||||||
var state = targetGraphics.Save();
|
var state = targetGraphics.Save();
|
||||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||||
|
@ -1868,7 +1866,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
targetGraphics.Restore(state);
|
targetGraphics.Restore(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawBackground(Graphics targetGraphics, Rectangle clipRectangle)
|
private void DrawBackground(Graphics targetGraphics, NativeRect clipRectangle)
|
||||||
{
|
{
|
||||||
// check if we need to draw the checkerboard
|
// check if we need to draw the checkerboard
|
||||||
if (Image.IsAlphaPixelFormat(Image.PixelFormat) && _transparencyBackgroundBrush != null)
|
if (Image.IsAlphaPixelFormat(Image.PixelFormat) && _transparencyBackgroundBrush != null)
|
||||||
|
@ -2199,32 +2197,31 @@ namespace Greenshot.Editor.Drawing
|
||||||
dcs.Parent = this;
|
dcs.Parent = this;
|
||||||
var moveOffset = isSameSurface ? new Point(10, 10) : Point.Empty;
|
var moveOffset = isSameSurface ? new Point(10, 10) : Point.Empty;
|
||||||
// Here a fix for bug #1475, first calculate the bounds of the complete IDrawableContainerList
|
// Here a fix for bug #1475, first calculate the bounds of the complete IDrawableContainerList
|
||||||
Rectangle drawableContainerListBounds = Rectangle.Empty;
|
NativeRect drawableContainerListBounds = NativeRect.Empty;
|
||||||
foreach (var element in dcs)
|
foreach (var element in dcs)
|
||||||
{
|
{
|
||||||
drawableContainerListBounds = drawableContainerListBounds == Rectangle.Empty
|
drawableContainerListBounds = drawableContainerListBounds == NativeRect.Empty
|
||||||
? element.DrawingBounds
|
? element.DrawingBounds
|
||||||
: Rectangle.Union(drawableContainerListBounds, element.DrawingBounds);
|
: drawableContainerListBounds.Union(element.DrawingBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And find a location inside the target surface to paste to
|
// And find a location inside the target surface to paste to
|
||||||
bool containersCanFit = drawableContainerListBounds.Width < Bounds.Width && drawableContainerListBounds.Height < Bounds.Height;
|
bool containersCanFit = drawableContainerListBounds.Width < Bounds.Width && drawableContainerListBounds.Height < Bounds.Height;
|
||||||
if (!containersCanFit)
|
if (!containersCanFit)
|
||||||
{
|
{
|
||||||
Point containersLocation = drawableContainerListBounds.Location;
|
NativePoint containersLocation = drawableContainerListBounds.Location;
|
||||||
containersLocation.Offset(moveOffset);
|
containersLocation.Offset(moveOffset);
|
||||||
if (!Bounds.Contains(containersLocation))
|
if (!Bounds.Contains(containersLocation))
|
||||||
{
|
{
|
||||||
// Easy fix for same surface
|
// Easy fix for same surface
|
||||||
moveOffset = isSameSurface
|
moveOffset = isSameSurface
|
||||||
? new Point(-10, -10)
|
? new NativePoint(-10, -10)
|
||||||
: new Point(-drawableContainerListBounds.Location.X + 10, -drawableContainerListBounds.Location.Y + 10);
|
: new NativePoint(-drawableContainerListBounds.Location.X + 10, -drawableContainerListBounds.Location.Y + 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Rectangle moveContainerListBounds = drawableContainerListBounds;
|
NativeRect moveContainerListBounds = drawableContainerListBounds.Offset(moveOffset);
|
||||||
moveContainerListBounds.Offset(moveOffset);
|
|
||||||
// check if the element is inside
|
// check if the element is inside
|
||||||
if (!Bounds.Contains(moveContainerListBounds))
|
if (!Bounds.Contains(moveContainerListBounds))
|
||||||
{
|
{
|
||||||
|
@ -2272,7 +2269,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
}
|
}
|
||||||
else if (ClipboardHelper.ContainsImage(clipboard))
|
else if (ClipboardHelper.ContainsImage(clipboard))
|
||||||
{
|
{
|
||||||
Point pasteLocation = GetPasteLocation(0.1f, 0.1f);
|
NativePoint pasteLocation = GetPasteLocation(0.1f, 0.1f);
|
||||||
|
|
||||||
foreach (var drawableContainer in ClipboardHelper.GetDrawables(clipboard))
|
foreach (var drawableContainer in ClipboardHelper.GetDrawables(clipboard))
|
||||||
{
|
{
|
||||||
|
@ -2282,13 +2279,12 @@ namespace Greenshot.Editor.Drawing
|
||||||
drawableContainer.Top = pasteLocation.Y;
|
drawableContainer.Top = pasteLocation.Y;
|
||||||
AddElement(drawableContainer);
|
AddElement(drawableContainer);
|
||||||
SelectElement(drawableContainer);
|
SelectElement(drawableContainer);
|
||||||
pasteLocation.X += 10;
|
pasteLocation = pasteLocation.Offset(10, 10);
|
||||||
pasteLocation.Y += 10;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ClipboardHelper.ContainsText(clipboard))
|
else if (ClipboardHelper.ContainsText(clipboard))
|
||||||
{
|
{
|
||||||
Point pasteLocation = GetPasteLocation(0.4f, 0.4f);
|
NativePoint pasteLocation = GetPasteLocation(0.4f, 0.4f);
|
||||||
|
|
||||||
string text = ClipboardHelper.GetText(clipboard);
|
string text = ClipboardHelper.GetText(clipboard);
|
||||||
if (text != null)
|
if (text != null)
|
||||||
|
@ -2308,13 +2304,13 @@ namespace Greenshot.Editor.Drawing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="horizontalRatio">0.0f for the left edge of visible area, 1.0f for the right edge of visible area.</param>
|
/// <param name="horizontalRatio">0.0f for the left edge of visible area, 1.0f for the right edge of visible area.</param>
|
||||||
/// <param name="verticalRatio">0.0f for the top edge of visible area, 1.0f for the bottom edge of visible area.</param>
|
/// <param name="verticalRatio">0.0f for the top edge of visible area, 1.0f for the bottom edge of visible area.</param>
|
||||||
private Point GetPasteLocation(float horizontalRatio = 0.5f, float verticalRatio = 0.5f)
|
private NativePoint GetPasteLocation(float horizontalRatio = 0.5f, float verticalRatio = 0.5f)
|
||||||
{
|
{
|
||||||
var point = PointToClient(MousePosition);
|
var point = PointToClient(MousePosition);
|
||||||
var rc = GetVisibleRectangle();
|
var rc = GetVisibleRectangle();
|
||||||
if (!rc.Contains(point))
|
if (!rc.Contains(point))
|
||||||
{
|
{
|
||||||
point = new Point(
|
point = new NativePoint(
|
||||||
rc.Left + (int) (rc.Width * horizontalRatio),
|
rc.Left + (int) (rc.Width * horizontalRatio),
|
||||||
rc.Top + (int) (rc.Height * verticalRatio)
|
rc.Top + (int) (rc.Height * verticalRatio)
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Interfaces;
|
using Greenshot.Base.Interfaces;
|
||||||
using Svg;
|
using Svg;
|
||||||
|
@ -56,6 +57,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public override bool HasDefaultSize => true;
|
public override bool HasDefaultSize => true;
|
||||||
|
|
||||||
public override Size DefaultSize => new Size((int)_svgDocument.Width, (int)_svgDocument.Height);
|
public override NativeSize DefaultSize => new NativeSize((int)_svgDocument.Width, (int)_svgDocument.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -176,7 +176,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
UpdateTextBoxFont();
|
UpdateTextBoxFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyBounds(RectangleF newBounds)
|
public override void ApplyBounds(NativeRectFloat newBounds)
|
||||||
{
|
{
|
||||||
base.ApplyBounds(newBounds);
|
base.ApplyBounds(newBounds);
|
||||||
UpdateTextBoxPosition();
|
UpdateTextBoxPosition();
|
||||||
|
@ -509,8 +509,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
correction = -1;
|
correction = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle absRectangle = new NativeRect(Left, Top, Width, Height).Normalize();
|
var absRectangle = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||||
Rectangle displayRectangle = Parent.ToSurfaceCoordinates(absRectangle);
|
var displayRectangle = Parent.ToSurfaceCoordinates(absRectangle);
|
||||||
_textBox.Left = displayRectangle.X + lineWidth;
|
_textBox.Left = displayRectangle.X + lineWidth;
|
||||||
_textBox.Top = displayRectangle.Y + lineWidth;
|
_textBox.Top = displayRectangle.Y + lineWidth;
|
||||||
if (lineThickness <= 1)
|
if (lineThickness <= 1)
|
||||||
|
@ -602,7 +602,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||||
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
|
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||||
|
|
||||||
Rectangle rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
var rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||||
if (Selected && rm == RenderMode.EDIT)
|
if (Selected && rm == RenderMode.EDIT)
|
||||||
{
|
{
|
||||||
DrawSelectionBorder(graphics, rect);
|
DrawSelectionBorder(graphics, rect);
|
||||||
|
|
|
@ -25,6 +25,8 @@ using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
using Dapplo.Windows.Common.TypeConverters;
|
||||||
using Dapplo.Windows.Gdi32.Enums;
|
using Dapplo.Windows.Gdi32.Enums;
|
||||||
using Dapplo.Windows.Gdi32.Structs;
|
using Dapplo.Windows.Gdi32.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
|
@ -128,7 +130,7 @@ namespace Greenshot.Editor.FileFormatHandlers
|
||||||
{
|
{
|
||||||
if (sourceBitmap == null) throw new ArgumentNullException(nameof(sourceBitmap));
|
if (sourceBitmap == null) throw new ArgumentNullException(nameof(sourceBitmap));
|
||||||
|
|
||||||
var area = new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height);
|
var area = new NativeRect(0, 0, sourceBitmap.Width, sourceBitmap.Height);
|
||||||
|
|
||||||
// If the supplied format doesn't match 32bpp, we need to convert it first, and dispose the new bitmap afterwards
|
// If the supplied format doesn't match 32bpp, we need to convert it first, and dispose the new bitmap afterwards
|
||||||
bool needsDisposal = false;
|
bool needsDisposal = false;
|
||||||
|
|
|
@ -24,6 +24,8 @@ using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Forms
|
namespace Greenshot.Editor.Forms
|
||||||
{
|
{
|
||||||
|
@ -32,7 +34,7 @@ namespace Greenshot.Editor.Forms
|
||||||
public class ColorPickerToolStripButton : ToolStripButton
|
public class ColorPickerToolStripButton : ToolStripButton
|
||||||
{
|
{
|
||||||
private Color _color;
|
private Color _color;
|
||||||
public Point Offset = new Point(0, 0);
|
public NativePoint Offset = new NativePoint(0, 0);
|
||||||
public event ColorPickerEventHandler ColorPicked;
|
public event ColorPickerEventHandler ColorPicked;
|
||||||
private readonly ColorDialog _cd;
|
private readonly ColorDialog _cd;
|
||||||
|
|
||||||
|
@ -56,29 +58,24 @@ namespace Greenshot.Editor.Forms
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
if (_color != null)
|
if (_color == null) return;
|
||||||
|
// replace transparent color with selected color
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
ColorMap[] colorMap = new ColorMap[1];
|
||||||
|
colorMap[0] = new ColorMap
|
||||||
{
|
{
|
||||||
// replace transparent color with selected color
|
OldColor = Color.Magenta, //this.ImageTransparentColor;
|
||||||
Graphics g = e.Graphics;
|
NewColor = _color
|
||||||
//Graphics g = Graphics.FromImage(Image);
|
};
|
||||||
ColorMap[] colorMap = new ColorMap[1];
|
ImageAttributes attr = new ImageAttributes();
|
||||||
colorMap[0] = new ColorMap
|
attr.SetRemapTable(colorMap);
|
||||||
{
|
var rect = new NativeRect(0, 0, Image.Width, Image.Height);
|
||||||
OldColor = Color.Magenta, //this.ImageTransparentColor;
|
// todo find a way to retrieve transparency offset automatically
|
||||||
NewColor = _color
|
// for now, we use the public variable Offset to define this manually
|
||||||
};
|
rect = rect.Offset(Offset.X, Offset.Y);
|
||||||
ImageAttributes attr = new ImageAttributes();
|
//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
|
||||||
attr.SetRemapTable(colorMap);
|
g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
|
||||||
Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
|
//this.Image.In
|
||||||
// todo find a way to retrieve transparency offset automatically
|
|
||||||
// for now, we use the public variable Offset to define this manually
|
|
||||||
rect.Offset(Offset.X, Offset.Y);
|
|
||||||
//Image.
|
|
||||||
Debug.WriteLine("paint!" + Text + ": " + _color);
|
|
||||||
//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
|
|
||||||
g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
|
|
||||||
//this.Image.In
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolStripButton1Click(object sender, EventArgs e)
|
void ToolStripButton1Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -32,6 +32,7 @@ using Dapplo.Windows.Common.Extensions;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Dpi;
|
using Dapplo.Windows.Dpi;
|
||||||
using Dapplo.Windows.Kernel32;
|
using Dapplo.Windows.Kernel32;
|
||||||
|
using Dapplo.Windows.User32;
|
||||||
using Dapplo.Windows.User32.Structs;
|
using Dapplo.Windows.User32.Structs;
|
||||||
using Greenshot.Base;
|
using Greenshot.Base;
|
||||||
using Greenshot.Base.Controls;
|
using Greenshot.Base.Controls;
|
||||||
|
@ -53,7 +54,7 @@ using log4net;
|
||||||
namespace Greenshot.Editor.Forms
|
namespace Greenshot.Editor.Forms
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of ImageEditorForm.
|
/// The ImageEditorForm is the editor for Greenshot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ImageEditorForm : EditorForm, IImageEditor
|
public partial class ImageEditorForm : EditorForm, IImageEditor
|
||||||
{
|
{
|
||||||
|
@ -156,14 +157,12 @@ namespace Greenshot.Editor.Forms
|
||||||
Name = "add destinations"
|
Name = "add destinations"
|
||||||
};
|
};
|
||||||
thread.Start();
|
thread.Start();
|
||||||
|
|
||||||
DpiChangedHandler(96, DeviceDpi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make sure the editor is placed on the same location as the last editor was on close
|
// Make sure the editor is placed on the same location as the last editor was on close
|
||||||
// But only if this still exists, else it will be reset (BUG-1812)
|
// But only if this still exists, else it will be reset (BUG-1812)
|
||||||
WindowPlacement editorWindowPlacement = EditorConfiguration.GetEditorPlacement();
|
WindowPlacement editorWindowPlacement = EditorConfiguration.GetEditorPlacement();
|
||||||
Rectangle screenBounds = WindowCapture.GetScreenBounds();
|
NativeRect screenBounds = DisplayInfo.ScreenBounds;
|
||||||
if (!screenBounds.Contains(editorWindowPlacement.NormalPosition))
|
if (!screenBounds.Contains(editorWindowPlacement.NormalPosition))
|
||||||
{
|
{
|
||||||
EditorConfiguration.ResetEditorPlacement();
|
EditorConfiguration.ResetEditorPlacement();
|
||||||
|
@ -322,7 +321,7 @@ namespace Greenshot.Editor.Forms
|
||||||
if (cb.ComboBox == null) continue;
|
if (cb.ComboBox == null) continue;
|
||||||
|
|
||||||
// Calculate the rectangle
|
// Calculate the rectangle
|
||||||
Rectangle r = new Rectangle(cb.ComboBox.Location.X - 1, cb.ComboBox.Location.Y - 1, cb.ComboBox.Size.Width + 1, cb.ComboBox.Size.Height + 1);
|
var r = new NativeRect(cb.ComboBox.Location.X - 1, cb.ComboBox.Location.Y - 1, cb.ComboBox.Size.Width + 1, cb.ComboBox.Size.Height + 1);
|
||||||
|
|
||||||
// Draw the rectangle
|
// Draw the rectangle
|
||||||
e.Graphics.DrawRectangle(cbBorderPen, r);
|
e.Graphics.DrawRectangle(cbBorderPen, r);
|
||||||
|
@ -1700,7 +1699,7 @@ namespace Greenshot.Editor.Forms
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ShrinkCanvasToolStripMenuItemClick(object sender, EventArgs e)
|
private void ShrinkCanvasToolStripMenuItemClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Rectangle cropRectangle;
|
NativeRect cropRectangle;
|
||||||
using (Image tmpImage = GetImageForExport())
|
using (Image tmpImage = GetImageForExport())
|
||||||
{
|
{
|
||||||
cropRectangle = ImageHelper.FindAutoCropRectangle(tmpImage, coreConfiguration.AutoCropDifference);
|
cropRectangle = ImageHelper.FindAutoCropRectangle(tmpImage, coreConfiguration.AutoCropDifference);
|
||||||
|
|
|
@ -22,8 +22,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Gdi32;
|
using Dapplo.Windows.Gdi32;
|
||||||
using Dapplo.Windows.Gdi32.SafeHandles;
|
using Dapplo.Windows.Gdi32.SafeHandles;
|
||||||
|
using Dapplo.Windows.User32;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Forms
|
namespace Greenshot.Editor.Forms
|
||||||
{
|
{
|
||||||
|
@ -46,8 +49,8 @@ namespace Greenshot.Editor.Forms
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move the MovableShowColorForm to the specified location and display the color under the (current mouse) coordinates
|
/// Move the MovableShowColorForm to the specified location and display the color under the (current mouse) coordinates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="screenCoordinates">Coordinates</param>
|
/// <param name="screenCoordinates">NativePoint with Coordinates</param>
|
||||||
public void MoveTo(Point screenCoordinates)
|
public void MoveTo(NativePoint screenCoordinates)
|
||||||
{
|
{
|
||||||
Color c = GetPixelColor(screenCoordinates);
|
Color c = GetPixelColor(screenCoordinates);
|
||||||
preview.BackColor = c;
|
preview.BackColor = c;
|
||||||
|
@ -57,38 +60,36 @@ namespace Greenshot.Editor.Forms
|
||||||
green.Text = string.Empty + c.G;
|
green.Text = string.Empty + c.G;
|
||||||
alpha.Text = string.Empty + c.A;
|
alpha.Text = string.Empty + c.A;
|
||||||
|
|
||||||
Size cursorSize = Cursor.Current.Size;
|
NativeSize cursorSize = Cursor.Current.Size;
|
||||||
Point hotspot = Cursor.Current.HotSpot;
|
NativePoint hotspot = Cursor.Current.HotSpot;
|
||||||
|
|
||||||
Point zoomerLocation = new Point(screenCoordinates.X, screenCoordinates.Y);
|
var zoomerLocation = new NativePoint(screenCoordinates.X, screenCoordinates.Y)
|
||||||
zoomerLocation.X += cursorSize.Width + 5 - hotspot.X;
|
.Offset(cursorSize.Width + 5 - hotspot.X, cursorSize.Height + 5 - hotspot.Y);
|
||||||
zoomerLocation.Y += cursorSize.Height + 5 - hotspot.Y;
|
|
||||||
|
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
{
|
{
|
||||||
Rectangle screenRectangle = screen.Bounds;
|
NativeRect screenRectangle = displayInfo.Bounds;
|
||||||
if (screen.Bounds.Contains(screenCoordinates))
|
if (!displayInfo.Bounds.Contains(screenCoordinates)) continue;
|
||||||
|
|
||||||
|
if (zoomerLocation.X < screenRectangle.X)
|
||||||
{
|
{
|
||||||
if (zoomerLocation.X < screenRectangle.X)
|
zoomerLocation = zoomerLocation.ChangeX(screenRectangle.X);
|
||||||
{
|
|
||||||
zoomerLocation.X = screenRectangle.X;
|
|
||||||
}
|
|
||||||
else if (zoomerLocation.X + Width > screenRectangle.X + screenRectangle.Width)
|
|
||||||
{
|
|
||||||
zoomerLocation.X = screenCoordinates.X - Width - 5 - hotspot.X;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zoomerLocation.Y < screenRectangle.Y)
|
|
||||||
{
|
|
||||||
zoomerLocation.Y = screenRectangle.Y;
|
|
||||||
}
|
|
||||||
else if (zoomerLocation.Y + Height > screenRectangle.Y + screenRectangle.Height)
|
|
||||||
{
|
|
||||||
zoomerLocation.Y = screenCoordinates.Y - Height - 5 - hotspot.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (zoomerLocation.X + Width > screenRectangle.X + screenRectangle.Width)
|
||||||
|
{
|
||||||
|
zoomerLocation = zoomerLocation.ChangeX(screenCoordinates.X - Width - 5 - hotspot.X);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zoomerLocation.Y < screenRectangle.Y)
|
||||||
|
{
|
||||||
|
zoomerLocation = zoomerLocation.ChangeY(screenRectangle.Y);
|
||||||
|
}
|
||||||
|
else if (zoomerLocation.Y + Height > screenRectangle.Y + screenRectangle.Height)
|
||||||
|
{
|
||||||
|
zoomerLocation = zoomerLocation.ChangeY(screenCoordinates.Y - Height - 5 - hotspot.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location = zoomerLocation;
|
Location = zoomerLocation;
|
||||||
|
@ -102,10 +103,10 @@ namespace Greenshot.Editor.Forms
|
||||||
/// <returns>Color at the specified screenCoordinates</returns>
|
/// <returns>Color at the specified screenCoordinates</returns>
|
||||||
private static Color GetPixelColor(Point screenCoordinates)
|
private static Color GetPixelColor(Point screenCoordinates)
|
||||||
{
|
{
|
||||||
using SafeWindowDcHandle screenDC = SafeWindowDcHandle.FromDesktop();
|
using SafeWindowDcHandle safeWindowDcHandle = SafeWindowDcHandle.FromDesktop();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint pixel = Gdi32Api.GetPixel(screenDC, screenCoordinates.X, screenCoordinates.Y);
|
uint pixel = Gdi32Api.GetPixel(safeWindowDcHandle, screenCoordinates.X, screenCoordinates.Y);
|
||||||
Color color = Color.FromArgb(255, (int) (pixel & 0xFF), (int) (pixel & 0xFF00) >> 8, (int) (pixel & 0xFF0000) >> 16);
|
Color color = Color.FromArgb(255, (int) (pixel & 0xFF), (int) (pixel & 0xFF00) >> 8, (int) (pixel & 0xFF0000) >> 16);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Editor.Drawing;
|
using Greenshot.Editor.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Helpers
|
namespace Greenshot.Editor.Helpers
|
||||||
|
@ -118,7 +120,7 @@ namespace Greenshot.Editor.Helpers
|
||||||
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see constants in Gripper.cs, e.g. Gripper.POSITION_TOP_LEFT</param>
|
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see constants in Gripper.cs, e.g. Gripper.POSITION_TOP_LEFT</param>
|
||||||
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper</param>
|
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper</param>
|
||||||
/// <param name="options">ScaleOptions to use when scaling</param>
|
/// <param name="options">ScaleOptions to use when scaling</param>
|
||||||
public static void Scale(ref RectangleF originalRectangle, Positions resizeHandlePosition, PointF resizeHandleCoords, ScaleOptions? options)
|
public static void Scale(ref NativeRectFloat originalRectangle, Positions resizeHandlePosition, NativePointFloat resizeHandleCoords, ScaleOptions? options)
|
||||||
{
|
{
|
||||||
options ??= GetScaleOptions();
|
options ??= GetScaleOptions();
|
||||||
|
|
||||||
|
@ -135,8 +137,7 @@ namespace Greenshot.Editor.Helpers
|
||||||
// scale rectangle using handle coordinates
|
// scale rectangle using handle coordinates
|
||||||
Scale(ref originalRectangle, resizeHandlePosition, resizeHandleCoords);
|
Scale(ref originalRectangle, resizeHandlePosition, resizeHandleCoords);
|
||||||
// mirror handle coordinates via rectangle center coordinates
|
// mirror handle coordinates via rectangle center coordinates
|
||||||
resizeHandleCoords.X -= 2 * (resizeHandleCoords.X - rectCenterX);
|
resizeHandleCoords = resizeHandleCoords.Offset(-2 * (resizeHandleCoords.X - rectCenterX), -2 * (resizeHandleCoords.Y - rectCenterY));
|
||||||
resizeHandleCoords.Y -= 2 * (resizeHandleCoords.Y - rectCenterY);
|
|
||||||
// scale again with opposing handle and mirrored coordinates
|
// scale again with opposing handle and mirrored coordinates
|
||||||
resizeHandlePosition = (Positions) ((((int) resizeHandlePosition) + 4) % 8);
|
resizeHandlePosition = (Positions) ((((int) resizeHandlePosition) + 4) % 8);
|
||||||
Scale(ref originalRectangle, resizeHandlePosition, resizeHandleCoords);
|
Scale(ref originalRectangle, resizeHandlePosition, resizeHandleCoords);
|
||||||
|
@ -153,50 +154,72 @@ namespace Greenshot.Editor.Helpers
|
||||||
/// <param name="originalRectangle">bounds of the current rectangle, scaled values will be written to this reference</param>
|
/// <param name="originalRectangle">bounds of the current rectangle, scaled values will be written to this reference</param>
|
||||||
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see constants in Gripper.cs, e.g. Gripper.POSITION_TOP_LEFT</param>
|
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see constants in Gripper.cs, e.g. Gripper.POSITION_TOP_LEFT</param>
|
||||||
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper</param>
|
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper</param>
|
||||||
private static void Scale(ref RectangleF originalRectangle, Positions resizeHandlePosition, PointF resizeHandleCoords)
|
private static void Scale(ref NativeRectFloat originalRectangle, Positions resizeHandlePosition, NativePointFloat resizeHandleCoords)
|
||||||
{
|
{
|
||||||
switch (resizeHandlePosition)
|
switch (resizeHandlePosition)
|
||||||
{
|
{
|
||||||
case Positions.TopLeft:
|
case Positions.TopLeft:
|
||||||
originalRectangle.Width = originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.Height = originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y;
|
resizeHandleCoords.X,
|
||||||
originalRectangle.X = resizeHandleCoords.X;
|
resizeHandleCoords.Y,
|
||||||
originalRectangle.Y = resizeHandleCoords.Y;
|
originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X,
|
||||||
|
originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.TopCenter:
|
case Positions.TopCenter:
|
||||||
originalRectangle.Height = originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.Y = resizeHandleCoords.Y;
|
originalRectangle.X,
|
||||||
|
resizeHandleCoords.Y,
|
||||||
|
originalRectangle.Width,
|
||||||
|
originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.TopRight:
|
case Positions.TopRight:
|
||||||
originalRectangle.Width = resizeHandleCoords.X - originalRectangle.Left;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.Height = originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y;
|
originalRectangle.X,
|
||||||
originalRectangle.Y = resizeHandleCoords.Y;
|
resizeHandleCoords.Y,
|
||||||
|
resizeHandleCoords.X - originalRectangle.Left,
|
||||||
|
originalRectangle.Top + originalRectangle.Height - resizeHandleCoords.Y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.MiddleLeft:
|
case Positions.MiddleLeft:
|
||||||
originalRectangle.Width = originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.X = resizeHandleCoords.X;
|
resizeHandleCoords.X,
|
||||||
|
originalRectangle.Y,
|
||||||
|
originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X,
|
||||||
|
originalRectangle.Height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.MiddleRight:
|
case Positions.MiddleRight:
|
||||||
originalRectangle.Width = resizeHandleCoords.X - originalRectangle.Left;
|
originalRectangle = new NativeRectFloat(
|
||||||
|
originalRectangle.X,
|
||||||
|
originalRectangle.Y,
|
||||||
|
resizeHandleCoords.X - originalRectangle.Left,
|
||||||
|
originalRectangle.Height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.BottomLeft:
|
case Positions.BottomLeft:
|
||||||
originalRectangle.Width = originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.Height = resizeHandleCoords.Y - originalRectangle.Top;
|
resizeHandleCoords.X,
|
||||||
originalRectangle.X = resizeHandleCoords.X;
|
originalRectangle.Y,
|
||||||
|
originalRectangle.Left + originalRectangle.Width - resizeHandleCoords.X,
|
||||||
|
resizeHandleCoords.Y - originalRectangle.Top);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.BottomCenter:
|
case Positions.BottomCenter:
|
||||||
originalRectangle.Height = resizeHandleCoords.Y - originalRectangle.Top;
|
originalRectangle = new NativeRectFloat(
|
||||||
|
originalRectangle.X,
|
||||||
|
originalRectangle.Y,
|
||||||
|
originalRectangle.Width,
|
||||||
|
resizeHandleCoords.Y - originalRectangle.Top);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.BottomRight:
|
case Positions.BottomRight:
|
||||||
originalRectangle.Width = resizeHandleCoords.X - originalRectangle.Left;
|
originalRectangle = new NativeRectFloat(
|
||||||
originalRectangle.Height = resizeHandleCoords.Y - originalRectangle.Top;
|
originalRectangle.X,
|
||||||
|
originalRectangle.Y,
|
||||||
|
resizeHandleCoords.X - originalRectangle.Left,
|
||||||
|
resizeHandleCoords.Y - originalRectangle.Top);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -213,7 +236,7 @@ namespace Greenshot.Editor.Helpers
|
||||||
/// <param name="originalRectangle">bounds of the current rectangle</param>
|
/// <param name="originalRectangle">bounds of the current rectangle</param>
|
||||||
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see Position</param>
|
/// <param name="resizeHandlePosition">position of the handle/gripper being used for resized, see Position</param>
|
||||||
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper, adjusted coordinates will be written to this reference</param>
|
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper, adjusted coordinates will be written to this reference</param>
|
||||||
private static void AdjustCoordsForRationalScale(RectangleF originalRectangle, Positions resizeHandlePosition, ref PointF resizeHandleCoords)
|
private static void AdjustCoordsForRationalScale(NativeRectFloat originalRectangle, Positions resizeHandlePosition, ref NativePointFloat resizeHandleCoords)
|
||||||
{
|
{
|
||||||
SizeF selectedRectangle, newSize;
|
SizeF selectedRectangle, newSize;
|
||||||
|
|
||||||
|
@ -222,29 +245,25 @@ namespace Greenshot.Editor.Helpers
|
||||||
case Positions.TopLeft:
|
case Positions.TopLeft:
|
||||||
selectedRectangle = new SizeF(originalRectangle.Right - resizeHandleCoords.X, originalRectangle.Bottom - resizeHandleCoords.Y);
|
selectedRectangle = new SizeF(originalRectangle.Right - resizeHandleCoords.X, originalRectangle.Bottom - resizeHandleCoords.Y);
|
||||||
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
||||||
resizeHandleCoords.X = originalRectangle.Right - newSize.Width;
|
resizeHandleCoords = new NativePointFloat(originalRectangle.Right - newSize.Width, originalRectangle.Bottom - newSize.Height);
|
||||||
resizeHandleCoords.Y = originalRectangle.Bottom - newSize.Height;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.TopRight:
|
case Positions.TopRight:
|
||||||
selectedRectangle = new SizeF(resizeHandleCoords.X - originalRectangle.Left, originalRectangle.Bottom - resizeHandleCoords.Y);
|
selectedRectangle = new SizeF(resizeHandleCoords.X - originalRectangle.Left, originalRectangle.Bottom - resizeHandleCoords.Y);
|
||||||
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
||||||
resizeHandleCoords.X = originalRectangle.Left + newSize.Width;
|
resizeHandleCoords = new NativePointFloat(originalRectangle.Left + newSize.Width, originalRectangle.Bottom - newSize.Height);
|
||||||
resizeHandleCoords.Y = originalRectangle.Bottom - newSize.Height;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.BottomLeft:
|
case Positions.BottomLeft:
|
||||||
selectedRectangle = new SizeF(originalRectangle.Right - resizeHandleCoords.X, resizeHandleCoords.Y - originalRectangle.Top);
|
selectedRectangle = new SizeF(originalRectangle.Right - resizeHandleCoords.X, resizeHandleCoords.Y - originalRectangle.Top);
|
||||||
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
||||||
resizeHandleCoords.X = originalRectangle.Right - newSize.Width;
|
resizeHandleCoords = new NativePointFloat(originalRectangle.Right - newSize.Width, originalRectangle.Top + newSize.Height);
|
||||||
resizeHandleCoords.Y = originalRectangle.Top + newSize.Height;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Positions.BottomRight:
|
case Positions.BottomRight:
|
||||||
selectedRectangle = new SizeF(resizeHandleCoords.X - originalRectangle.Left, resizeHandleCoords.Y - originalRectangle.Top);
|
selectedRectangle = new SizeF(resizeHandleCoords.X - originalRectangle.Left, resizeHandleCoords.Y - originalRectangle.Top);
|
||||||
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
newSize = GetNewSizeForRationalScale(originalRectangle.Size, selectedRectangle);
|
||||||
resizeHandleCoords.X = originalRectangle.Left + newSize.Width;
|
resizeHandleCoords = new NativePointFloat(originalRectangle.Left + newSize.Width, originalRectangle.Top + newSize.Height);
|
||||||
resizeHandleCoords.Y = originalRectangle.Top + newSize.Height;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,12 +273,12 @@ namespace Greenshot.Editor.Helpers
|
||||||
/// * has the same aspect ratio as the original
|
/// * has the same aspect ratio as the original
|
||||||
/// * fits into selected size
|
/// * fits into selected size
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="originalSize">size to be considered for keeping aspect ratio</param>
|
/// <param name="originalSize">NativeSizeFloat to be considered for keeping aspect ratio</param>
|
||||||
/// <param name="selectedSize">selection size (i.e. the size we'd produce if we wouldn't keep aspect ratio)</param>
|
/// <param name="selectedSize">NativeSizeFloat selection size (i.e. the size we'd produce if we wouldn't keep aspect ratio)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static SizeF GetNewSizeForRationalScale(SizeF originalSize, SizeF selectedSize)
|
private static NativeSizeFloat GetNewSizeForRationalScale(NativeSizeFloat originalSize, NativeSizeFloat selectedSize)
|
||||||
{
|
{
|
||||||
SizeF newSize = selectedSize;
|
NativeSizeFloat newSize = selectedSize;
|
||||||
float originalRatio = originalSize.Width / originalSize.Height;
|
float originalRatio = originalSize.Width / originalSize.Height;
|
||||||
float selectedRatio = selectedSize.Width / selectedSize.Height;
|
float selectedRatio = selectedSize.Width / selectedSize.Height;
|
||||||
// will fix orientation if the scaling causes size to be flipped in any direction
|
// will fix orientation if the scaling causes size to be flipped in any direction
|
||||||
|
@ -268,29 +287,29 @@ namespace Greenshot.Editor.Helpers
|
||||||
{
|
{
|
||||||
// scaled rectangle (ratio) would be wider than original
|
// scaled rectangle (ratio) would be wider than original
|
||||||
// keep height and tweak width to maintain aspect ratio
|
// keep height and tweak width to maintain aspect ratio
|
||||||
newSize.Width = selectedSize.Height * originalRatio * flippedRatioSign;
|
newSize = newSize.ChangeWidth(selectedSize.Height * originalRatio * flippedRatioSign);
|
||||||
}
|
}
|
||||||
else if (Math.Abs(selectedRatio) < Math.Abs(originalRatio))
|
else if (Math.Abs(selectedRatio) < Math.Abs(originalRatio))
|
||||||
{
|
{
|
||||||
// scaled rectangle (ratio) would be taller than original
|
// scaled rectangle (ratio) would be taller than original
|
||||||
// keep width and tweak height to maintain aspect ratio
|
// keep width and tweak height to maintain aspect ratio
|
||||||
newSize.Height = selectedSize.Width / originalRatio * flippedRatioSign;
|
newSize = newSize.ChangeWidth(selectedSize.Width / originalRatio * flippedRatioSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newSize;
|
return newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize)
|
public static void Scale(NativeRect boundsBeforeResize, int cursorX, int cursorY, ref NativeRectFloat boundsAfterResize)
|
||||||
{
|
{
|
||||||
Scale(boundsBeforeResize, cursorX, cursorY, ref boundsAfterResize, null);
|
Scale(boundsBeforeResize, cursorX, cursorY, ref boundsAfterResize, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize, IDoubleProcessor angleRoundBehavior)
|
public static void Scale(NativeRect boundsBeforeResize, int cursorX, int cursorY, ref NativeRectFloat boundsAfterResize, IDoubleProcessor angleRoundBehavior)
|
||||||
{
|
{
|
||||||
Scale(boundsBeforeResize, Positions.TopLeft, cursorX, cursorY, ref boundsAfterResize, angleRoundBehavior);
|
Scale(boundsBeforeResize, Positions.TopLeft, cursorX, cursorY, ref boundsAfterResize, angleRoundBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Scale(Rectangle boundsBeforeResize, Positions gripperPosition, int cursorX, int cursorY, ref RectangleF boundsAfterResize,
|
public static void Scale(NativeRect boundsBeforeResize, Positions gripperPosition, int cursorX, int cursorY, ref NativeRectFloat boundsAfterResize,
|
||||||
IDoubleProcessor angleRoundBehavior)
|
IDoubleProcessor angleRoundBehavior)
|
||||||
{
|
{
|
||||||
ScaleOptions opts = GetScaleOptions();
|
ScaleOptions opts = GetScaleOptions();
|
||||||
|
@ -309,18 +328,16 @@ namespace Greenshot.Editor.Helpers
|
||||||
|
|
||||||
int dist = GeometryHelper.Distance2D(boundsBeforeResize.X, boundsBeforeResize.Y, cursorX, cursorY);
|
int dist = GeometryHelper.Distance2D(boundsBeforeResize.X, boundsBeforeResize.Y, cursorX, cursorY);
|
||||||
|
|
||||||
boundsAfterResize.Width = (int) Math.Round(dist * Math.Cos(angle / 180 * Math.PI));
|
boundsAfterResize = boundsAfterResize
|
||||||
boundsAfterResize.Height = (int) Math.Round(dist * Math.Sin(angle / 180 * Math.PI));
|
.ChangeWidth((int)Math.Round(dist * Math.Cos(angle / 180 * Math.PI)))
|
||||||
|
.ChangeHeight((int) Math.Round(dist * Math.Sin(angle / 180 * Math.PI)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (centeredScale)
|
if (centeredScale)
|
||||||
{
|
{
|
||||||
float wdiff = boundsAfterResize.Width - boundsBeforeResize.Width;
|
float wdiff = boundsAfterResize.Width - boundsBeforeResize.Width;
|
||||||
float hdiff = boundsAfterResize.Height - boundsBeforeResize.Height;
|
float hdiff = boundsAfterResize.Height - boundsBeforeResize.Height;
|
||||||
boundsAfterResize.Width += wdiff;
|
boundsAfterResize = boundsAfterResize.Inflate(wdiff, hdiff);
|
||||||
boundsAfterResize.Height += hdiff;
|
|
||||||
boundsAfterResize.X -= wdiff;
|
|
||||||
boundsAfterResize.Y -= hdiff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ using System.Threading.Tasks;
|
||||||
using Windows.Graphics.Imaging;
|
using Windows.Graphics.Imaging;
|
||||||
using Windows.Media.Ocr;
|
using Windows.Media.Ocr;
|
||||||
using Windows.Storage.Streams;
|
using Windows.Storage.Streams;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
using Greenshot.Base.Core.Enums;
|
using Greenshot.Base.Core.Enums;
|
||||||
using Greenshot.Base.Effects;
|
using Greenshot.Base.Effects;
|
||||||
|
@ -169,7 +170,7 @@ namespace Greenshot.Plugin.Win10
|
||||||
for (var index = 0; index < ocrLine.Words.Count; index++)
|
for (var index = 0; index < ocrLine.Words.Count; index++)
|
||||||
{
|
{
|
||||||
var ocrWord = ocrLine.Words[index];
|
var ocrWord = ocrLine.Words[index];
|
||||||
var location = new Rectangle((int) ocrWord.BoundingRect.X, (int) ocrWord.BoundingRect.Y,
|
var location = new NativeRect((int) ocrWord.BoundingRect.X, (int) ocrWord.BoundingRect.Y,
|
||||||
(int) ocrWord.BoundingRect.Width, (int) ocrWord.BoundingRect.Height);
|
(int) ocrWord.BoundingRect.Width, (int) ocrWord.BoundingRect.Height);
|
||||||
|
|
||||||
var word = line.Words[index];
|
var word = line.Words[index];
|
||||||
|
|
|
@ -73,40 +73,40 @@ namespace Greenshot.Forms
|
||||||
private readonly List<NativePoint> _gSpots = new List<NativePoint>
|
private readonly List<NativePoint> _gSpots = new List<NativePoint>
|
||||||
{
|
{
|
||||||
// Top row
|
// Top row
|
||||||
new NativePoint(P2, P1), // 0
|
new(P2, P1), // 0
|
||||||
new NativePoint(P3, P1), // 1
|
new(P3, P1), // 1
|
||||||
new NativePoint(P4, P1), // 2
|
new(P4, P1), // 2
|
||||||
new NativePoint(P5, P1), // 3
|
new(P5, P1), // 3
|
||||||
new NativePoint(P6, P1), // 4
|
new(P6, P1), // 4
|
||||||
|
|
||||||
// Second row
|
// Second row
|
||||||
new NativePoint(P1, P2), // 5
|
new(P1, P2), // 5
|
||||||
new NativePoint(P2, P2), // 6
|
new(P2, P2), // 6
|
||||||
|
|
||||||
// Third row
|
// Third row
|
||||||
new NativePoint(P1, P3), // 7
|
new(P1, P3), // 7
|
||||||
new NativePoint(P2, P3), // 8
|
new(P2, P3), // 8
|
||||||
|
|
||||||
// Fourth row
|
// Fourth row
|
||||||
new NativePoint(P1, P4), // 9
|
new(P1, P4), // 9
|
||||||
new NativePoint(P2, P4), // 10
|
new(P2, P4), // 10
|
||||||
new NativePoint(P5, P4), // 11
|
new(P5, P4), // 11
|
||||||
new NativePoint(P6, P4), // 12
|
new(P6, P4), // 12
|
||||||
new NativePoint(P7, P4), // 13
|
new(P7, P4), // 13
|
||||||
|
|
||||||
// Fifth row
|
// Fifth row
|
||||||
new NativePoint(P1, P5), // 14
|
new(P1, P5), // 14
|
||||||
new NativePoint(P2, P5), // 15
|
new(P2, P5), // 15
|
||||||
new NativePoint(P6, P5), // 16
|
new(P6, P5), // 16
|
||||||
new NativePoint(P7, P5), // 17
|
new(P7, P5), // 17
|
||||||
|
|
||||||
// Sixth row
|
// Sixth row
|
||||||
new NativePoint(P1, P6), // 18
|
new(P1, P6), // 18
|
||||||
new NativePoint(P2, P6), // 19
|
new(P2, P6), // 19
|
||||||
new NativePoint(P3, P6), // 20
|
new(P3, P6), // 20
|
||||||
new NativePoint(P4, P6), // 21
|
new(P4, P6), // 21
|
||||||
new NativePoint(P5, P6), // 22
|
new(P5, P6), // 22
|
||||||
new NativePoint(P6, P6) // 23
|
new(P6, P6) // 23
|
||||||
};
|
};
|
||||||
|
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
|
@ -166,7 +166,7 @@ namespace Greenshot.Forms
|
||||||
for (int index = 0; index < _gSpots.Count; index++)
|
for (int index = 0; index < _gSpots.Count; index++)
|
||||||
{
|
{
|
||||||
// Read the pixels in the order of the flow
|
// Read the pixels in the order of the flow
|
||||||
Point gSpot = _gSpots[_flowOrder[index]];
|
NativePoint gSpot = _gSpots[_flowOrder[index]];
|
||||||
// Create the animation, first we do nothing (on the final destination)
|
// Create the animation, first we do nothing (on the final destination)
|
||||||
RectangleAnimator pixelAnimation;
|
RectangleAnimator pixelAnimation;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace Greenshot.Forms
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the selected capture rectangle
|
/// Property to access the selected capture rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Rectangle CaptureRectangle => _captureRect;
|
public NativeRect CaptureRectangle => _captureRect;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the used capture mode
|
/// Property to access the used capture mode
|
||||||
|
@ -182,7 +182,7 @@ namespace Greenshot.Forms
|
||||||
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
||||||
if (_captureMode == CaptureMode.Window)
|
if (_captureMode == CaptureMode.Window)
|
||||||
{
|
{
|
||||||
_windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
_windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the zoomer animation
|
// Set the zoomer animation
|
||||||
|
@ -321,7 +321,7 @@ namespace Greenshot.Forms
|
||||||
InitializeZoomer(false);
|
InitializeZoomer(false);
|
||||||
// "Fade in" window
|
// "Fade in" window
|
||||||
_windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
_windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
_captureRect = Rectangle.Empty;
|
_captureRect = NativeRect.Empty;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
case CaptureMode.Text:
|
case CaptureMode.Text:
|
||||||
|
@ -436,7 +436,7 @@ namespace Greenshot.Forms
|
||||||
else if (_captureMode == CaptureMode.Text && IsWordUnderCursor(_mouseMovePos))
|
else if (_captureMode == CaptureMode.Text && IsWordUnderCursor(_mouseMovePos))
|
||||||
{
|
{
|
||||||
// Handle a click on a single word
|
// Handle a click on a single word
|
||||||
_captureRect = new Rectangle(_mouseMovePos, new Size(1, 1));
|
_captureRect = new NativeRect(_mouseMovePos, new NativeSize(1, 1));
|
||||||
// Go and process the capture
|
// Go and process the capture
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,7 @@ namespace Greenshot.Forms
|
||||||
// Here we want to capture the window which is under the mouse
|
// 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.
|
// As the ClientRectangle is not in Bitmap coordinates, we need to correct.
|
||||||
_captureRect.Offset(-_capture.ScreenBounds.Location.X, -_capture.ScreenBounds.Location.Y);
|
_captureRect = _captureRect.Offset(-_capture.ScreenBounds.Location.X, -_capture.ScreenBounds.Location.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ namespace Greenshot.Forms
|
||||||
{
|
{
|
||||||
if (!IsTerminalServerSession)
|
if (!IsTerminalServerSession)
|
||||||
{
|
{
|
||||||
NativeRect allScreenBounds = WindowCapture.GetScreenBounds();
|
var allScreenBounds = DisplayInfo.ScreenBounds;
|
||||||
allScreenBounds = allScreenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location));
|
allScreenBounds = allScreenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location));
|
||||||
if (verticalMove)
|
if (verticalMove)
|
||||||
{
|
{
|
||||||
|
@ -791,50 +791,49 @@ namespace Greenshot.Forms
|
||||||
/// <param name="allowZoomOverCaptureRect">false to try to find a location which is neither out of screen bounds nor intersects with the selected rectangle</param>
|
/// <param name="allowZoomOverCaptureRect">false to try to find a location which is neither out of screen bounds nor intersects with the selected rectangle</param>
|
||||||
private void VerifyZoomAnimation(Point pos, bool allowZoomOverCaptureRect)
|
private void VerifyZoomAnimation(Point pos, bool allowZoomOverCaptureRect)
|
||||||
{
|
{
|
||||||
Rectangle screenBounds = Screen.GetBounds(MousePosition);
|
NativeRect screenBounds = DisplayInfo.GetBounds(MousePosition);
|
||||||
// convert to be relative to top left corner of all screen bounds
|
// convert to be relative to top left corner of all screen bounds
|
||||||
screenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location);
|
screenBounds = screenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location));
|
||||||
int relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;
|
int relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;
|
||||||
// Make sure the final size is a plural of 4, this makes it look better
|
// Make sure the final size is a plural of 4, this makes it look better
|
||||||
relativeZoomSize -= relativeZoomSize % 4;
|
relativeZoomSize -= relativeZoomSize % 4;
|
||||||
Size zoomSize = new Size(relativeZoomSize, relativeZoomSize);
|
var zoomSize = new NativeSize(relativeZoomSize, relativeZoomSize);
|
||||||
Point zoomOffset = new Point(20, 20);
|
var zoomOffset = new NativePoint(20, 20);
|
||||||
|
|
||||||
Rectangle targetRectangle = _zoomAnimator.Final;
|
NativeRect targetRectangle = _zoomAnimator.Final.Offset(pos);
|
||||||
targetRectangle.Offset(pos);
|
|
||||||
if (screenBounds.Contains(targetRectangle) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(targetRectangle)))
|
if (screenBounds.Contains(targetRectangle) && (allowZoomOverCaptureRect || !_captureRect.IntersectsWith(targetRectangle)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Point destinationLocation = Point.Empty;
|
var destinationLocation = NativePoint.Empty;
|
||||||
Rectangle tl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height);
|
var tl = new NativeRect(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);
|
var tr = new NativeRect(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);
|
var bl = new NativeRect(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);
|
var br = new NativeRect(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);
|
destinationLocation = new NativePoint(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);
|
destinationLocation = new NativePoint(-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);
|
destinationLocation = new NativePoint(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);
|
destinationLocation = new NativePoint(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destinationLocation == Point.Empty && !allowZoomOverCaptureRect)
|
if (destinationLocation == NativePoint.Empty && !allowZoomOverCaptureRect)
|
||||||
{
|
{
|
||||||
VerifyZoomAnimation(pos, true);
|
VerifyZoomAnimation(pos, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_zoomAnimator.ChangeDestination(new Rectangle(destinationLocation, zoomSize));
|
_zoomAnimator.ChangeDestination(new NativeRect(destinationLocation, zoomSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +843,7 @@ namespace Greenshot.Forms
|
||||||
/// <param name="graphics"></param>
|
/// <param name="graphics"></param>
|
||||||
/// <param name="sourceRectangle"></param>
|
/// <param name="sourceRectangle"></param>
|
||||||
/// <param name="destinationRectangle"></param>
|
/// <param name="destinationRectangle"></param>
|
||||||
private void DrawZoom(Graphics graphics, Rectangle sourceRectangle, Rectangle destinationRectangle)
|
private void DrawZoom(Graphics graphics, NativeRect sourceRectangle, NativeRect destinationRectangle)
|
||||||
{
|
{
|
||||||
if (_capture.Image == null)
|
if (_capture.Image == null)
|
||||||
{
|
{
|
||||||
|
@ -957,7 +956,7 @@ namespace Greenshot.Forms
|
||||||
private void OnPaint(object sender, PaintEventArgs e)
|
private void OnPaint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
Graphics graphics = e.Graphics;
|
Graphics graphics = e.Graphics;
|
||||||
Rectangle clipRectangle = e.ClipRectangle;
|
NativeRect clipRectangle = e.ClipRectangle;
|
||||||
//graphics.BitBlt((Bitmap)buffer, Point.Empty);
|
//graphics.BitBlt((Bitmap)buffer, Point.Empty);
|
||||||
graphics.DrawImageUnscaled(_capture.Image, Point.Empty);
|
graphics.DrawImageUnscaled(_capture.Image, Point.Empty);
|
||||||
|
|
||||||
|
@ -1005,7 +1004,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only draw Cursor if it's (partly) visible
|
// Only draw Cursor if it's (partly) visible
|
||||||
if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size)))
|
if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new NativeRect(_capture.CursorLocation, _capture.Cursor.Size)))
|
||||||
{
|
{
|
||||||
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
|
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
|
||||||
}
|
}
|
||||||
|
@ -1141,7 +1140,7 @@ namespace Greenshot.Forms
|
||||||
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;
|
NativeRect screenBounds = _capture.ScreenBounds;
|
||||||
graphics.DrawLine(pen, _cursorPos.X, screenBounds.Y, _cursorPos.X, screenBounds.Height);
|
graphics.DrawLine(pen, _cursorPos.X, screenBounds.Y, _cursorPos.X, screenBounds.Height);
|
||||||
graphics.DrawLine(pen, screenBounds.X, _cursorPos.Y, screenBounds.Width, _cursorPos.Y);
|
graphics.DrawLine(pen, screenBounds.X, _cursorPos.Y, screenBounds.Width, _cursorPos.Y);
|
||||||
}
|
}
|
||||||
|
@ -1170,10 +1169,10 @@ namespace Greenshot.Forms
|
||||||
const int zoomSourceWidth = 25;
|
const int zoomSourceWidth = 25;
|
||||||
const int zoomSourceHeight = 25;
|
const int zoomSourceHeight = 25;
|
||||||
|
|
||||||
Rectangle sourceRectangle = new Rectangle(_cursorPos.X - zoomSourceWidth / 2, _cursorPos.Y - zoomSourceHeight / 2, zoomSourceWidth, zoomSourceHeight);
|
var sourceRectangle = new NativeRect(_cursorPos.X - zoomSourceWidth / 2, _cursorPos.Y - zoomSourceHeight / 2, zoomSourceWidth, zoomSourceHeight);
|
||||||
|
|
||||||
Rectangle destinationRectangle = _zoomAnimator.Current;
|
var destinationRectangle = _zoomAnimator.Current;
|
||||||
destinationRectangle.Offset(_cursorPos);
|
destinationRectangle = destinationRectangle.Offset(_cursorPos);
|
||||||
DrawZoom(graphics, sourceRectangle, destinationRectangle);
|
DrawZoom(graphics, sourceRectangle, destinationRectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Forms.Integration;
|
using System.Windows.Forms.Integration;
|
||||||
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.DesktopWindowsManager;
|
using Dapplo.Windows.DesktopWindowsManager;
|
||||||
using Dapplo.Windows.Dpi;
|
using Dapplo.Windows.Dpi;
|
||||||
using Dapplo.Windows.Kernel32;
|
using Dapplo.Windows.Kernel32;
|
||||||
|
using Dapplo.Windows.User32;
|
||||||
using Greenshot.Base;
|
using Greenshot.Base;
|
||||||
using Greenshot.Base.Controls;
|
using Greenshot.Base.Controls;
|
||||||
using Greenshot.Base.Core;
|
using Greenshot.Base.Core;
|
||||||
|
@ -1003,7 +1005,7 @@ namespace Greenshot.Forms
|
||||||
var factor = DeviceDpi / 96f;
|
var factor = DeviceDpi / 96f;
|
||||||
contextMenu.Scale(new SizeF(factor, factor));
|
contextMenu.Scale(new SizeF(factor, factor));
|
||||||
contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage();
|
contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage();
|
||||||
contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != Rectangle.Empty;
|
contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != NativeRect.Empty;
|
||||||
|
|
||||||
// IE context menu code
|
// IE context menu code
|
||||||
try
|
try
|
||||||
|
@ -1125,51 +1127,50 @@ namespace Greenshot.Forms
|
||||||
{
|
{
|
||||||
ToolStripMenuItem captureScreenMenuItem = (ToolStripMenuItem) sender;
|
ToolStripMenuItem captureScreenMenuItem = (ToolStripMenuItem) sender;
|
||||||
captureScreenMenuItem.DropDownItems.Clear();
|
captureScreenMenuItem.DropDownItems.Clear();
|
||||||
if (Screen.AllScreens.Length > 1)
|
if (DisplayInfo.AllDisplayInfos.Length <= 1) return;
|
||||||
{
|
|
||||||
Rectangle allScreensBounds = WindowCapture.GetScreenBounds();
|
|
||||||
|
|
||||||
var captureScreenItem = new ToolStripMenuItem(Language.GetString(LangKey.contextmenu_capturefullscreen_all));
|
var allScreensBounds = DisplayInfo.ScreenBounds;
|
||||||
captureScreenItem.Click += delegate {
|
|
||||||
BeginInvoke((MethodInvoker) delegate {
|
var captureScreenItem = new ToolStripMenuItem(Language.GetString(LangKey.contextmenu_capturefullscreen_all));
|
||||||
CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen);
|
captureScreenItem.Click += delegate {
|
||||||
|
BeginInvoke((MethodInvoker) delegate {
|
||||||
|
CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
||||||
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
|
{
|
||||||
|
var displayToCapture = displayInfo;
|
||||||
|
string deviceAlignment = displayToCapture.DeviceName;
|
||||||
|
|
||||||
|
if (displayInfo.Bounds.Top == allScreensBounds.Top && displayInfo.Bounds.Bottom != allScreensBounds.Bottom)
|
||||||
|
{
|
||||||
|
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_top);
|
||||||
|
}
|
||||||
|
else if (displayInfo.Bounds.Top != allScreensBounds.Top && displayInfo.Bounds.Bottom == allScreensBounds.Bottom)
|
||||||
|
{
|
||||||
|
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (displayInfo.Bounds.Left == allScreensBounds.Left && displayInfo.Bounds.Right != allScreensBounds.Right)
|
||||||
|
{
|
||||||
|
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_left);
|
||||||
|
}
|
||||||
|
else if (displayInfo.Bounds.Left != allScreensBounds.Left && displayInfo.Bounds.Right == allScreensBounds.Right)
|
||||||
|
{
|
||||||
|
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_right);
|
||||||
|
}
|
||||||
|
|
||||||
|
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||||
|
captureScreenItem.Click += delegate
|
||||||
|
{
|
||||||
|
BeginInvoke((MethodInvoker) delegate
|
||||||
|
{
|
||||||
|
CaptureHelper.CaptureRegion(false, displayToCapture.Bounds);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
||||||
foreach (Screen screen in Screen.AllScreens)
|
|
||||||
{
|
|
||||||
Screen screenToCapture = screen;
|
|
||||||
string deviceAlignment = screenToCapture.DeviceName;
|
|
||||||
|
|
||||||
if (screen.Bounds.Top == allScreensBounds.Top && screen.Bounds.Bottom != allScreensBounds.Bottom)
|
|
||||||
{
|
|
||||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_top);
|
|
||||||
}
|
|
||||||
else if (screen.Bounds.Top != allScreensBounds.Top && screen.Bounds.Bottom == allScreensBounds.Bottom)
|
|
||||||
{
|
|
||||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (screen.Bounds.Left == allScreensBounds.Left && screen.Bounds.Right != allScreensBounds.Right)
|
|
||||||
{
|
|
||||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_left);
|
|
||||||
}
|
|
||||||
else if (screen.Bounds.Left != allScreensBounds.Left && screen.Bounds.Right == allScreensBounds.Right)
|
|
||||||
{
|
|
||||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_right);
|
|
||||||
}
|
|
||||||
|
|
||||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
|
||||||
captureScreenItem.Click += delegate
|
|
||||||
{
|
|
||||||
BeginInvoke((MethodInvoker) delegate
|
|
||||||
{
|
|
||||||
CaptureHelper.CaptureRegion(false, screenToCapture.Bounds);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,8 +363,7 @@ namespace Greenshot.Helpers
|
||||||
_capture = WindowCapture.CaptureRectangle(_capture, screen.Bounds);
|
_capture = WindowCapture.CaptureRectangle(_capture, screen.Bounds);
|
||||||
captureTaken = true;
|
captureTaken = true;
|
||||||
// As the screen shot might be on a different monitor we need to correct the mouse location
|
// As the screen shot might be on a different monitor we need to correct the mouse location
|
||||||
var correctedCursorLocation = _capture.CursorLocation;
|
var correctedCursorLocation = _capture.CursorLocation.Offset(-screen.Bounds.Location.X, -screen.Bounds.Location.Y);
|
||||||
correctedCursorLocation.Offset(-screen.Bounds.Location.X, -screen.Bounds.Location.Y);
|
|
||||||
_capture.CursorLocation = correctedCursorLocation;
|
_capture.CursorLocation = correctedCursorLocation;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -877,7 +876,7 @@ namespace Greenshot.Helpers
|
||||||
/// <returns>WindowDetails with the target Window OR a replacement</returns>
|
/// <returns>WindowDetails with the target Window OR a replacement</returns>
|
||||||
public static WindowDetails SelectCaptureWindow(WindowDetails windowToCapture)
|
public static WindowDetails SelectCaptureWindow(WindowDetails windowToCapture)
|
||||||
{
|
{
|
||||||
Rectangle windowRectangle = windowToCapture.WindowRectangle;
|
NativeRect windowRectangle = windowToCapture.WindowRectangle;
|
||||||
if (windowRectangle.Width == 0 || windowRectangle.Height == 0)
|
if (windowRectangle.Width == 0 || windowRectangle.Height == 0)
|
||||||
{
|
{
|
||||||
Log.WarnFormat("Window {0} has nothing to capture, using workaround to find other window of same process.", windowToCapture.Text);
|
Log.WarnFormat("Window {0} has nothing to capture, using workaround to find other window of same process.", windowToCapture.Text);
|
||||||
|
@ -1220,8 +1219,7 @@ namespace Greenshot.Helpers
|
||||||
|
|
||||||
// save for re-capturing later and show recapture context menu option
|
// save for re-capturing later and show recapture context menu option
|
||||||
// Important here is that the location needs to be offsetted back to screen coordinates!
|
// Important here is that the location needs to be offsetted back to screen coordinates!
|
||||||
Rectangle tmpRectangle = _captureRect;
|
NativeRect tmpRectangle = _captureRect.Offset(_capture.ScreenBounds.Location.X, _capture.ScreenBounds.Location.Y);
|
||||||
tmpRectangle.Offset(_capture.ScreenBounds.Location.X, _capture.ScreenBounds.Location.Y);
|
|
||||||
CoreConfig.LastCapturedRegion = tmpRectangle;
|
CoreConfig.LastCapturedRegion = tmpRectangle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Dapplo.Windows.Common.Extensions;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Messages;
|
using Dapplo.Windows.Messages;
|
||||||
using Dapplo.Windows.User32;
|
using Dapplo.Windows.User32;
|
||||||
|
@ -760,9 +761,9 @@ namespace Greenshot.Helpers
|
||||||
// Crop to clientRectangle
|
// Crop to clientRectangle
|
||||||
if (ImageHelper.Crop(ref fragment, ref clientRectangle))
|
if (ImageHelper.Crop(ref fragment, ref clientRectangle))
|
||||||
{
|
{
|
||||||
Point targetLocation = new Point(documentContainer.DestinationLocation.X, documentContainer.DestinationLocation.Y);
|
NativePoint targetLocation = new NativePoint(documentContainer.DestinationLocation.X, documentContainer.DestinationLocation.Y);
|
||||||
Log.DebugFormat("Fragment targetLocation is {0}", targetLocation);
|
Log.DebugFormat("Fragment targetLocation is {0}", targetLocation);
|
||||||
targetLocation.Offset(targetOffset);
|
targetLocation = targetLocation.Offset(targetOffset);
|
||||||
Log.DebugFormat("After offsetting the fragment targetLocation is {0}", targetLocation);
|
Log.DebugFormat("After offsetting the fragment targetLocation is {0}", targetLocation);
|
||||||
Log.DebugFormat("Drawing fragment of size {0} to {1}", fragment.Size, targetLocation);
|
Log.DebugFormat("Drawing fragment of size {0} to {1}", fragment.Size, targetLocation);
|
||||||
graphicsTarget.DrawImage(fragment, targetLocation);
|
graphicsTarget.DrawImage(fragment, targetLocation);
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace Greenshot.Helpers.IEInterop
|
||||||
// Do not release IHTMLDocument5 com object, as this also gives problems with the document2!
|
// Do not release IHTMLDocument5 com object, as this also gives problems with the document2!
|
||||||
//Marshal.ReleaseComObject(document5);
|
//Marshal.ReleaseComObject(document5);
|
||||||
|
|
||||||
Rectangle clientRectangle = contentWindow.WindowRectangle;
|
NativeRect clientRectangle = contentWindow.WindowRectangle;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IHTMLWindow2 window2 = document2.parentWindow;
|
IHTMLWindow2 window2 = document2.parentWindow;
|
||||||
|
@ -184,9 +184,9 @@ namespace Greenshot.Helpers.IEInterop
|
||||||
// If there is a border AND a scrollbar the diff == 20
|
// If there is a border AND a scrollbar the diff == 20
|
||||||
if ((diffX == 4 || diffX >= 20) && (diffY == 4 || diffY >= 20))
|
if ((diffX == 4 || diffX >= 20) && (diffY == 4 || diffY >= 20))
|
||||||
{
|
{
|
||||||
Point viewportOffset = new Point(2, 2);
|
var viewportOffset = new NativePoint(2, 2);
|
||||||
Size viewportSize = new Size(ClientWidth, ClientHeight);
|
var viewportSize = new NativeSize(ClientWidth, ClientHeight);
|
||||||
_viewportRectangle = new Rectangle(viewportOffset, viewportSize);
|
_viewportRectangle = new NativeRect(viewportOffset, viewportSize);
|
||||||
LOG.DebugFormat("viewportRect {0}", _viewportRectangle);
|
LOG.DebugFormat("viewportRect {0}", _viewportRectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,15 +517,15 @@ namespace Greenshot.Helpers.IEInterop
|
||||||
|
|
||||||
public int ScrollHeight => ScaleY(GetAttributeAsInt("scrollHeight"));
|
public int ScrollHeight => ScaleY(GetAttributeAsInt("scrollHeight"));
|
||||||
|
|
||||||
public Point SourceLocation
|
public NativePoint SourceLocation
|
||||||
{
|
{
|
||||||
get { return _sourceLocation; }
|
get { return _sourceLocation; }
|
||||||
set { _sourceLocation = value; }
|
set { _sourceLocation = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size SourceSize => new Size(ClientWidth, ClientHeight);
|
public NativeSize SourceSize => new NativeSize(ClientWidth, ClientHeight);
|
||||||
|
|
||||||
public Rectangle SourceRectangle => new Rectangle(SourceLocation, SourceSize);
|
public NativeRect SourceRectangle => new NativeRect(SourceLocation, SourceSize);
|
||||||
|
|
||||||
public int SourceLeft => _sourceLocation.X;
|
public int SourceLeft => _sourceLocation.X;
|
||||||
|
|
||||||
|
@ -535,15 +535,15 @@ namespace Greenshot.Helpers.IEInterop
|
||||||
|
|
||||||
public int SourceBottom => _sourceLocation.Y + ClientHeight;
|
public int SourceBottom => _sourceLocation.Y + ClientHeight;
|
||||||
|
|
||||||
public Point DestinationLocation
|
public NativePoint DestinationLocation
|
||||||
{
|
{
|
||||||
get { return _destinationLocation; }
|
get { return _destinationLocation; }
|
||||||
set { _destinationLocation = value; }
|
set { _destinationLocation = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size DestinationSize => new Size(ScrollWidth, ScrollHeight);
|
public NativeSize DestinationSize => new NativeSize(ScrollWidth, ScrollHeight);
|
||||||
|
|
||||||
public Rectangle DestinationRectangle => new Rectangle(DestinationLocation, DestinationSize);
|
public NativeRect DestinationRectangle => new NativeRect(DestinationLocation, DestinationSize);
|
||||||
|
|
||||||
public int DestinationLeft
|
public int DestinationLeft
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue