Holding ctrl while using image file tool will use last image file instead of opening file dialog

This commit is contained in:
Jaex 2018-02-22 13:27:54 +03:00
parent 8311c79ba8
commit 8f81068e07
3 changed files with 51 additions and 47 deletions

View file

@ -75,6 +75,7 @@ public class AnnotationOptions
// Image drawing
public ImageEditorInterpolationMode ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor;
public string LastImageFilePath { get; set; }
// Step drawing
public Color StepBorderColor { get; set; } = SecondaryColor;

View file

@ -35,15 +35,20 @@ public override void OnCreating()
Point pos = InputManager.ClientMousePosition;
Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
if (!OpenImageDialog(true))
if (Manager.IsCornerMoving && LoadImageFile(AnnotationOptions.LastImageFilePath, true))
{
Remove();
OnCreated();
Manager.IsMoving = true;
}
else
else if (OpenImageDialog(true))
{
OnCreated();
ShowNodes();
}
else
{
Remove();
}
}
public override void OnDoubleClicked()
@ -54,15 +59,20 @@ public override void OnDoubleClicked()
private bool OpenImageDialog(bool centerImage)
{
Manager.IsMoving = false;
string filepath = ImageHelpers.OpenImageFileDialog(Manager.Form);
return LoadImageFile(filepath, centerImage);
}
if (!string.IsNullOrEmpty(filepath))
private bool LoadImageFile(string filePath, bool centerImage)
{
Image img = ImageHelpers.LoadImage(filepath);
if (!string.IsNullOrEmpty(filePath))
{
Image img = ImageHelpers.LoadImage(filePath);
if (img != null)
{
AnnotationOptions.LastImageFilePath = filePath;
SetImage(img, centerImage);
return true;

View file

@ -50,7 +50,37 @@ public override void ShowNodes()
{
}
private void OpenStickerForm(bool creating)
public override void OnCreating()
{
Point pos = InputManager.ClientMousePosition;
Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
if (Manager.IsCornerMoving && LoadSticker(AnnotationOptions.LastStickerPath, AnnotationOptions.StickerSize))
{
OnCreated();
Manager.IsMoving = true;
}
else if (OpenStickerForm())
{
OnCreated();
}
else
{
Remove();
}
}
public override void OnDoubleClicked()
{
OpenStickerForm();
}
public override void Resize(int x, int y, bool fromBottomRight)
{
Move(x, y);
}
private bool OpenStickerForm()
{
Manager.Form.Pause();
@ -63,27 +93,16 @@ private void OpenStickerForm(bool creating)
AnnotationOptions.SelectedStickerPack = stickerForm.SelectedStickerPack;
AnnotationOptions.StickerSize = stickerForm.StickerSize;
if (LoadSticker(stickerForm.SelectedImageFile, stickerForm.StickerSize))
{
if (creating)
{
OnCreated();
return LoadSticker(stickerForm.SelectedImageFile, stickerForm.StickerSize);
}
return;
}
}
}
if (creating)
{
Remove();
}
}
finally
{
Manager.Form.Resume();
}
return false;
}
private bool LoadSticker(string filePath, int stickerSize)
@ -106,31 +125,5 @@ private bool LoadSticker(string filePath, int stickerSize)
return false;
}
public override void OnCreating()
{
Point pos = InputManager.ClientMousePosition;
Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
if (Manager.IsCornerMoving && LoadSticker(AnnotationOptions.LastStickerPath, AnnotationOptions.StickerSize))
{
OnCreated();
Manager.IsMoving = true;
}
else
{
OpenStickerForm(true);
}
}
public override void OnDoubleClicked()
{
OpenStickerForm(false);
}
public override void Resize(int x, int y, bool fromBottomRight)
{
Move(x, y);
}
}
}