2018-01-10 01:15:57 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2022-01-12 05:32:17 +13:00
|
|
|
|
Copyright (c) 2007-2022 ShareX Team
|
2018-01-10 01:15:57 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
using ShareX.HelpersLib;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
|
|
|
|
public class ImageFileDrawingShape : ImageDrawingShape
|
|
|
|
|
{
|
|
|
|
|
public override void OnCreating()
|
|
|
|
|
{
|
2022-02-20 19:30:39 +13:00
|
|
|
|
PointF pos = Manager.Form.ScaledClientMousePosition;
|
|
|
|
|
Rectangle = new RectangleF(pos.X, pos.Y, 1, 1);
|
2018-01-10 01:15:57 +13:00
|
|
|
|
|
2018-04-09 21:10:19 +12:00
|
|
|
|
if (Manager.IsCtrlModifier && LoadImageFile(AnnotationOptions.LastImageFilePath, true))
|
2018-01-10 01:15:57 +13:00
|
|
|
|
{
|
2018-02-22 23:27:54 +13:00
|
|
|
|
OnCreated();
|
|
|
|
|
Manager.IsMoving = true;
|
2018-01-10 01:15:57 +13:00
|
|
|
|
}
|
2018-02-22 23:27:54 +13:00
|
|
|
|
else if (OpenImageDialog(true))
|
2018-01-10 01:15:57 +13:00
|
|
|
|
{
|
|
|
|
|
OnCreated();
|
|
|
|
|
ShowNodes();
|
|
|
|
|
}
|
2018-02-22 23:27:54 +13:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Remove();
|
|
|
|
|
}
|
2018-01-10 01:15:57 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnDoubleClicked()
|
|
|
|
|
{
|
|
|
|
|
OpenImageDialog(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool OpenImageDialog(bool centerImage)
|
|
|
|
|
{
|
|
|
|
|
Manager.IsMoving = false;
|
2018-03-17 08:46:34 +13:00
|
|
|
|
Manager.Form.Pause();
|
2022-01-05 20:44:18 +13:00
|
|
|
|
string filePath = ImageHelpers.OpenImageFileDialog(Manager.Form);
|
2018-03-17 08:46:34 +13:00
|
|
|
|
Manager.Form.Resume();
|
2022-01-05 20:44:18 +13:00
|
|
|
|
return LoadImageFile(filePath, centerImage);
|
2018-02-22 23:27:54 +13:00
|
|
|
|
}
|
2018-01-10 01:15:57 +13:00
|
|
|
|
|
2018-02-22 23:27:54 +13:00
|
|
|
|
private bool LoadImageFile(string filePath, bool centerImage)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
2018-01-10 01:15:57 +13:00
|
|
|
|
{
|
2020-03-22 12:22:43 +13:00
|
|
|
|
Bitmap bmp = ImageHelpers.LoadImage(filePath);
|
2018-01-10 01:15:57 +13:00
|
|
|
|
|
2020-03-22 12:22:43 +13:00
|
|
|
|
if (bmp != null)
|
2018-01-10 01:15:57 +13:00
|
|
|
|
{
|
2018-02-22 23:27:54 +13:00
|
|
|
|
AnnotationOptions.LastImageFilePath = filePath;
|
|
|
|
|
|
2020-03-22 12:22:43 +13:00
|
|
|
|
SetImage(bmp, centerImage);
|
2018-01-10 01:15:57 +13:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|