mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Drag n drop support to image effects
This commit is contained in:
parent
9d42b58cb7
commit
d4eada44b1
2 changed files with 47 additions and 0 deletions
2
ImageEffectsLib/ImageEffectsForm.Designer.cs
generated
2
ImageEffectsLib/ImageEffectsForm.Designer.cs
generated
|
@ -249,6 +249,8 @@ private void InitializeComponent()
|
||||||
this.pbResult.Name = "pbResult";
|
this.pbResult.Name = "pbResult";
|
||||||
this.pbResult.Size = new System.Drawing.Size(688, 448);
|
this.pbResult.Size = new System.Drawing.Size(688, 448);
|
||||||
this.pbResult.TabIndex = 11;
|
this.pbResult.TabIndex = 11;
|
||||||
|
this.pbResult.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbResult_DragDrop);
|
||||||
|
this.pbResult.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbResult_DragEnter);
|
||||||
//
|
//
|
||||||
// ImageEffectsForm
|
// ImageEffectsForm
|
||||||
//
|
//
|
||||||
|
|
|
@ -57,6 +57,7 @@ public ImageEffectsForm(Image img, List<ImageEffect> effects = null)
|
||||||
|
|
||||||
public void EditorMode()
|
public void EditorMode()
|
||||||
{
|
{
|
||||||
|
pbResult.AllowDrop = true;
|
||||||
btnLoadImage.Visible = true;
|
btnLoadImage.Visible = true;
|
||||||
btnSaveImage.Visible = true;
|
btnSaveImage.Visible = true;
|
||||||
}
|
}
|
||||||
|
@ -340,6 +341,9 @@ private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||||
{
|
{
|
||||||
|
ofd.Title = "Browse for images...";
|
||||||
|
ofd.Filter = "Image files (*.jpg, *.jpeg, *.png, *.gif, *.bmp)|*.jpg;*.jpeg;*.png;*.gif;*.bmp";
|
||||||
|
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (DefaultImage != null) DefaultImage.Dispose();
|
if (DefaultImage != null) DefaultImage.Dispose();
|
||||||
|
@ -366,6 +370,47 @@ private void btnSaveImage_Click(object sender, EventArgs e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pbResult_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) || e.Data.GetDataPresent(DataFormats.Bitmap, false))
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pbResult_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
|
||||||
|
{
|
||||||
|
string[] files = e.Data.GetData(DataFormats.FileDrop, false) as string[];
|
||||||
|
|
||||||
|
if (files != null && files.Length > 0)
|
||||||
|
{
|
||||||
|
if (Helpers.IsImageFile(files[0]))
|
||||||
|
{
|
||||||
|
if (DefaultImage != null) DefaultImage.Dispose();
|
||||||
|
DefaultImage = Helpers.GetImageFromFile(files[0]);
|
||||||
|
UpdatePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (e.Data.GetDataPresent(DataFormats.Bitmap, false))
|
||||||
|
{
|
||||||
|
Image img = e.Data.GetData(DataFormats.Bitmap, false) as Image;
|
||||||
|
|
||||||
|
if (img != null)
|
||||||
|
{
|
||||||
|
if (DefaultImage != null) DefaultImage.Dispose();
|
||||||
|
DefaultImage = img;
|
||||||
|
UpdatePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void btnOK_Click(object sender, EventArgs e)
|
private void btnOK_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Effects = GetImageEffects();
|
Effects = GetImageEffects();
|
||||||
|
|
Loading…
Reference in a new issue