Skip to content

Commit

Permalink
Fixed UI issue when changing Data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaifm committed Dec 29, 2022
1 parent cf36bc7 commit a849562
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 22 additions & 4 deletions ElegantRecorder/ElegantOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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()
Expand Down Expand Up @@ -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();
}
}
}

Expand Down
1 change: 1 addition & 0 deletions ElegantRecorder/ElegantRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void ReadRecordingHeaders()
dataGridViewRecordings.Sort(new RowComparer(this));

dataGridViewRecordings.ClearSelection();
CurrentRecordingName = "";

if (dataGridViewRecordings.Rows.Count > 0)
{
Expand Down

0 comments on commit a849562

Please sign in to comment.