Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Improve drag-drop events #272

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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