diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index 2883e9b6c..80b792908 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -464,6 +464,18 @@ public static Point GetPosition(ContentAlignment placement, int offset, Size bac return GetPosition(placement, new Point(offset, offset), backgroundSize, objectSize); } + public static Point GetPosition(ContentAlignment placement, int offset, Rectangle background, Size objectSize) + { + return GetPosition(placement, new Point(offset, offset), background, objectSize); + } + + public static Point GetPosition(ContentAlignment placement, Point offset, Rectangle background, Size objectSize) + { + Point position = GetPosition(placement, offset, background.Size, objectSize); + + return new Point(background.X + position.X, background.Y + position.Y); + } + public static Point GetPosition(ContentAlignment placement, Point offset, Size backgroundSize, Size objectSize) { int midX = (int)Math.Round((backgroundSize.Width / 2f) - (objectSize.Width / 2f)); diff --git a/ShareX/Forms/DropForm.cs b/ShareX/Forms/DropForm.cs index 4e56f1a08..0e68f483f 100644 --- a/ShareX/Forms/DropForm.cs +++ b/ShareX/Forms/DropForm.cs @@ -70,7 +70,7 @@ private DropForm(int size, int offset, ContentAlignment alignment, int opacity, backgroundImage = DrawDropImage(DropSize); - Location = Helpers.GetPosition(DropAlignment, DropOffset, Screen.PrimaryScreen.WorkingArea.Size, backgroundImage.Size); + Location = Helpers.GetPosition(DropAlignment, DropOffset, Screen.PrimaryScreen.WorkingArea, backgroundImage.Size); SelectBitmap(backgroundImage, DropOpacity); } diff --git a/ShareX/Forms/NotificationForm.cs b/ShareX/Forms/NotificationForm.cs index c832bbeb0..32bd0d24e 100644 --- a/ShareX/Forms/NotificationForm.cs +++ b/ShareX/Forms/NotificationForm.cs @@ -136,10 +136,10 @@ public void LoadConfig(NotificationFormConfig config) buffer = new Bitmap(Config.Size.Width, Config.Size.Height); gBuffer = Graphics.FromImage(buffer); - Point position = Helpers.GetPosition(Config.Placement, Config.Offset, Screen.PrimaryScreen.WorkingArea.Size, Config.Size); + Point position = Helpers.GetPosition(Config.Placement, Config.Offset, Screen.PrimaryScreen.WorkingArea, Config.Size); - NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, position.X + Screen.PrimaryScreen.WorkingArea.X, - position.Y + Screen.PrimaryScreen.WorkingArea.Y, Config.Size.Width, Config.Size.Height, SetWindowPosFlags.SWP_NOACTIVATE); + NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, position.X, position.Y, Config.Size.Width, Config.Size.Height, + SetWindowPosFlags.SWP_NOACTIVATE); tDuration.Stop(); tOpacity.Stop(); diff --git a/ShareX/Tools/PinToScreen/PinToScreenForm.cs b/ShareX/Tools/PinToScreen/PinToScreenForm.cs index 81e135ac2..4594947b4 100644 --- a/ShareX/Tools/PinToScreen/PinToScreenForm.cs +++ b/ShareX/Tools/PinToScreen/PinToScreenForm.cs @@ -140,9 +140,7 @@ private PinToScreenForm(Image image, PinToScreenOptions options, Point? location } else { - Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenWorkingArea(); - Point position = Helpers.GetPosition(Options.Placement, Options.PlacementOffset, rectActiveScreen.Size, ImageSize); - Location = new Point(rectActiveScreen.X + position.X, rectActiveScreen.Y + position.Y); + Location = Helpers.GetPosition(Options.Placement, Options.PlacementOffset, CaptureHelpers.GetActiveScreenWorkingArea(), ImageSize); } }