diff --git a/App.config b/App.config new file mode 100644 index 0000000..164954a --- /dev/null +++ b/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/H5MotaUpdate.csproj b/H5MotaUpdate.csproj index b5d81a9..ddbd334 100644 --- a/H5MotaUpdate.csproj +++ b/H5MotaUpdate.csproj @@ -13,4 +13,19 @@ + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f60979d --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace H5MotaUpdate.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.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 LastSourceFolderPath { + get { + return ((string)(this["LastSourceFolderPath"])); + } + set { + this["LastSourceFolderPath"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string LastDestFolderPath { + get { + return ((string)(this["LastDestFolderPath"])); + } + set { + this["LastDestFolderPath"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..a29f701 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 9ff7680..948b40b 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -91,10 +91,17 @@ namespace H5MotaUpdate.ViewModels { using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { + // 设置初始路径为上一次选择的路径 + folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastSourceFolderPath; + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SourceRootDirectory = folderBrowserDialog.SelectedPath; + // 保存本次选择的路径 + Properties.Settings.Default.LastSourceFolderPath = SourceRootDirectory; + Properties.Settings.Default.Save(); } + VersionString = VersionUtils.GetVersion(SourceRootDirectory); } } @@ -106,9 +113,15 @@ namespace H5MotaUpdate.ViewModels { using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { + // 设置初始路径为上一次选择的路径 + folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastDestFolderPath; + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DestRootDirectory = folderBrowserDialog.SelectedPath; + // 保存本次选择的路径 + Properties.Settings.Default.LastDestFolderPath = DestRootDirectory; + Properties.Settings.Default.Save(); } } }