mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-28 11:10:23 +12:00
Preserve screen location
This commit is contained in:
parent
d252c9345e
commit
ad35e2389c
|
@ -115,7 +115,7 @@ public static float GetCursorSizeMultiplier()
|
|||
|
||||
if (cursorSize != null && cursorSize > 1)
|
||||
{
|
||||
sizeMultiplier = 1f + (((int)cursorSize - 1) * 0.5f);
|
||||
sizeMultiplier = 1f + ((cursorSize.Value - 1) * 0.5f);
|
||||
}
|
||||
|
||||
return sizeMultiplier;
|
||||
|
|
|
@ -44,7 +44,7 @@ public static Bitmap GetRegionImage(RegionCaptureOptions options = null)
|
|||
}
|
||||
}
|
||||
|
||||
public static bool GetRectangleRegion(out Rectangle rect, RegionCaptureOptions options)
|
||||
public static bool GetRectangleRegion(out Rectangle rect, RegionCaptureOptions options = null)
|
||||
{
|
||||
return GetRectangleRegion(out rect, out _, options);
|
||||
}
|
||||
|
|
|
@ -1283,19 +1283,19 @@ public static void PinToScreen()
|
|||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
PinToScreen(form.Image);
|
||||
PinToScreen(form.Image, form.PinToScreenLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PinToScreen(Image image)
|
||||
public static void PinToScreen(Image image, Point? location = null)
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
PinToScreenOptions options = new PinToScreenOptions();
|
||||
options.BackgroundColor = ShareXResources.Theme.LightBackgroundColor;
|
||||
|
||||
PinToScreenForm form = new PinToScreenForm(image, options);
|
||||
PinToScreenForm form = new PinToScreenForm(image, options, location);
|
||||
form.Show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,13 +122,20 @@ private PinToScreenForm(PinToScreenOptions options)
|
|||
loaded = true;
|
||||
}
|
||||
|
||||
public PinToScreenForm(Image image, PinToScreenOptions options) : this(options)
|
||||
public PinToScreenForm(Image image, PinToScreenOptions options, Point? location = null) : this(options)
|
||||
{
|
||||
Image = image;
|
||||
AutoSizeForm();
|
||||
|
||||
Rectangle rectScreen = CaptureHelpers.GetActiveScreenWorkingArea();
|
||||
Location = Helpers.GetPosition(Options.Placement, Options.PlacementOffset, rectScreen.Size, ImageSize);
|
||||
if (location != null)
|
||||
{
|
||||
Location = location.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle rectScreen = CaptureHelpers.GetActiveScreenWorkingArea();
|
||||
Location = Helpers.GetPosition(Options.Placement, Options.PlacementOffset, rectScreen.Size, ImageSize);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace ShareX
|
|||
public partial class PinToScreenStartupForm : Form
|
||||
{
|
||||
public Bitmap Image { get; private set; }
|
||||
public Point? PinToScreenLocation { get; private set; }
|
||||
|
||||
public PinToScreenStartupForm()
|
||||
{
|
||||
|
@ -59,12 +60,17 @@ private void btnFromClipboard_Click(object sender, EventArgs e)
|
|||
|
||||
private void btnFromScreen_Click(object sender, EventArgs e)
|
||||
{
|
||||
Image = RegionCaptureTasks.GetRegionImage();
|
||||
|
||||
if (Image != null)
|
||||
if (RegionCaptureTasks.GetRectangleRegion(out Rectangle rect))
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
Image = new Screenshot().CaptureRectangle(rect);
|
||||
|
||||
if (Image != null)
|
||||
{
|
||||
PinToScreenLocation = rect.Location;
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue