Add settings for quick reload last path

Hold shift and click the open button
This commit is contained in:
Kurt 2020-03-28 15:31:55 -07:00
parent 20f2a655b1
commit a25a77d9a1
4 changed files with 78 additions and 4 deletions

View File

@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Windows.Forms;
using NHSE.Core;
using NHSE.WinForms.Properties;
namespace NHSE.WinForms
{
@ -41,6 +43,19 @@ private void Main_DragDrop(object sender, DragEventArgs e)
private void Menu_Open(object sender, EventArgs e)
{
if ((ModifierKeys & Keys.Control) != 0)
{
// Detect save file from SD cards?
}
else if ((ModifierKeys & Keys.Shift) != 0)
{
var path = Settings.Default.LastFilePath;
if (Directory.Exists(path))
{
Open(path);
return;
}
}
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
Open(fbd.SelectedPath);
@ -48,14 +63,14 @@ private void Menu_Open(object sender, EventArgs e)
private static void Open(string path)
{
if ((ModifierKeys & Keys.Control) != 0)
{
// Detect save file from SD cards?
}
try
{
var file = new HorizonSave(path);
Open(file);
var settings = Settings.Default;
settings.LastFilePath = path;
settings.Save();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)

View File

@ -34,6 +34,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(Configuration)' == 'Release'">
@ -47,4 +52,11 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace NHSE.WinForms.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastFilePath {
get {
return ((string)(this["LastFilePath"]));
}
set {
this["LastFilePath"] = value;
}
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="NHSE.WinForms.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="LastFilePath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>