mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 19:54:13 +13:00
On image shape created or double clicked open image file dialog
This commit is contained in:
parent
0b0efdc129
commit
603ca595c1
2 changed files with 37 additions and 7 deletions
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
|
@ -35,18 +36,35 @@ public class ImageDrawingShape : BaseDrawingShape
|
|||
|
||||
public void SetImage(Image img)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
Image = img;
|
||||
SetImage(img, Rectangle.Location);
|
||||
}
|
||||
|
||||
public void SetImage(Image img, Point pos)
|
||||
{
|
||||
SetImage(img);
|
||||
Dispose();
|
||||
|
||||
Image = img;
|
||||
|
||||
if (Image != null)
|
||||
{
|
||||
Rectangle = new Rectangle(new Point(pos.X - Image.Width / 2, pos.Y - Image.Height / 2), Image.Size);
|
||||
Rectangle = new Rectangle(pos, Image.Size);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenImageDialog()
|
||||
{
|
||||
Manager.IsMoving = false;
|
||||
|
||||
string filepath = ImageHelpers.OpenImageFileDialog();
|
||||
|
||||
if (!string.IsNullOrEmpty(filepath))
|
||||
{
|
||||
Image img = ImageHelpers.LoadImage(filepath);
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
SetImage(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +76,16 @@ public override void OnDraw(Graphics g)
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnCreated()
|
||||
{
|
||||
OpenImageDialog();
|
||||
}
|
||||
|
||||
public override void OnDoubleClicked()
|
||||
{
|
||||
OpenImageDialog();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (Image != null)
|
||||
|
|
|
@ -136,7 +136,7 @@ public bool IsCurrentShapeTypeRegion
|
|||
}
|
||||
|
||||
public bool IsCreating { get; set; }
|
||||
public bool IsMoving { get; private set; }
|
||||
public bool IsMoving { get; set; }
|
||||
public bool IsResizing { get; set; }
|
||||
|
||||
public bool IsCornerMoving { get; private set; }
|
||||
|
@ -1717,7 +1717,9 @@ private void AddImageFromClipboard()
|
|||
{
|
||||
CurrentShapeType = ShapeType.DrawingImage;
|
||||
ImageDrawingShape shape = (ImageDrawingShape)CreateShape(ShapeType.DrawingImage);
|
||||
shape.SetImage(img, InputManager.MousePosition0Based);
|
||||
Point pos = InputManager.MousePosition0Based;
|
||||
Point shapePos = new Point(pos.X - img.Width / 2, pos.Y - img.Height / 2);
|
||||
shape.SetImage(img, shapePos);
|
||||
AddShape(shape);
|
||||
SelectCurrentShape();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue