private void _listViewAddMenuItem_Click(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Multiselect = true;
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var filePaths = new HashSet<string>(dialog.FileNames);
Task.Run(() =>
{
if (_uploadAddIsRunning) return;
_uploadAddIsRunning = true;
Thread.CurrentThread.IsBackground = true;
try
{
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;
}
});
}
}