Will now save and default to the last format path that was entered.

This commit is contained in:
John Jenko 2020-02-21 19:09:08 +00:00
parent 9cbfb4cb84
commit c962d8785a
3 changed files with 32 additions and 10 deletions

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34209 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -22,5 +22,17 @@ namespace Formats.Properties {
return defaultInstance; return defaultInstance;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string FormatPath {
get {
return ((string)(this["FormatPath"]));
}
set {
this["FormatPath"] = value;
}
}
} }
} }

View File

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

View File

@ -18,11 +18,17 @@ namespace Formats
} }
private void SetDefaults() private void SetDefaults()
{
string savedFormatPath = Properties.Settings.Default.FormatPath ?? ""; // Get the last saved format copy path
if (savedFormatPath.Length > 0)
txbxPROMSFormatsPath.Text = savedFormatPath;
else
{ {
string curFolder = Environment.CurrentDirectory; // C:\development/PROMS/Formats/bin/debug string curFolder = Environment.CurrentDirectory; // C:\development/PROMS/Formats/bin/debug
int idx = curFolder.ToUpper().IndexOf(@"\PROMS\"); int idx = curFolder.ToUpper().IndexOf(@"\PROMS\");
txbxPROMSFormatsPath.Text = curFolder.Substring(0, idx); txbxPROMSFormatsPath.Text = curFolder.Substring(0, idx);
} }
}
// This will create the folders if they don't exist or clear the contents if they do. // This will create the folders if they don't exist or clear the contents if they do.
private void ClearOrCreateDestinationFolders(string path) private void ClearOrCreateDestinationFolders(string path)
@ -139,6 +145,8 @@ namespace Formats
if (fio.Exists && fio.IsReadOnly) fio.IsReadOnly = false; if (fio.Exists && fio.IsReadOnly) fio.IsReadOnly = false;
} }
} }
Properties.Settings.Default.FormatPath = txbxPROMSFormatsPath.Text.Substring(0,txbxPROMSFormatsPath.Text.Length-1); // save the copy format path minus the ending backslash
Properties.Settings.Default.Save();
if(MessageBox.Show("Do you want to end the Format Copier?","Formats Copied.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)Application.Exit(); if(MessageBox.Show("Do you want to end the Format Copier?","Formats Copied.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)Application.Exit();
} }