mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Add drag and drop from history window
Drag and drop of entries in history list view copies file to drop location. Closes #1550
This commit is contained in:
parent
cc6df4560c
commit
0b94f69b0e
2 changed files with 20 additions and 0 deletions
1
ShareX.HistoryLib/HistoryForm.Designer.cs
generated
1
ShareX.HistoryLib/HistoryForm.Designer.cs
generated
|
@ -99,6 +99,7 @@ private void InitializeComponent()
|
|||
this.lvHistory.Name = "lvHistory";
|
||||
this.lvHistory.UseCompatibleStateImageBehavior = false;
|
||||
this.lvHistory.View = System.Windows.Forms.View.Details;
|
||||
this.lvHistory.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvHistory_ItemDrag);
|
||||
this.lvHistory.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvHistory_ItemSelectionChanged);
|
||||
this.lvHistory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHistory_KeyDown);
|
||||
this.lvHistory.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHistory_MouseDoubleClick);
|
||||
|
|
|
@ -27,6 +27,7 @@ You should have received a copy of the GNU General Public License
|
|||
using ShareX.HistoryLib.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
@ -395,6 +396,24 @@ private void lvHistory_KeyDown(object sender, KeyEventArgs e)
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void lvHistory_ItemDrag(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
List<string> selection = new List<string>();
|
||||
|
||||
foreach (ListViewItem item in lvHistory.SelectedItems)
|
||||
{
|
||||
HistoryItem hi = (HistoryItem)item.Tag;
|
||||
if (File.Exists(hi.Filepath))
|
||||
selection.Add(hi.Filepath);
|
||||
}
|
||||
|
||||
if (selection.Count == 0)
|
||||
return;
|
||||
|
||||
DataObject data = new DataObject(DataFormats.FileDrop, selection.ToArray());
|
||||
DoDragDrop(data, DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void txtFilenameFilter_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
cbFilenameFilter.Checked = txtFilenameFilter.TextLength > 0;
|
||||
|
|
Loading…
Reference in a new issue