From 9bd1736fec19276ae521e66e466ea689032d84ea Mon Sep 17 00:00:00 2001 From: N00MKRAD <61149547+n00mkrad@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:07:43 +0100 Subject: [PATCH] Fix dragndrop cursor getting stuck when main thread is busy --- CodeLegacy/Forms/Main/Form1.cs | 13 +++++++------ CodeLegacy/Forms/PromptForm.cs | 7 ------- CodeLegacy/Main/InterpolateUtils.cs | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/CodeLegacy/Forms/Main/Form1.cs b/CodeLegacy/Forms/Main/Form1.cs index bdcbc7f..fb22a81 100644 --- a/CodeLegacy/Forms/Main/Form1.cs +++ b/CodeLegacy/Forms/Main/Form1.cs @@ -674,12 +674,14 @@ namespace Flowframes.Forms.Main private void Form1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; } - private void Form1_DragDrop(object sender, DragEventArgs e) + private async void Form1_DragDrop(object sender, DragEventArgs e) { - DragDropHandler((string[])e.Data.GetData(DataFormats.FileDrop)); + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + await Task.Delay(1); // Release drop + DragDropHandler(files); } - public void DragDropHandler(string[] files) + public void DragDropHandler(string[] files, bool first = true) { if (Program.busy) return; @@ -689,13 +691,12 @@ namespace Flowframes.Forms.Main { SetTab(interpOptsTab.Name); queueBtn_Click(null, null); - if (BatchProcessing.currentBatchForm != null) - BatchProcessing.currentBatchForm.LoadDroppedPaths(files, start); + BatchProcessing.currentBatchForm?.LoadDroppedPaths(files, start); } else { SetTab(interpOptsTab.Name); - Logger.Log("Selected video/directory: " + Path.GetFileName(files[0]), true); + Logger.Log($"Selected video/directory: {Path.GetFileName(files[0])}", true); inputTbox.Text = files[0]; bool resume = Directory.Exists(files[0]) && IoUtils.GetAmountOfFiles(Path.Combine(files[0], Paths.resumeDir), true, "*.json") > 0; diff --git a/CodeLegacy/Forms/PromptForm.cs b/CodeLegacy/Forms/PromptForm.cs index 3e9d7e8..b7ac395 100644 --- a/CodeLegacy/Forms/PromptForm.cs +++ b/CodeLegacy/Forms/PromptForm.cs @@ -1,11 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace Flowframes.Forms diff --git a/CodeLegacy/Main/InterpolateUtils.cs b/CodeLegacy/Main/InterpolateUtils.cs index 5b57046..24ac736 100644 --- a/CodeLegacy/Main/InterpolateUtils.cs +++ b/CodeLegacy/Main/InterpolateUtils.cs @@ -381,8 +381,8 @@ namespace Flowframes.Main public static Fraction AskForFramerate(string mediaName, bool isImageSequence = true) { - string text = $"Please enter an input frame rate to use for{(isImageSequence ? " the image sequence" : "")} '{mediaName.Trunc(80)}'."; - PromptForm form = new PromptForm("Enter Frame Rate", text, "15"); + string text = $"Please enter the source frame rate for{(isImageSequence ? " the image sequence" : "")} '{mediaName.Trunc(80)}'."; + var form = new PromptForm("Enter Frame Rate", text, "15"); form.ShowDialog(); return new Fraction(form.EnteredText); }