From c09188ff8ddd3526751a7172469d05c43a9bf603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hein=20Andre=20Gr=C3=B8nnestad?= Date: Tue, 15 Oct 2019 01:15:12 +0200 Subject: [PATCH] #12 Some improvements to drag and drop .PRG loading --- ComputerSystems/Commodore64/FormC64Screen.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ComputerSystems/Commodore64/FormC64Screen.cs b/ComputerSystems/Commodore64/FormC64Screen.cs index f66af31..cf5f46c 100644 --- a/ComputerSystems/Commodore64/FormC64Screen.cs +++ b/ComputerSystems/Commodore64/FormC64Screen.cs @@ -380,19 +380,23 @@ private void BtnReset_Click(object sender, EventArgs e) { C64.Cpu.Reset(); } - private void pScreen_DragDropAsync(object sender, DragEventArgs e) { + private async void pScreen_DragDropAsync(object sender, DragEventArgs e) { if (e.Data.GetData(DataFormats.FileDrop) is string[] d && d.Length > 0) { if (!File.Exists(d.First())) return; + await C64.Cpu.Pause(); LoadPrg(d.First()); - } + C64.Cpu.Resume(); - // TODO: Fix this hack - this.Focus(); - SendKeys.SendWait("r"); - SendKeys.SendWait("u"); - SendKeys.SendWait("n"); - SendKeys.SendWait("{ENTER}"); + // TODO: Fix this RUN hack + while (!Focused) { + Focus(); + } + SendKeys.SendWait("r"); + SendKeys.SendWait("u"); + SendKeys.SendWait("n"); + SendKeys.SendWait("{ENTER}"); + } } private void pScreen_DragEnter(object sender, DragEventArgs e) {