From a849562dfe992660b6067dbb2fb949922d1b31a3 Mon Sep 17 00:00:00 2001 From: Mihai Ciuraru Date: Thu, 29 Dec 2022 20:58:13 +0200 Subject: [PATCH] Fixed UI issue when changing Data folder --- ElegantRecorder/ElegantOptions.cs | 26 ++++++++++++++++++++++---- ElegantRecorder/ElegantRecorder.cs | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ElegantRecorder/ElegantOptions.cs b/ElegantRecorder/ElegantOptions.cs index bd7e8d4..72c0a1b 100644 --- a/ElegantRecorder/ElegantOptions.cs +++ b/ElegantRecorder/ElegantOptions.cs @@ -7,7 +7,8 @@ namespace ElegantRecorder public partial class ElegantOptions : Form { private ElegantRecorder App; - private Recording Rec; + + private Recording Rec = null; private int recordHotkeyData = 0; private int stopHotkeyData = 0; @@ -19,8 +20,11 @@ public ElegantOptions(ElegantRecorder elegantRecorder) App = elegantRecorder; TopMost = App.TopMost; - Rec = new Recording(App, App.CurrentRecordingName); - Rec.Load(); + if (App.CurrentRecordingName.Length > 0) + { + Rec = new Recording(App, App.CurrentRecordingName); + Rec.Load(); + } textBoxDataFolder.Text = App.Options.DataFolder; checkBoxPromptOverwrite.Checked = App.Options.PromptOverwrite; @@ -78,7 +82,11 @@ public void SaveOptions() App.Options.CurrRecName = textBoxCurrRecName.Text; App.Options.Save(App.ConfigFilePath); - Rec.Save(false); + + if (Rec != null) + { + Rec.Save(false); + } App.ReadRecordingHeaders(); } @@ -89,6 +97,8 @@ private void EnableControls() textBoxMouseMoveDelay.Enabled = checkBoxRecMouseMove.Checked; labelMinEventDelay.Enabled = checkBoxRecMouseMove.Checked; labelMs.Enabled = checkBoxRecMouseMove.Checked; + + groupBoxCurrentRec.Enabled = Rec != null; } private void ChangeAutomationEngine() @@ -118,9 +128,17 @@ private void buttonBrowseScript_Click(object sender, EventArgs e) { var dialog = new FolderBrowserDialog(); + var prevDataFolder = textBoxDataFolder.Text; + if (dialog.ShowDialog() == DialogResult.OK) { textBoxDataFolder.Text = dialog.SelectedPath; + + if (textBoxDataFolder.Text != prevDataFolder) + { + Rec = null; + EnableControls(); + } } } diff --git a/ElegantRecorder/ElegantRecorder.cs b/ElegantRecorder/ElegantRecorder.cs index fc11b5a..1a049b8 100644 --- a/ElegantRecorder/ElegantRecorder.cs +++ b/ElegantRecorder/ElegantRecorder.cs @@ -160,6 +160,7 @@ public void ReadRecordingHeaders() dataGridViewRecordings.Sort(new RowComparer(this)); dataGridViewRecordings.ClearSelection(); + CurrentRecordingName = ""; if (dataGridViewRecordings.Rows.Count > 0) {