mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00: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.Desktop.Overlays;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osuTK.Input;
|
|
||||||
using osu.Desktop.Updater;
|
using osu.Desktop.Updater;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -129,22 +128,20 @@ namespace osu.Desktop
|
|||||||
desktopGameWindow.CursorState |= CursorState.Hidden;
|
desktopGameWindow.CursorState |= CursorState.Hidden;
|
||||||
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
|
||||||
desktopGameWindow.Title = Name;
|
desktopGameWindow.Title = Name;
|
||||||
desktopGameWindow.FileDrop += fileDrop;
|
desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// SDL2 DesktopWindow
|
// SDL2 DesktopWindow
|
||||||
case DesktopWindow desktopWindow:
|
case DesktopWindow desktopWindow:
|
||||||
desktopWindow.CursorState.Value |= CursorState.Hidden;
|
desktopWindow.CursorState.Value |= CursorState.Hidden;
|
||||||
desktopWindow.Title = Name;
|
desktopWindow.Title = Name;
|
||||||
desktopWindow.FileDrop += fileDrop;
|
desktopWindow.DragDrop += f => fileDrop(new[] { f });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fileDrop(object sender, FileDropEventArgs e)
|
private void fileDrop(string[] filePaths)
|
||||||
{
|
{
|
||||||
var filePaths = e.FileNames;
|
|
||||||
|
|
||||||
var firstExtension = Path.GetExtension(filePaths.First());
|
var firstExtension = Path.GetExtension(filePaths.First());
|
||||||
|
|
||||||
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user