Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
tmokmss committed May 27, 2018
1 parent 64f81a8 commit 0c22e98
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions Osu2Saber/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,20 @@ private void ModelChanged(object sender, PropertyChangedEventArgs e)

public void DragOver(IDropInfo dropInfo)
{
var dragFileList = ((DataObject)dropInfo.Data).GetFileDropList().Cast<string>();
dropInfo.Effects = dragFileList.Any(item =>
{
var extension = Path.GetExtension(item);
return extension != null && extension.Equals(".zip");
}) ? DragDropEffects.Copy : DragDropEffects.None;
var files = ((DataObject)dropInfo.Data).GetFileDropList().Cast<string>();
dropInfo.Effects = files.Any(fname => fname.EndsWith(".zip"))
? DragDropEffects.Copy : DragDropEffects.None;
}

public void Drop(IDropInfo dropInfo)
{
var dragFileList = ((DataObject)dropInfo.Data).GetFileDropList().Cast<string>()
var files = ((DataObject)dropInfo.Data).GetFileDropList().Cast<string>()
.Where(fname => fname.EndsWith(".zip") || fname.EndsWith(".osz"))
.ToList();
//dropInfo.Effects = dragFileList.Any(item =>
//{
// var extension = Path.GetExtension(item);
// return extension != null && extension.Equals(".zip");
//}) ? DragDropEffects.Copy : DragDropEffects.None;

if (dragFileList.Count == 0) return;
if (files.Count == 0) return;

foreach (var file in dragFileList)
foreach (var file in files)
{
OszFiles.Add(file);
}
Expand Down

0 comments on commit 0c22e98

Please sign in to comment.