Skip to content

Commit

Permalink
[Windows] Improve drag-drop events (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jul 5, 2021
1 parent 43e1ac3 commit 313e257
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion windows/QMK Toolbox/Helpers/EmbeddedResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class EmbeddedResourceHelper
{
public static void ExtractResource(string file)
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"QMK_Toolbox.{file}"))
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"QMK_Toolbox.Resources.{file}"))
using (var filestream = new FileStream(Path.Combine(Application.LocalUserAppDataPath, file), FileMode.Create))
{
stream?.CopyTo(filestream);
Expand Down
18 changes: 14 additions & 4 deletions windows/QMK Toolbox/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ public MainWindow(string path) : this()
{
if (path != string.Empty)
{
if (Path.GetExtension(path)?.ToLower() == ".qmk" ||
Path.GetExtension(path)?.ToLower() == ".hex" ||
Path.GetExtension(path)?.ToLower() == ".bin")
var extension = Path.GetExtension(path)?.ToLower();
if (extension == ".qmk" || extension == ".hex" || extension == ".bin")
{
_filePassedIn = path;
}
Expand Down Expand Up @@ -660,7 +659,18 @@ private void MainWindow_DragDrop(object sender, DragEventArgs e)

private void MainWindow_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length == 1)
{
var extension = Path.GetExtension(files.First())?.ToLower();
if (extension == ".qmk" || extension == ".hex" || extension == ".bin")
{
e.Effect = DragDropEffects.Copy;
}
}
}
}

private void MainWindow_Shown(object sender, EventArgs e)
Expand Down

0 comments on commit 313e257

Please sign in to comment.