mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:23:02 +08:00
Implement file drop with DragDrop event
This commit is contained in:
parent
b89dcb6a77
commit
fca6a6d69f
@ -10,7 +10,6 @@ using Microsoft.Win32;
|
||||
using osu.Desktop.Overlays;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game;
|
||||
using osuTK.Input;
|
||||
using osu.Desktop.Updater;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Logging;
|
||||
@ -129,22 +128,20 @@ namespace osu.Desktop
|
||||
desktopGameWindow.CursorState |= CursorState.Hidden;
|
||||
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
||||
desktopGameWindow.Title = Name;
|
||||
desktopGameWindow.FileDrop += fileDrop;
|
||||
desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames);
|
||||
break;
|
||||
|
||||
// SDL2 DesktopWindow
|
||||
case DesktopWindow desktopWindow:
|
||||
desktopWindow.CursorState.Value |= CursorState.Hidden;
|
||||
desktopWindow.Title = Name;
|
||||
desktopWindow.FileDrop += fileDrop;
|
||||
desktopWindow.DragDrop += f => fileDrop(new[] { f });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void fileDrop(object sender, FileDropEventArgs e)
|
||||
private void fileDrop(string[] filePaths)
|
||||
{
|
||||
var filePaths = e.FileNames;
|
||||
|
||||
var firstExtension = Path.GetExtension(filePaths.First());
|
||||
|
||||
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
||||
|
Loading…
Reference in New Issue
Block a user