fixed #1023: Added drag file from main window support

This commit is contained in:
Jaex 2016-04-24 01:15:35 +03:00
parent 1838519e23
commit a6603f3e1a
2 changed files with 24 additions and 3 deletions

View file

@ -297,7 +297,9 @@ private void InitializeComponent()
this.lvUploads.ShowItemToolTips = true;
this.lvUploads.UseCompatibleStateImageBehavior = false;
this.lvUploads.View = System.Windows.Forms.View.Details;
this.lvUploads.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvUploads_ItemDrag);
this.lvUploads.SelectedIndexChanged += new System.EventHandler(this.lvUploads_SelectedIndexChanged);
this.lvUploads.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.lvUploads_QueryContinueDrag);
this.lvUploads.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvUploads_KeyDown);
this.lvUploads.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvUploads_MouseDoubleClick);
this.lvUploads.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvUploads_MouseUp);

View file

@ -31,6 +31,7 @@ You should have received a copy of the GNU General Public License
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@ -796,15 +797,14 @@ private WorkerTask[] GetCurrentTasks()
private TaskInfo GetCurrentUploadInfo()
{
TaskInfo info = null;
WorkerTask[] tasks = GetCurrentTasks();
if (tasks != null && tasks.Length > 0)
{
info = tasks[0].Info;
return tasks[0].Info;
}
return info;
return null;
}
private void RemoveSelectedItems()
@ -1276,6 +1276,25 @@ private void lvUploads_KeyDown(object sender, KeyEventArgs e)
e.Handled = true;
}
private void lvUploads_ItemDrag(object sender, ItemDragEventArgs e)
{
TaskInfo task = GetCurrentUploadInfo();
if (task != null && !string.IsNullOrEmpty(task.FilePath) && File.Exists(task.FilePath))
{
AllowDrop = false;
lvUploads.DoDragDrop(new DataObject(DataFormats.FileDrop, new string[] { task.FilePath }), DragDropEffects.Copy);
}
}
private void lvUploads_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
if (e.Action != DragAction.Continue)
{
AllowDrop = true;
}
}
#region Tray events
private void timerTraySingleClick_Tick(object sender, EventArgs e)