private void _listView_PreviewDrop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
var result = ((string[])e.Data.GetData(DataFormats.FileDrop)).ToList();
Task.Run(() =>
{
if (_uploadAddIsRunning) return;
_uploadAddIsRunning = true;
Thread.CurrentThread.IsBackground = true;
try
{
var filePaths = new HashSet<string>();
foreach (var item in result)
{
if (File.Exists(item)) filePaths.Add(item);
else if (Directory.Exists(item)) filePaths.UnionWith(Directory.GetFiles(item, "*", SearchOption.AllDirectories));
}
foreach (var informaiton in _amoebaManager.ShareInformation)
{
filePaths.Remove((string)informaiton["Path"]);
}
this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
{
if (filePaths.Count == 1)
{
var window = new UploadWindow(filePaths.First(), false, _amoebaManager);
window.Owner = _mainWindow;
window.ShowDialog();
}
else if (filePaths.Count > 1)
{
var window = new UploadListWindow(filePaths, false, _amoebaManager);
window.Owner = _mainWindow;
window.ShowDialog();
}
}));
}
finally
{
_uploadAddIsRunning = false;
}
});
}