mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 22:13:23 -07:00
Some more small changes from Point to NativePoint etc, also some small code changes.
This commit is contained in:
parent
cfe7d69a29
commit
f900299cc8
26 changed files with 107 additions and 161 deletions
|
@ -396,10 +396,10 @@ namespace Greenshot.Base.Controls
|
|||
|
||||
protected void ApplyLanguage(Control applyTo)
|
||||
{
|
||||
if (!(applyTo is IGreenshotLanguageBindable languageBindable))
|
||||
if (applyTo is not IGreenshotLanguageBindable languageBindable)
|
||||
{
|
||||
// check if it's a menu!
|
||||
if (!(applyTo is ToolStrip toolStrip))
|
||||
if (applyTo is not ToolStrip toolStrip)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -416,20 +416,14 @@ namespace Greenshot.Base.Controls
|
|||
ApplyLanguage(applyTo, languageBindable.LanguageKey);
|
||||
|
||||
// Repopulate the combox boxes
|
||||
if (applyTo is IGreenshotConfigBindable configBindable && applyTo is GreenshotComboBox comboxBox)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName))
|
||||
{
|
||||
IniSection section = IniConfig.GetIniSection(configBindable.SectionName);
|
||||
if (section != null)
|
||||
{
|
||||
// Only update the language, so get the actual value and than repopulate
|
||||
Enum currentValue = comboxBox.GetSelectedEnum();
|
||||
comboxBox.Populate(section.Values[configBindable.PropertyName].ValueType);
|
||||
comboxBox.SetValue(currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (applyTo is not (IGreenshotConfigBindable configBindable and GreenshotComboBox comboxBox)) return;
|
||||
if (string.IsNullOrEmpty(configBindable.SectionName) || string.IsNullOrEmpty(configBindable.PropertyName)) return;
|
||||
IniSection section = IniConfig.GetIniSection(configBindable.SectionName);
|
||||
if (section == null) return;
|
||||
// Only update the language, so get the actual value and than repopulate
|
||||
Enum currentValue = comboxBox.GetSelectedEnum();
|
||||
comboxBox.Populate(section.Values[configBindable.PropertyName].ValueType);
|
||||
comboxBox.SetValue(currentValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -472,10 +466,9 @@ namespace Greenshot.Base.Controls
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!(controlObject is Control applyToControl))
|
||||
if (controlObject is not Control applyToControl)
|
||||
{
|
||||
ToolStripItem applyToItem = controlObject as ToolStripItem;
|
||||
if (applyToItem == null)
|
||||
if (controlObject is not ToolStripItem applyToItem)
|
||||
{
|
||||
LOG.DebugFormat("No Control or ToolStripItem: {0}", field.Name);
|
||||
continue;
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Greenshot.Base.Core
|
|||
|
||||
public virtual int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is IDestination other))
|
||||
if (obj is not IDestination other)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -284,6 +284,9 @@ EndSelection:<<<<<<<4
|
|||
{
|
||||
if (dataObject == null) return false;
|
||||
|
||||
IList<string> formats = GetFormats(dataObject);
|
||||
Log.DebugFormat("Found formats: {0}", string.Join(",", formats));
|
||||
|
||||
if (dataObject.GetDataPresent(DataFormats.Bitmap)
|
||||
|| dataObject.GetDataPresent(DataFormats.Dib)
|
||||
|| dataObject.GetDataPresent(DataFormats.Tiff)
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Dapplo.Windows.Common.Extensions;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Greenshot.Base.Effects;
|
||||
|
||||
namespace Greenshot.Base.Core
|
||||
|
@ -136,16 +138,16 @@ namespace Greenshot.Base.Core
|
|||
|
||||
break;
|
||||
case "ShadowOffset":
|
||||
Point shadowOffset = new Point();
|
||||
NativePoint shadowOffset = new NativePoint();
|
||||
string[] coordinates = pair[1].Split(',');
|
||||
if (int.TryParse(coordinates[0], out var shadowOffsetX))
|
||||
{
|
||||
shadowOffset.X = shadowOffsetX;
|
||||
shadowOffset = shadowOffset.ChangeX(shadowOffsetX);
|
||||
}
|
||||
|
||||
if (int.TryParse(coordinates[1], out var shadowOffsetY))
|
||||
{
|
||||
shadowOffset.Y = shadowOffsetY;
|
||||
shadowOffset = shadowOffset.ChangeY(shadowOffsetY);
|
||||
}
|
||||
|
||||
effect.ShadowOffset = shadowOffset;
|
||||
|
|
|
@ -384,7 +384,7 @@ namespace Greenshot.Base.Core
|
|||
protected FastBitmap(Bitmap bitmap, NativeRect area)
|
||||
{
|
||||
Bitmap = bitmap;
|
||||
var bitmapArea = new NativeRect(Point.Empty, bitmap.Size);
|
||||
var bitmapArea = new NativeRect(NativePoint.Empty, bitmap.Size);
|
||||
if (area != NativeRect.Empty)
|
||||
{
|
||||
area = area.Intersect(bitmapArea);
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace Greenshot.Base.Core
|
|||
/// Private helper method for the FindAutoCropNativeRect
|
||||
/// </summary>
|
||||
/// <param name="fastBitmap">IFastBitmap</param>
|
||||
/// <param name="colorPoint">Point</param>
|
||||
/// <param name="colorPoint">NativePoint</param>
|
||||
/// <param name="cropDifference">int</param>
|
||||
/// <param name="area">NativeRect with optional area to scan in</param>
|
||||
/// <returns>NativeRect</returns>
|
||||
|
|
|
@ -558,46 +558,6 @@ namespace Greenshot.Base.Core
|
|||
return fileImage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Based on: https://www.codeproject.com/KB/cs/IconExtractor.aspx
|
||||
/// And a hint from: https://www.codeproject.com/KB/cs/IconLib.aspx
|
||||
/// </summary>
|
||||
/// <param name="iconStream">Stream with the icon information</param>
|
||||
/// <returns>Bitmap with the Vista Icon (256x256)</returns>
|
||||
private static Bitmap ExtractVistaIcon(Stream iconStream)
|
||||
{
|
||||
const int sizeIconDir = 6;
|
||||
const int sizeIconDirEntry = 16;
|
||||
Bitmap bmpPngExtracted = null;
|
||||
try
|
||||
{
|
||||
byte[] srcBuf = new byte[iconStream.Length];
|
||||
iconStream.Read(srcBuf, 0, (int)iconStream.Length);
|
||||
int iCount = BitConverter.ToInt16(srcBuf, 4);
|
||||
for (int iIndex = 0; iIndex < iCount; iIndex++)
|
||||
{
|
||||
int iWidth = srcBuf[sizeIconDir + sizeIconDirEntry * iIndex];
|
||||
int iHeight = srcBuf[sizeIconDir + sizeIconDirEntry * iIndex + 1];
|
||||
if (iWidth == 0 && iHeight == 0)
|
||||
{
|
||||
int iImageSize = BitConverter.ToInt32(srcBuf, sizeIconDir + sizeIconDirEntry * iIndex + 8);
|
||||
int iImageOffset = BitConverter.ToInt32(srcBuf, sizeIconDir + sizeIconDirEntry * iIndex + 12);
|
||||
using MemoryStream destStream = new MemoryStream();
|
||||
destStream.Write(srcBuf, iImageOffset, iImageSize);
|
||||
destStream.Seek(0, SeekOrigin.Begin);
|
||||
bmpPngExtracted = new Bitmap(destStream); // This is PNG! :)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return bmpPngExtracted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an image from a stream, if an extension is supplied more formats are supported.
|
||||
/// </summary>
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace Greenshot.Base.Core
|
|||
/// </summary>
|
||||
/// <param name="path">path to the exe or dll</param>
|
||||
/// <param name="index">index of the icon</param>
|
||||
/// <returns>Bitmap with the icon or null if something happended</returns>
|
||||
/// <returns>Bitmap with the icon or null if something happened</returns>
|
||||
public static Image GetCachedExeIcon(string path, int index)
|
||||
{
|
||||
string cacheKey = $"{path}:{index}";
|
||||
|
@ -148,7 +148,7 @@ namespace Greenshot.Base.Core
|
|||
/// </summary>
|
||||
/// <param name="path">path to the exe or dll</param>
|
||||
/// <param name="index">index of the icon</param>
|
||||
/// <returns>Bitmap with the icon or null if something happended</returns>
|
||||
/// <returns>Bitmap with the icon or null if something happened</returns>
|
||||
private static Bitmap GetExeIcon(string path, int index)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
@ -164,7 +164,6 @@ namespace Greenshot.Base.Core
|
|||
Log.DebugFormat("Loaded icon for {0}, with dimensions {1}x{2}", path, appIcon.Width, appIcon.Height);
|
||||
return appIcon;
|
||||
}
|
||||
return appIcon;
|
||||
}
|
||||
catch (Exception exIcon)
|
||||
{
|
||||
|
|
|
@ -96,12 +96,12 @@ namespace Greenshot.Base.Core
|
|||
using SafeIconHandle safeIcon = NativeIconMethods.CopyIcon(cursorInfo.CursorHandle);
|
||||
if (!NativeIconMethods.GetIconInfo(safeIcon, out var iconInfo)) return capture;
|
||||
|
||||
Point cursorLocation = User32Api.GetCursorLocation();
|
||||
NativePoint cursorLocation = User32Api.GetCursorLocation();
|
||||
// Align cursor location to Bitmap coordinates (instead of Screen coordinates)
|
||||
var x = cursorLocation.X - iconInfo.Hotspot.X - capture.ScreenBounds.X;
|
||||
var y = cursorLocation.Y - iconInfo.Hotspot.Y - capture.ScreenBounds.Y;
|
||||
// Set the location
|
||||
capture.CursorLocation = new Point(x, y);
|
||||
capture.CursorLocation = new NativePoint(x, y);
|
||||
|
||||
using (Icon icon = Icon.FromHandle(safeIcon.DangerousGetHandle()))
|
||||
{
|
||||
|
|
|
@ -1515,9 +1515,9 @@ namespace Greenshot.Base.Core
|
|||
/// <summary>
|
||||
/// Recursive "find children which"
|
||||
/// </summary>
|
||||
/// <param name="point">point to check for</param>
|
||||
/// <returns></returns>
|
||||
public WindowDetails FindChildUnderPoint(Point point)
|
||||
/// <param name="point">NativePoint to check for</param>
|
||||
/// <returns>WindowDetails</returns>
|
||||
public WindowDetails FindChildUnderPoint(NativePoint point)
|
||||
{
|
||||
if (!Contains(point))
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Greenshot.Base.Core;
|
||||
|
||||
namespace Greenshot.Base.Effects
|
||||
|
@ -42,7 +43,7 @@ namespace Greenshot.Base.Effects
|
|||
|
||||
public int ShadowSize { get; set; }
|
||||
|
||||
public Point ShadowOffset { get; set; }
|
||||
public NativePoint ShadowOffset { get; set; }
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace Greenshot.Editor.Controls
|
|||
{
|
||||
//Release Capture should consume MouseUp when canceled with the escape key
|
||||
User32Api.ReleaseCapture();
|
||||
PipetteUsed?.Invoke(this, new PipetteUsedArgs(_movableShowColorForm.color));
|
||||
PipetteUsed?.Invoke(this, new PipetteUsedArgs(_movableShowColorForm.Color));
|
||||
}
|
||||
|
||||
base.OnMouseUp(e);
|
||||
|
|
|
@ -55,23 +55,18 @@ namespace Greenshot.Editor.Drawing.Adorners
|
|||
isNotSwitched = !isNotSwitched;
|
||||
}
|
||||
|
||||
switch (Position)
|
||||
return Position switch
|
||||
{
|
||||
case Positions.TopLeft:
|
||||
case Positions.BottomRight:
|
||||
return isNotSwitched ? Cursors.SizeNWSE : Cursors.SizeNESW;
|
||||
case Positions.TopRight:
|
||||
case Positions.BottomLeft:
|
||||
return isNotSwitched ? Cursors.SizeNESW : Cursors.SizeNWSE;
|
||||
case Positions.MiddleLeft:
|
||||
case Positions.MiddleRight:
|
||||
return Cursors.SizeWE;
|
||||
case Positions.TopCenter:
|
||||
case Positions.BottomCenter:
|
||||
return Cursors.SizeNS;
|
||||
default:
|
||||
return Cursors.SizeAll;
|
||||
}
|
||||
Positions.TopLeft => isNotSwitched ? Cursors.SizeNWSE : Cursors.SizeNESW,
|
||||
Positions.BottomRight => isNotSwitched ? Cursors.SizeNWSE : Cursors.SizeNESW,
|
||||
Positions.TopRight => isNotSwitched ? Cursors.SizeNESW : Cursors.SizeNWSE,
|
||||
Positions.BottomLeft => isNotSwitched ? Cursors.SizeNESW : Cursors.SizeNWSE,
|
||||
Positions.MiddleLeft => Cursors.SizeWE,
|
||||
Positions.MiddleRight => Cursors.SizeWE,
|
||||
Positions.TopCenter => Cursors.SizeNS,
|
||||
Positions.BottomCenter => Cursors.SizeNS,
|
||||
_ => Cursors.SizeAll
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Greenshot.Editor.Drawing
|
|||
/// This is the offset for the shadow version of the bitmap
|
||||
/// Do not serialize, as the offset is recreated
|
||||
/// </summary>
|
||||
[NonSerialized] private Point _shadowOffset = new Point(-1, -1);
|
||||
[NonSerialized] private NativePoint _shadowOffset = new NativePoint(-1, -1);
|
||||
|
||||
public ImageContainer(ISurface parent, string filename) : this(parent)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Greenshot.Editor.Drawing
|
|||
private NativePoint _initialGripperPoint;
|
||||
|
||||
// Only used for serializing the TargetGripper location
|
||||
private Point _storedTargetGripperLocation;
|
||||
private NativePoint _storedTargetGripperLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Store the current location of the target gripper
|
||||
|
@ -96,8 +96,8 @@ namespace Greenshot.Editor.Drawing
|
|||
{
|
||||
if (TargetAdorner == null)
|
||||
{
|
||||
_initialGripperPoint = new Point(mouseX, mouseY);
|
||||
InitTargetAdorner(new Point(mouseX, mouseY));
|
||||
_initialGripperPoint = new NativePoint(mouseX, mouseY);
|
||||
InitTargetAdorner(_initialGripperPoint);
|
||||
}
|
||||
|
||||
return base.HandleMouseDown(mouseX, mouseY);
|
||||
|
|
|
@ -1012,7 +1012,7 @@ namespace Greenshot.Editor.Drawing
|
|||
public void Clear(Color newColor)
|
||||
{
|
||||
//create a blank bitmap the same size as original
|
||||
Bitmap newBitmap = ImageHelper.CreateEmptyLike(Image, Color.Empty);
|
||||
Bitmap newBitmap = ImageHelper.CreateEmptyLike(Image, newColor);
|
||||
if (newBitmap == null) return;
|
||||
// Make undoable
|
||||
MakeUndoable(new SurfaceBackgroundChangeMemento(this, null), false);
|
||||
|
@ -2112,10 +2112,7 @@ namespace Greenshot.Editor.Drawing
|
|||
}
|
||||
|
||||
// maybe the undo button has to be enabled
|
||||
if (_movingElementChanged != null)
|
||||
{
|
||||
_movingElementChanged(this, new SurfaceElementEventArgs());
|
||||
}
|
||||
_movingElementChanged?.Invoke(this, new SurfaceElementEventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2150,10 +2147,7 @@ namespace Greenshot.Editor.Drawing
|
|||
DrawingMode = DrawingModes.None;
|
||||
|
||||
// maybe the undo button has to be enabled
|
||||
if (_movingElementChanged != null)
|
||||
{
|
||||
_movingElementChanged(this, new SurfaceElementEventArgs());
|
||||
}
|
||||
_movingElementChanged?.Invoke(this, new SurfaceElementEventArgs());
|
||||
}
|
||||
|
||||
public void RemoveCropContainer()
|
||||
|
@ -2195,7 +2189,7 @@ namespace Greenshot.Editor.Drawing
|
|||
// Make element(s) only move 10,10 if the surface is the same
|
||||
bool isSameSurface = (dcs.ParentID == _uniqueId);
|
||||
dcs.Parent = this;
|
||||
var moveOffset = isSameSurface ? new Point(10, 10) : Point.Empty;
|
||||
var moveOffset = isSameSurface ? new NativePoint(10, 10) : NativePoint.Empty;
|
||||
// Here a fix for bug #1475, first calculate the bounds of the complete IDrawableContainerList
|
||||
NativeRect drawableContainerListBounds = NativeRect.Empty;
|
||||
foreach (var element in dcs)
|
||||
|
@ -2485,24 +2479,24 @@ namespace Greenshot.Editor.Drawing
|
|||
|
||||
bool shiftModifier = (ModifierKeys & Keys.Shift) == Keys.Shift;
|
||||
int px = shiftModifier ? 10 : 1;
|
||||
Point moveBy = Point.Empty;
|
||||
NativePoint moveBy = NativePoint.Empty;
|
||||
switch (k)
|
||||
{
|
||||
case Keys.Left:
|
||||
case Keys.Left | Keys.Shift:
|
||||
moveBy = new Point(-px, 0);
|
||||
moveBy = new NativePoint(-px, 0);
|
||||
break;
|
||||
case Keys.Up:
|
||||
case Keys.Up | Keys.Shift:
|
||||
moveBy = new Point(0, -px);
|
||||
moveBy = new NativePoint(0, -px);
|
||||
break;
|
||||
case Keys.Right:
|
||||
case Keys.Right | Keys.Shift:
|
||||
moveBy = new Point(px, 0);
|
||||
moveBy = new NativePoint(px, 0);
|
||||
break;
|
||||
case Keys.Down:
|
||||
case Keys.Down | Keys.Shift:
|
||||
moveBy = new Point(0, px);
|
||||
moveBy = new NativePoint(0, px);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
PullElementsUp();
|
||||
|
@ -2580,7 +2574,7 @@ namespace Greenshot.Editor.Drawing
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Point.Empty.Equals(moveBy))
|
||||
if (moveBy != NativePoint.Empty)
|
||||
{
|
||||
selectedElements.MakeBoundsChangeUndoable(true);
|
||||
selectedElements.MoveBy(moveBy.X, moveBy.Y);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Greenshot.Editor.Drawing
|
|||
[Serializable]
|
||||
public class SvgContainer : VectorGraphicsContainer
|
||||
{
|
||||
private SvgDocument _svgDocument;
|
||||
private readonly SvgDocument _svgDocument;
|
||||
|
||||
public SvgContainer(SvgDocument svgDocument, ISurface parent) : base(parent)
|
||||
{
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace Greenshot.Editor.Drawing
|
|||
};
|
||||
|
||||
_textBox.DataBindings.Add("Text", this, "Text", false, DataSourceUpdateMode.OnPropertyChanged);
|
||||
_textBox.LostFocus += textBox_LostFocus;
|
||||
_textBox.LostFocus += TextBox_LostFocus;
|
||||
_textBox.KeyDown += textBox_KeyDown;
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,7 @@ namespace Greenshot.Editor.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
private void textBox_LostFocus(object sender, EventArgs e)
|
||||
private void TextBox_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
// next change will be made undoable
|
||||
makeUndoable = true;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Greenshot.Base.Effects;
|
||||
|
||||
namespace Greenshot.Editor.Forms
|
||||
|
@ -51,7 +52,7 @@ namespace Greenshot.Editor.Forms
|
|||
private void ButtonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
_effect.Darkness = trackBar1.Value / (float) 40;
|
||||
_effect.ShadowOffset = new Point((int) offsetX.Value, (int) offsetY.Value);
|
||||
_effect.ShadowOffset = new NativePoint((int) offsetX.Value, (int) offsetY.Value);
|
||||
_effect.ShadowSize = (int) thickness.Value;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Greenshot.Editor.Forms
|
|||
/// </summary>
|
||||
public partial class MovableShowColorForm : Form
|
||||
{
|
||||
public Color color
|
||||
public Color Color
|
||||
{
|
||||
get { return preview.BackColor; }
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ namespace Greenshot.Editor.Forms
|
|||
/// <summary>
|
||||
/// Get the color from the pixel on the screen at "x,y"
|
||||
/// </summary>
|
||||
/// <param name="screenCoordinates">Point with the coordinates</param>
|
||||
/// <param name="screenCoordinates">NativePoint with the coordinates</param>
|
||||
/// <returns>Color at the specified screenCoordinates</returns>
|
||||
private static Color GetPixelColor(Point screenCoordinates)
|
||||
private static Color GetPixelColor(NativePoint screenCoordinates)
|
||||
{
|
||||
using SafeWindowDcHandle safeWindowDcHandle = SafeWindowDcHandle.FromDesktop();
|
||||
try
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Greenshot.Base.Effects;
|
||||
|
||||
namespace Greenshot.Editor.Forms
|
||||
|
@ -56,7 +56,7 @@ namespace Greenshot.Editor.Forms
|
|||
private void ButtonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
_effect.Darkness = shadowDarkness.Value / (float) 40;
|
||||
_effect.ShadowOffset = new Point((int) offsetX.Value, (int) offsetY.Value);
|
||||
_effect.ShadowOffset = new NativePoint((int) offsetX.Value, (int) offsetY.Value);
|
||||
_effect.ShadowSize = (int) thickness.Value;
|
||||
_effect.ToothHeight = (int) toothsize.Value;
|
||||
_effect.VerticalToothRange = (int) verticaltoothrange.Value;
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace Greenshot.Forms
|
|||
/// <param name="e"></param>
|
||||
private void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
if (!(sender is LinkLabel linkLabel)) return;
|
||||
if (sender is not LinkLabel linkLabel) return;
|
||||
var link = linkLabel.Tag?.ToString() ?? linkLabel.Text;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Greenshot.Forms
|
|||
|
||||
private int _mX;
|
||||
private int _mY;
|
||||
private NativePoint _mouseMovePos = Point.Empty;
|
||||
private NativePoint _mouseMovePos = NativePoint.Empty;
|
||||
private NativePoint _cursorPos;
|
||||
private CaptureMode _captureMode;
|
||||
private readonly List<WindowDetails> _windows;
|
||||
|
@ -404,7 +404,7 @@ namespace Greenshot.Forms
|
|||
|
||||
private void HandleMouseDown()
|
||||
{
|
||||
Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||
NativePoint tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||
_mX = tmpCursorLocation.X;
|
||||
_mY = tmpCursorLocation.Y;
|
||||
_mouseDown = true;
|
||||
|
@ -508,11 +508,11 @@ namespace Greenshot.Forms
|
|||
}
|
||||
else if (_fixMode == FixMode.Vertical)
|
||||
{
|
||||
currentMouse = new Point(currentMouse.X, _previousMousePos.Y);
|
||||
currentMouse = new NativePoint(currentMouse.X, _previousMousePos.Y);
|
||||
}
|
||||
else if (_fixMode == FixMode.Horizontal)
|
||||
{
|
||||
currentMouse = new Point(_previousMousePos.X, currentMouse.Y);
|
||||
currentMouse = new NativePoint(_previousMousePos.X, currentMouse.Y);
|
||||
}
|
||||
|
||||
_previousMousePos = currentMouse;
|
||||
|
@ -551,7 +551,7 @@ namespace Greenshot.Forms
|
|||
/// </summary>
|
||||
protected override void Animate()
|
||||
{
|
||||
Point lastPos = _cursorPos;
|
||||
NativePoint lastPos = _cursorPos;
|
||||
_cursorPos = _mouseMovePos;
|
||||
|
||||
if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !IsAnimating(_zoomAnimator) && !IsAnimating(_windowAnimator))
|
||||
|
@ -579,7 +579,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
|
||||
// Iterate over the found windows and check if the current location is inside a window
|
||||
Point cursorPosition = Cursor.Position;
|
||||
NativePoint cursorPosition = Cursor.Position;
|
||||
_selectedCaptureWindow = null;
|
||||
lock (_windows)
|
||||
{
|
||||
|
@ -789,7 +789,7 @@ namespace Greenshot.Forms
|
|||
/// </summary>
|
||||
/// <param name="pos">preferred destination location for the zoom area</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(NativePoint pos, bool allowZoomOverCaptureRect)
|
||||
{
|
||||
NativeRect screenBounds = DisplayInfo.GetBounds(MousePosition);
|
||||
// convert to be relative to top left corner of all screen bounds
|
||||
|
|
|
@ -507,14 +507,12 @@ namespace Greenshot.Helpers
|
|||
// Set capture title, fixing bug #3569703
|
||||
foreach (WindowDetails window in WindowDetails.GetVisibleWindows())
|
||||
{
|
||||
Point estimatedLocation = new Point(CoreConfig.LastCapturedRegion.X + CoreConfig.LastCapturedRegion.Width / 2,
|
||||
NativePoint estimatedLocation = new NativePoint(CoreConfig.LastCapturedRegion.X + CoreConfig.LastCapturedRegion.Width / 2,
|
||||
CoreConfig.LastCapturedRegion.Y + CoreConfig.LastCapturedRegion.Height / 2);
|
||||
if (window.Contains(estimatedLocation))
|
||||
{
|
||||
_selectedCaptureWindow = window;
|
||||
_capture.CaptureDetails.Title = _selectedCaptureWindow.Text;
|
||||
break;
|
||||
}
|
||||
if (!window.Contains(estimatedLocation)) continue;
|
||||
_selectedCaptureWindow = window;
|
||||
_capture.CaptureDetails.Title = _selectedCaptureWindow.Text;
|
||||
break;
|
||||
}
|
||||
|
||||
// Move cursor, fixing bug #3569703
|
||||
|
|
|
@ -722,14 +722,14 @@ namespace Greenshot.Helpers
|
|||
int horizontalPage = 0;
|
||||
|
||||
// The location of the browser, used as the destination into the bitmap target
|
||||
Point targetOffset = new Point();
|
||||
NativePoint targetOffset = NativePoint.Empty;
|
||||
|
||||
// Loop of the pages and make a copy of the visible viewport
|
||||
while (horizontalPage * viewportWidth < pageWidth)
|
||||
{
|
||||
// Scroll to location
|
||||
documentContainer.ScrollLeft = viewportWidth * horizontalPage;
|
||||
targetOffset.X = documentContainer.ScrollLeft;
|
||||
targetOffset = targetOffset.ChangeX(documentContainer.ScrollLeft);
|
||||
|
||||
// Variable used for looping vertically
|
||||
int verticalPage = 0;
|
||||
|
@ -738,7 +738,7 @@ namespace Greenshot.Helpers
|
|||
// Scroll to location
|
||||
documentContainer.ScrollTop = viewportHeight * verticalPage;
|
||||
//Shoot visible window
|
||||
targetOffset.Y = documentContainer.ScrollTop;
|
||||
targetOffset = targetOffset.ChangeY(documentContainer.ScrollTop);
|
||||
|
||||
// Draw the captured fragment to the target, but "crop" the scrollbars etc while capturing
|
||||
NativeSize viewPortSize = new NativeSize(viewportWidth, viewportHeight);
|
||||
|
|
|
@ -40,11 +40,11 @@ namespace Greenshot.Helpers.IEInterop
|
|||
private static readonly Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
|
||||
private static readonly Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E");
|
||||
private static int _counter;
|
||||
private readonly NativePoint _startLocation = NativePoint.Empty;
|
||||
private IHTMLDocument2 _document2;
|
||||
private IHTMLDocument3 _document3;
|
||||
private NativePoint _sourceLocation;
|
||||
private NativePoint _destinationLocation;
|
||||
private NativePoint _startLocation = NativePoint.Empty;
|
||||
private NativeRect _viewportRectangle = NativeRect.Empty;
|
||||
private bool _isDtd;
|
||||
private DocumentContainer _parent;
|
||||
|
@ -90,15 +90,15 @@ namespace Greenshot.Helpers.IEInterop
|
|||
// Calculate startLocation for the frames
|
||||
IHTMLWindow2 window2 = document2.parentWindow;
|
||||
IHTMLWindow3 window3 = (IHTMLWindow3) window2;
|
||||
Point contentWindowLocation = contentWindow.WindowRectangle.Location;
|
||||
NativePoint contentWindowLocation = contentWindow.WindowRectangle.Location;
|
||||
int x = window3.screenLeft - contentWindowLocation.X;
|
||||
int y = window3.screenTop - contentWindowLocation.Y;
|
||||
|
||||
// Release IHTMLWindow 2+3 com objects
|
||||
releaseCom(window2);
|
||||
releaseCom(window3);
|
||||
ReleaseCom(window2);
|
||||
ReleaseCom(window3);
|
||||
|
||||
_startLocation = new Point(x, y);
|
||||
_startLocation = new NativePoint(x, y);
|
||||
Init(document2, contentWindow);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
/// Helper method to release com objects
|
||||
/// </summary>
|
||||
/// <param name="comObject"></param>
|
||||
private void releaseCom(object comObject)
|
||||
private void ReleaseCom(object comObject)
|
||||
{
|
||||
if (comObject != null)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
int diffY = clientRectangle.Height - ClientHeight;
|
||||
// If there is a border around the inner window, the diff == 4
|
||||
// If there is a border AND a scrollbar the diff == 20
|
||||
if ((diffX == 4 || diffX >= 20) && (diffY == 4 || diffY >= 20))
|
||||
if (diffX is 4 or >= 20 && diffY is 4 or >= 20)
|
||||
{
|
||||
var viewportOffset = new NativePoint(2, 2);
|
||||
var viewportSize = new NativeSize(ClientWidth, ClientHeight);
|
||||
|
@ -193,9 +193,9 @@ namespace Greenshot.Helpers.IEInterop
|
|||
|
||||
LOG.DebugFormat("Zoomlevel {0}, {1}", _zoomLevelX, _zoomLevelY);
|
||||
// Release com objects
|
||||
releaseCom(window2);
|
||||
releaseCom(screen);
|
||||
releaseCom(screen2);
|
||||
ReleaseCom(window2);
|
||||
ReleaseCom(screen);
|
||||
ReleaseCom(screen2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -225,8 +225,8 @@ namespace Greenshot.Helpers.IEInterop
|
|||
LOG.Warn("Problem while trying to get document url!", e);
|
||||
}
|
||||
|
||||
_sourceLocation = new Point(ScaleX(_startLocation.X), ScaleY(_startLocation.Y));
|
||||
_destinationLocation = new Point(ScaleX(_startLocation.X), ScaleY(_startLocation.Y));
|
||||
_sourceLocation = new NativePoint(ScaleX(_startLocation.X), ScaleY(_startLocation.Y));
|
||||
_destinationLocation = new NativePoint(ScaleX(_startLocation.X), ScaleY(_startLocation.Y));
|
||||
|
||||
if (_parent != null)
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
}
|
||||
|
||||
// Clean up frameWindow
|
||||
releaseCom(frameWindow);
|
||||
ReleaseCom(frameWindow);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -263,7 +263,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
}
|
||||
|
||||
// Clean up collection
|
||||
releaseCom(frameCollection);
|
||||
ReleaseCom(frameCollection);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
{
|
||||
CorrectFrameLocations(frameElement);
|
||||
// Clean up frameElement
|
||||
releaseCom(frameElement);
|
||||
ReleaseCom(frameElement);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -294,7 +294,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Corrent the frame locations with the information
|
||||
/// Correct the frame locations with the information
|
||||
/// </summary>
|
||||
/// <param name="frameElement"></param>
|
||||
private void CorrectFrameLocations(IHTMLElement frameElement)
|
||||
|
@ -311,22 +311,22 @@ namespace Greenshot.Helpers.IEInterop
|
|||
// Release element, but prevent the frameElement to be released
|
||||
if (oldElement != null)
|
||||
{
|
||||
releaseCom(oldElement);
|
||||
ReleaseCom(oldElement);
|
||||
}
|
||||
|
||||
oldElement = element;
|
||||
} while (element != null);
|
||||
|
||||
Point elementLocation = new Point((int) x, (int) y);
|
||||
var elementLocation = new NativePoint((int) x, (int) y);
|
||||
IHTMLElement2 element2 = (IHTMLElement2) frameElement;
|
||||
IHTMLRect rec = element2.getBoundingClientRect();
|
||||
Point elementBoundingLocation = new Point(rec.left, rec.top);
|
||||
var elementBoundingLocation = new NativePoint(rec.left, rec.top);
|
||||
// Release IHTMLRect
|
||||
releaseCom(rec);
|
||||
ReleaseCom(rec);
|
||||
LOG.DebugFormat("Looking for iframe to correct at {0}", elementBoundingLocation);
|
||||
foreach (DocumentContainer foundFrame in _frames)
|
||||
{
|
||||
Point frameLocation = foundFrame.SourceLocation;
|
||||
NativePoint frameLocation = foundFrame.SourceLocation;
|
||||
if (frameLocation.Equals(elementBoundingLocation))
|
||||
{
|
||||
// Match found, correcting location
|
||||
|
@ -475,7 +475,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
var element = !_isDtd ? _document2.body : _document3.documentElement;
|
||||
element.setAttribute(attribute, value, 1);
|
||||
// Release IHTMLElement com object
|
||||
releaseCom(element);
|
||||
ReleaseCom(element);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -488,7 +488,7 @@ namespace Greenshot.Helpers.IEInterop
|
|||
var element = !_isDtd ? _document2.body : _document3.documentElement;
|
||||
var retVal = element.getAttribute(attribute, 1);
|
||||
// Release IHTMLElement com object
|
||||
releaseCom(element);
|
||||
ReleaseCom(element);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue