From 9dd92c1cb559e3f793498e66650f68e4d58ab5d9 Mon Sep 17 00:00:00 2001 From: KrossX Date: Mon, 29 Jul 2019 19:52:03 -0300 Subject: [PATCH] GSDumpGUI: Replace directory tree dialog. Also fix refresh on manual label change. --- tools/GSDumpGUI/Forms/frmMain.Designer.cs | 2 + tools/GSDumpGUI/Forms/frmMain.cs | 96 ++++++++++++++++------- 2 files changed, 70 insertions(+), 28 deletions(-) diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index c78631721e..0b0f3a7bd0 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -95,6 +95,7 @@ this.txtGSDXDirectory.Size = new System.Drawing.Size(243, 20); this.txtGSDXDirectory.TabIndex = 0; this.txtGSDXDirectory.TabStop = false; + this.txtGSDXDirectory.Enter += new System.EventHandler(this.txtGSDXDirectory_Enter); this.txtGSDXDirectory.Leave += new System.EventHandler(this.txtGSDXDirectory_Leave); // // lblDirectory @@ -144,6 +145,7 @@ this.txtDumpsDirectory.Size = new System.Drawing.Size(243, 20); this.txtDumpsDirectory.TabIndex = 3; this.txtDumpsDirectory.TabStop = false; + this.txtDumpsDirectory.Enter += new System.EventHandler(this.txtDumpsDirectory_Enter); this.txtDumpsDirectory.Leave += new System.EventHandler(this.txtDumpsDirectory_Leave); // // lstGSDX diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 9f6164d281..8caa1b948b 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -99,6 +99,8 @@ namespace GSDumpGUI private ConcurrentQueue watcher_events; + private string gsdx_path_old, dump_path_old; + public GSDumpGUI() { PortableXmlSettingsProvider.ApplyProvider(Settings); @@ -114,8 +116,8 @@ namespace GSDumpGUI _availableGsDumps.OnIndexUpdatedEvent += UpdatePreviewImage; - txtGSDXDirectory.DataBindings.Add(nameof(TextBox.Text), Settings, nameof(Settings.GSDXDir)); - txtDumpsDirectory.DataBindings.Add(nameof(TextBox.Text), Settings, nameof(Settings.DumpDir)); + txtGSDXDirectory.Text = Settings.GSDXDir; + txtDumpsDirectory.Text = Settings.DumpDir; BindListControl(lstDumps, _availableGsDumps, g => g.Files, f => f.DisplayText, g => g.SelectedFileIndex); BindListControl(lstGSDX, _availableGsDlls, g => g.Files, f => f.DisplayText, g => g.SelectedFileIndex); @@ -277,30 +279,46 @@ namespace GSDumpGUI private void cmdBrowseGSDX_Click(object sender, EventArgs e) { - FolderBrowserDialog fbd = new FolderBrowserDialog(); - fbd.Description = "Select the GSdx DLL Directory"; - fbd.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; - if (fbd.ShowDialog() == DialogResult.OK) - Settings.GSDXDir = fbd.SelectedPath; - Settings.Save(); - ReloadGsdxDlls(); + OpenFileDialog ofd = new OpenFileDialog(); + ofd.ValidateNames = false; + ofd.CheckFileExists = false; + ofd.CheckPathExists = true; + ofd.InitialDirectory = Settings.GSDXDir; + ofd.FileName = "Select Folder"; - // Auto select GSdx dll - _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + if(ofd.ShowDialog() == DialogResult.OK) + { + string newpath = Path.GetDirectoryName(ofd.FileName); + if (!Settings.GSDXDir.ToLower().Equals(newpath.ToLower())) + { + Settings.GSDXDir = newpath; + Settings.Save(); + ReloadGsdxDlls(); + _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + } + } } private void cmdBrowseDumps_Click(object sender, EventArgs e) { - FolderBrowserDialog fbd = new FolderBrowserDialog(); - fbd.Description = "Select the GSdx Dumps Directory"; - fbd.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; - if (fbd.ShowDialog() == DialogResult.OK) - Settings.DumpDir = fbd.SelectedPath; - Settings.Save(); - ReloadGsdxDumps(); + OpenFileDialog ofd = new OpenFileDialog(); + ofd.ValidateNames = false; + ofd.CheckFileExists = false; + ofd.CheckPathExists = true; + ofd.InitialDirectory = Settings.DumpDir; + ofd.FileName = "Select Folder"; - // Auto select GS dump - _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + if (ofd.ShowDialog() == DialogResult.OK) + { + string newpath = Path.GetDirectoryName(ofd.FileName); + if (!Settings.DumpDir.ToLower().Equals(newpath.ToLower())) + { + Settings.DumpDir = newpath; + Settings.Save(); + ReloadGsdxDumps(); + _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + } + } } private void cmdRun_Click(object sender, EventArgs e) @@ -479,22 +497,44 @@ namespace GSDumpGUI SelectedRad = Convert.ToInt32(itm.Tag); } + private void txtGSDXDirectory_Enter(object sender, EventArgs e) + { + gsdx_path_old = txtGSDXDirectory.Text; + } + + private void txtDumpsDirectory_Enter(object sender, EventArgs e) + { + dump_path_old = txtDumpsDirectory.Text; + } + private void txtGSDXDirectory_Leave(object sender, EventArgs e) { - Settings.Save(); - ReloadGsdxDlls(); + string newpath = txtGSDXDirectory.Text; - // Auto select GSdx dll - _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + if (!String.IsNullOrEmpty(newpath) && + !gsdx_path_old.ToLower().Equals(newpath.ToLower()) && + Directory.Exists(newpath)) + { + Settings.GSDXDir = newpath; + Settings.Save(); + ReloadGsdxDlls(); + _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + } } private void txtDumpsDirectory_Leave(object sender, EventArgs e) { - Settings.Save(); - ReloadGsdxDumps(); + string newpath = txtDumpsDirectory.Text; - // Auto select GS dump - _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + if (!String.IsNullOrEmpty(newpath) && + !dump_path_old.ToLower().Equals(newpath.ToLower()) && + Directory.Exists(newpath)) + { + Settings.DumpDir = newpath; + Settings.Save(); + ReloadGsdxDumps(); + _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + } } private void lstProcesses_SelectedIndexChanged(object sender, EventArgs e)