fix directory drag drop

This commit is contained in:
Jeremy Wu 2019-10-17 07:35:27 +11:00
parent 9ce94a8398
commit aa08125e43

View File

@ -116,22 +116,34 @@ namespace Wox.Plugin.Program.Views
private void programSourceView_Drop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
var directories = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files != null && files.Length > 0)
var directoriesToAdd = new List<ProgramSource>();
if (directories != null && directories.Length > 0)
{
foreach (string s in files)
foreach (string directory in directories)
{
if (Directory.Exists(s))
if (Directory.Exists(directory) && !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == directory))
{
_settings.ProgramSources.Add(new Settings.ProgramSource
var source = new ProgramSource
{
Location = s
});
Location = directory,
UniqueIdentifier = directory
};
ReIndexing();
directoriesToAdd.Add(source);
}
}
if (directoriesToAdd.Count() > 0)
{
directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
programSourceView.Items.Refresh();
ReIndexing();
}
}
}