Overhaul of installation workflow per issue #36
This commit is contained in:
parent
730484c28c
commit
c9b434daed
@ -37,7 +37,7 @@ namespace FileManager
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Configuration.Instance.Books))
|
if (string.IsNullOrWhiteSpace(Configuration.Instance.Books))
|
||||||
Configuration.Instance.Books = Path.Combine(Configuration.Instance.LibationFiles, "Books");
|
Configuration.Instance.Books = Path.Combine(Configuration.UserProfile, "Books");
|
||||||
return Directory.CreateDirectory(Configuration.Instance.Books).FullName;
|
return Directory.CreateDirectory(Configuration.Instance.Books).FullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,28 @@ namespace FileManager
|
|||||||
{
|
{
|
||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
// settings will be persisted when all are true
|
public bool LibationSettingsAreValid
|
||||||
// - property (not field)
|
=> File.Exists(APPSETTINGS_JSON)
|
||||||
// - string
|
&& SettingsFileIsValid(SettingsFilePath);
|
||||||
// - public getter
|
|
||||||
// - public setter
|
public static bool SettingsFileIsValid(string settingsFile)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.GetDirectoryName(settingsFile)) || !File.Exists(settingsFile))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var pDic = new PersistentDictionary(settingsFile, isReadOnly: true);
|
||||||
|
|
||||||
|
var booksDir = pDic.GetString(nameof(Books));
|
||||||
|
if (booksDir is null || !Directory.Exists(booksDir))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(pDic.GetString(nameof(InProgress))))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region persistent configuration settings/values
|
||||||
|
|
||||||
#region // properties to test reflection
|
#region // properties to test reflection
|
||||||
/*
|
/*
|
||||||
@ -33,16 +50,39 @@ namespace FileManager
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
// settings will be persisted when all are true
|
||||||
|
// - property (not field)
|
||||||
|
// - string
|
||||||
|
// - public getter
|
||||||
|
// - public setter
|
||||||
|
|
||||||
|
// note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app
|
||||||
|
|
||||||
|
// default setting and directory creation occur in class responsible for files.
|
||||||
|
// config class is only responsible for path. not responsible for setting defaults, dir validation, or dir creation
|
||||||
|
// exceptions: appsettings.json, LibationFiles dir, Settings.json
|
||||||
|
|
||||||
private PersistentDictionary persistentDictionary;
|
private PersistentDictionary persistentDictionary;
|
||||||
|
|
||||||
public bool FilesExist
|
public object GetObject(string propertyName) => persistentDictionary.GetObject(propertyName);
|
||||||
=> File.Exists(APPSETTINGS_JSON)
|
public void SetObject(string propertyName, object newValue) => persistentDictionary.Set(propertyName, newValue);
|
||||||
&& File.Exists(SettingsFilePath)
|
public void SetWithJsonPath(string jsonPath, string propertyName, string newValue) => persistentDictionary.SetWithJsonPath(jsonPath, propertyName, newValue);
|
||||||
&& Directory.Exists(LibationFiles)
|
|
||||||
&& Directory.Exists(Books);
|
|
||||||
|
|
||||||
public string SettingsFilePath => Path.Combine(LibationFiles, "Settings.json");
|
public string SettingsFilePath => Path.Combine(LibationFiles, "Settings.json");
|
||||||
|
|
||||||
|
public static string GetDescription(string propertyName)
|
||||||
|
{
|
||||||
|
var attribute = typeof(Configuration)
|
||||||
|
.GetProperty(propertyName)
|
||||||
|
?.GetCustomAttributes(typeof(DescriptionAttribute), true)
|
||||||
|
.SingleOrDefault()
|
||||||
|
as DescriptionAttribute;
|
||||||
|
|
||||||
|
return attribute?.Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(string propertyName) => persistentDictionary.Exists(propertyName);
|
||||||
|
|
||||||
[Description("Location for book storage. Includes destination of newly liberated books")]
|
[Description("Location for book storage. Includes destination of newly liberated books")]
|
||||||
public string Books
|
public string Books
|
||||||
{
|
{
|
||||||
@ -50,10 +90,34 @@ namespace FileManager
|
|||||||
set => persistentDictionary.Set(nameof(Books), value);
|
set => persistentDictionary.Set(nameof(Books), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// temp/working dir(s) should be outside of dropbox
|
||||||
|
[Description("Temporary location of files while they're in process of being downloaded and decrypted.\r\nWhen decryption is complete, the final file will be in Books location\r\nRecommend not using a folder which is backed up real time. Eg: Dropbox, iCloud, Google Drive")]
|
||||||
|
public string InProgress
|
||||||
|
{
|
||||||
|
get => persistentDictionary.GetString(nameof(InProgress));
|
||||||
|
set => persistentDictionary.Set(nameof(InProgress), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Description("Allow Libation for fix up audiobook metadata?")]
|
||||||
|
public bool AllowLibationFixup
|
||||||
|
{
|
||||||
|
get => persistentDictionary.Get<bool>(nameof(AllowLibationFixup));
|
||||||
|
set => persistentDictionary.Set(nameof(AllowLibationFixup), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Description("Decrypt to lossy format?")]
|
||||||
|
public bool DecryptToLossy
|
||||||
|
{
|
||||||
|
get => persistentDictionary.Get<bool>(nameof(DecryptToLossy));
|
||||||
|
set => persistentDictionary.Set(nameof(DecryptToLossy), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region known directories
|
#region known directories
|
||||||
public static string AppDir_Relative => @".\LibationFiles";
|
public static string AppDir_Relative => $@".\{LIBATION_FILES_KEY}";
|
||||||
public static string AppDir_Absolute => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), LIBATION_FILES_KEY));
|
public static string AppDir_Absolute => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), LIBATION_FILES_KEY));
|
||||||
public static string MyDocs => Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "LibationFiles"));
|
public static string MyDocs => Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Libation"));
|
||||||
public static string WinTemp => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation"));
|
public static string WinTemp => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation"));
|
||||||
public static string UserProfile => Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Libation"));
|
public static string UserProfile => Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Libation"));
|
||||||
|
|
||||||
@ -84,7 +148,8 @@ namespace FileManager
|
|||||||
(KnownDirectories.AppDir, () => AppDir_Relative),
|
(KnownDirectories.AppDir, () => AppDir_Relative),
|
||||||
(KnownDirectories.WinTemp, () => WinTemp),
|
(KnownDirectories.WinTemp, () => WinTemp),
|
||||||
(KnownDirectories.MyDocs, () => MyDocs),
|
(KnownDirectories.MyDocs, () => MyDocs),
|
||||||
// this is important to not let very early calls try to accidentally load LibationFiles too early
|
// this is important to not let very early calls try to accidentally load LibationFiles too early.
|
||||||
|
// also, keep this at bottom of this list
|
||||||
(KnownDirectories.LibationFiles, () => libationFilesPathCache)
|
(KnownDirectories.LibationFiles, () => libationFilesPathCache)
|
||||||
};
|
};
|
||||||
public static string GetKnownDirectoryPath(KnownDirectories directory)
|
public static string GetKnownDirectoryPath(KnownDirectories directory)
|
||||||
@ -98,41 +163,19 @@ namespace FileManager
|
|||||||
if (string.IsNullOrWhiteSpace(directory))
|
if (string.IsNullOrWhiteSpace(directory))
|
||||||
return KnownDirectories.None;
|
return KnownDirectories.None;
|
||||||
|
|
||||||
var dirFunc = directoryOptionsPaths.SingleOrDefault(dirFunc => dirFunc.getPathFunc() == directory);
|
// 'First' instead of 'Single' because LibationFiles could match other directories. eg: default value of LibationFiles == UserProfile.
|
||||||
|
// since it's a list, order matters and non-LibationFiles will be returned first
|
||||||
|
var dirFunc = directoryOptionsPaths.FirstOrDefault(dirFunc => dirFunc.getPathFunc() == directory);
|
||||||
return dirFunc == default ? KnownDirectories.None : dirFunc.directory;
|
return dirFunc == default ? KnownDirectories.None : dirFunc.directory;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// default setting and directory creation occur in class responsible for files.
|
#region singleton stuff
|
||||||
// config class is only responsible for path. not responsible for setting defaults, dir validation, or dir creation
|
|
||||||
// exceptions: appsettings.json, LibationFiles dir, Settings.json
|
|
||||||
|
|
||||||
// temp/working dir(s) should be outside of dropbox
|
|
||||||
[Description("Temporary location of files while they're in process of being downloaded and decrypted.\r\nWhen decryption is complete, the final file will be in Books location\r\nRecommend not using a folder which is backed up real time. Eg: Dropbox, iCloud, Google Drive")]
|
|
||||||
public string InProgress
|
|
||||||
{
|
|
||||||
get => persistentDictionary.GetString(nameof(InProgress));
|
|
||||||
set => persistentDictionary.Set(nameof(InProgress), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Description("Allow Libation for fix up audiobook metadata?")]
|
|
||||||
public bool AllowLibationFixup
|
|
||||||
{
|
|
||||||
get => persistentDictionary.Get<bool>(nameof(AllowLibationFixup));
|
|
||||||
set => persistentDictionary.Set(nameof(AllowLibationFixup), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Description("Decrypt to lossy format?")]
|
|
||||||
public bool DecryptToLossy
|
|
||||||
{
|
|
||||||
get => persistentDictionary.Get<bool>(nameof(DecryptToLossy));
|
|
||||||
set => persistentDictionary.Set(nameof(DecryptToLossy), value);
|
|
||||||
}
|
|
||||||
// note: any potential file manager static ctors can't compensate if storage dir is changed at run time via settings. this is partly bad architecture. but the side effect is desirable. if changing LibationFiles location: restart app
|
|
||||||
|
|
||||||
// singleton stuff
|
|
||||||
public static Configuration Instance { get; } = new Configuration();
|
public static Configuration Instance { get; } = new Configuration();
|
||||||
private Configuration() { }
|
private Configuration() { }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LibationFiles
|
||||||
|
|
||||||
private const string APPSETTINGS_JSON = "appsettings.json";
|
private const string APPSETTINGS_JSON = "appsettings.json";
|
||||||
private const string LIBATION_FILES_KEY = "LibationFiles";
|
private const string LIBATION_FILES_KEY = "LibationFiles";
|
||||||
@ -192,21 +235,6 @@ namespace FileManager
|
|||||||
return valueFinal;
|
return valueFinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetObject(string propertyName) => persistentDictionary.GetObject(propertyName);
|
|
||||||
public void SetObject(string propertyName, object newValue) => persistentDictionary.Set(propertyName, newValue);
|
|
||||||
public void SetWithJsonPath(string jsonPath, string propertyName, string newValue) => persistentDictionary.SetWithJsonPath(jsonPath, propertyName, newValue);
|
|
||||||
|
|
||||||
public static string GetDescription(string propertyName)
|
|
||||||
{
|
|
||||||
var attribute = typeof(Configuration)
|
|
||||||
.GetProperty(propertyName)
|
|
||||||
?.GetCustomAttributes(typeof(DescriptionAttribute), true)
|
|
||||||
.SingleOrDefault()
|
|
||||||
as DescriptionAttribute;
|
|
||||||
|
|
||||||
return attribute?.Description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TrySetLibationFiles(string directory)
|
public bool TrySetLibationFiles(string directory)
|
||||||
{
|
{
|
||||||
// this is WRONG. need to MOVE settings; not DELETE them
|
// this is WRONG. need to MOVE settings; not DELETE them
|
||||||
@ -236,5 +264,6 @@ namespace FileManager
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,14 +10,16 @@ namespace FileManager
|
|||||||
public class PersistentDictionary
|
public class PersistentDictionary
|
||||||
{
|
{
|
||||||
public string Filepath { get; }
|
public string Filepath { get; }
|
||||||
|
public bool IsReadOnly { get; }
|
||||||
|
|
||||||
// optimize for strings. expectation is most settings will be strings and a rare exception will be something else
|
// optimize for strings. expectation is most settings will be strings and a rare exception will be something else
|
||||||
private Dictionary<string, string> stringCache { get; } = new Dictionary<string, string>();
|
private Dictionary<string, string> stringCache { get; } = new Dictionary<string, string>();
|
||||||
private Dictionary<string, object> objectCache { get; } = new Dictionary<string, object>();
|
private Dictionary<string, object> objectCache { get; } = new Dictionary<string, object>();
|
||||||
|
|
||||||
public PersistentDictionary(string filepath)
|
public PersistentDictionary(string filepath, bool isReadOnly = false)
|
||||||
{
|
{
|
||||||
Filepath = filepath;
|
Filepath = filepath;
|
||||||
|
IsReadOnly = isReadOnly;
|
||||||
|
|
||||||
if (File.Exists(Filepath))
|
if (File.Exists(Filepath))
|
||||||
return;
|
return;
|
||||||
@ -25,6 +27,9 @@ namespace FileManager
|
|||||||
// will create any missing directories, incl subdirectories. if all already exist: no action
|
// will create any missing directories, incl subdirectories. if all already exist: no action
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(filepath));
|
Directory.CreateDirectory(Path.GetDirectoryName(filepath));
|
||||||
|
|
||||||
|
if (IsReadOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
File.WriteAllText(Filepath, "{}");
|
File.WriteAllText(Filepath, "{}");
|
||||||
System.Threading.Thread.Sleep(100);
|
System.Threading.Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
@ -34,7 +39,9 @@ namespace FileManager
|
|||||||
if (!stringCache.ContainsKey(propertyName))
|
if (!stringCache.ContainsKey(propertyName))
|
||||||
{
|
{
|
||||||
var jObject = readFile();
|
var jObject = readFile();
|
||||||
stringCache[propertyName] = jObject.ContainsKey(propertyName) ? jObject[propertyName].Value<string>() : null;
|
if (!jObject.ContainsKey(propertyName))
|
||||||
|
return null;
|
||||||
|
stringCache[propertyName] = jObject[propertyName].Value<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringCache[propertyName];
|
return stringCache[propertyName];
|
||||||
@ -42,10 +49,10 @@ namespace FileManager
|
|||||||
|
|
||||||
public T Get<T>(string propertyName)
|
public T Get<T>(string propertyName)
|
||||||
{
|
{
|
||||||
var o = GetObject(propertyName);
|
var obj = GetObject(propertyName);
|
||||||
if (o is null) return default;
|
if (obj is null) return default;
|
||||||
if (o is JToken jt) return jt.Value<T>();
|
if (obj is JToken jToken) return jToken.Value<T>();
|
||||||
return (T)o;
|
return (T)obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetObject(string propertyName)
|
public object GetObject(string propertyName)
|
||||||
@ -53,17 +60,21 @@ namespace FileManager
|
|||||||
if (!objectCache.ContainsKey(propertyName))
|
if (!objectCache.ContainsKey(propertyName))
|
||||||
{
|
{
|
||||||
var jObject = readFile();
|
var jObject = readFile();
|
||||||
objectCache[propertyName] = jObject.ContainsKey(propertyName) ? jObject[propertyName].Value<object>() : null;
|
if (!jObject.ContainsKey(propertyName))
|
||||||
|
return null;
|
||||||
|
objectCache[propertyName] = jObject[propertyName].Value<object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return objectCache[propertyName];
|
return objectCache[propertyName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Exists(string propertyName) => readFile().ContainsKey(propertyName);
|
||||||
|
|
||||||
private object locker { get; } = new object();
|
private object locker { get; } = new object();
|
||||||
public void Set(string propertyName, string newValue)
|
public void Set(string propertyName, string newValue)
|
||||||
{
|
{
|
||||||
// only do this check in string cache, NOT object cache
|
// only do this check in string cache, NOT object cache
|
||||||
if (stringCache[propertyName] == newValue)
|
if (stringCache.ContainsKey(propertyName) && stringCache[propertyName] == newValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set cache
|
// set cache
|
||||||
@ -83,6 +94,9 @@ namespace FileManager
|
|||||||
|
|
||||||
private void writeFile(string propertyName, JToken newValue)
|
private void writeFile(string propertyName, JToken newValue)
|
||||||
{
|
{
|
||||||
|
if (IsReadOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var str = newValue?.ToString();
|
var str = newValue?.ToString();
|
||||||
@ -113,6 +127,9 @@ namespace FileManager
|
|||||||
// special case: no caching. no logging
|
// special case: no caching. no logging
|
||||||
public void SetWithJsonPath(string jsonPath, string propertyName, string newValue)
|
public void SetWithJsonPath(string jsonPath, string propertyName, string newValue)
|
||||||
{
|
{
|
||||||
|
if (IsReadOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
var jObject = readFile();
|
var jObject = readFile();
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.1.10.24</Version>
|
<Version>5.1.10.42</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -26,200 +26,120 @@ namespace LibationLauncher
|
|||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
// must occur before access to Configuration instance
|
// must occur before access to Configuration instance
|
||||||
migrate_to_v5_2_0();
|
migrate_to_v5_2_0__pre_config();
|
||||||
|
|
||||||
createSettings();
|
|
||||||
|
//***********************************************//
|
||||||
|
// //
|
||||||
|
// do not use Configuration before this line //
|
||||||
|
// //
|
||||||
|
//***********************************************//
|
||||||
|
|
||||||
|
|
||||||
|
var config = Configuration.Instance;
|
||||||
|
|
||||||
|
createSettings(config);
|
||||||
|
|
||||||
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
||||||
|
|
||||||
migrate_to_v4_0_0();
|
migrate_to_v5_0_0(config);
|
||||||
migrate_to_v5_0_0();
|
migrate_to_v5_2_0__post_config(config);
|
||||||
|
|
||||||
ensureSerilogConfig();
|
ensureSerilogConfig(config);
|
||||||
configureLogging();
|
configureLogging(config);
|
||||||
checkForUpdate();
|
checkForUpdate(config);
|
||||||
logStartupState();
|
logStartupState(config);
|
||||||
|
|
||||||
Application.Run(new Form1());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createSettings()
|
private static void createSettings(Configuration config)
|
||||||
{
|
{
|
||||||
static bool configSetupIsComplete(Configuration config)
|
// all returns should be preceded by either:
|
||||||
=> config.FilesExist
|
// - if config.LibationSettingsAreValid
|
||||||
&& !string.IsNullOrWhiteSpace(config.InProgress);
|
// - error message, Exit()
|
||||||
|
|
||||||
var config = Configuration.Instance;
|
static void CancelInstallation()
|
||||||
if (configSetupIsComplete(config))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var isAdvanced = false;
|
|
||||||
|
|
||||||
var setupDialog = new SetupDialog();
|
|
||||||
setupDialog.NoQuestionsBtn_Click += (_, __) =>
|
|
||||||
{
|
{
|
||||||
config.InProgress ??= Configuration.WinTemp;
|
|
||||||
config.Books ??= Configuration.AppDir_Relative;
|
|
||||||
config.AllowLibationFixup = true;
|
|
||||||
};
|
|
||||||
// setupDialog.BasicBtn_Click += (_, __) => // no action needed
|
|
||||||
setupDialog.AdvancedBtn_Click += (_, __) => isAdvanced = true;
|
|
||||||
setupDialog.ShowDialog();
|
|
||||||
|
|
||||||
if (isAdvanced)
|
|
||||||
{
|
|
||||||
var dialog = new LibationFilesDialog();
|
|
||||||
if (dialog.ShowDialog() != DialogResult.OK)
|
|
||||||
MessageBox.Show("Libation Files location not changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configSetupIsComplete(config))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (new SettingsDialog().ShowDialog() == DialogResult.OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MessageBox.Show("Initial set up cancelled.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("Initial set up cancelled.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region v3 => v4 migration
|
if (config.LibationSettingsAreValid)
|
||||||
static string AccountsSettingsFileLegacy30 => Path.Combine(Configuration.Instance.LibationFiles, "IdentityTokens.json");
|
|
||||||
|
|
||||||
private static void migrate_to_v4_0_0()
|
|
||||||
{
|
|
||||||
migrateLegacyIdentityFile();
|
|
||||||
|
|
||||||
updateSettingsFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void migrateLegacyIdentityFile()
|
|
||||||
{
|
|
||||||
if (File.Exists(AccountsSettingsFileLegacy30))
|
|
||||||
{
|
|
||||||
// don't always rely on applicable POCOs. some is legacy and must be: json file => JObject
|
|
||||||
try
|
|
||||||
{
|
|
||||||
updateLegacyFileWithLocale();
|
|
||||||
|
|
||||||
var account = createAccountFromLegacySettings();
|
|
||||||
account.DecryptKey = getDecryptKey(account);
|
|
||||||
|
|
||||||
// the next few methods need persistence. to be a good citizen, dispose of persister at the end of current scope
|
|
||||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
|
||||||
persister.AccountsSettings.Add(account);
|
|
||||||
}
|
|
||||||
// migration is a convenience. if something goes wrong: just move on
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
// delete legacy token file
|
|
||||||
File.Delete(AccountsSettingsFileLegacy30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void updateLegacyFileWithLocale()
|
|
||||||
{
|
|
||||||
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
|
||||||
var legacyJObj = JObject.Parse(legacyContents);
|
|
||||||
|
|
||||||
// attempt to update legacy token file with locale from settings
|
|
||||||
if (!legacyJObj.ContainsKey("LocaleName"))
|
|
||||||
{
|
|
||||||
var settings = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
|
||||||
var settingsJObj = JObject.Parse(settings);
|
|
||||||
if (settingsJObj.TryGetValue("LocaleCountryCode", out var localeName))
|
|
||||||
{
|
|
||||||
// update legacy token file with locale from settings
|
|
||||||
legacyJObj.AddFirst(new JProperty("LocaleName", localeName.Value<string>()));
|
|
||||||
|
|
||||||
// save
|
|
||||||
var newContents = legacyJObj.ToString(Formatting.Indented);
|
|
||||||
File.WriteAllText(AccountsSettingsFileLegacy30, newContents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Account createAccountFromLegacySettings()
|
|
||||||
{
|
|
||||||
// get required locale from settings file
|
|
||||||
var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
|
||||||
if (!JObject.Parse(settingsContents).TryGetValue("LocaleCountryCode", out var jLocale))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var localeName = jLocale.Value<string>();
|
|
||||||
var locale = Localization.Get(localeName);
|
|
||||||
|
|
||||||
var api = EzApiCreator.GetApiAsync(locale, AccountsSettingsFileLegacy30).GetAwaiter().GetResult();
|
|
||||||
var email = api.GetEmailAsync().GetAwaiter().GetResult();
|
|
||||||
|
|
||||||
// identity has likely been updated above. re-get contents
|
|
||||||
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
|
||||||
|
|
||||||
var identity = Identity.FromJson(legacyContents);
|
|
||||||
|
|
||||||
if (!identity.IsValid)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var account = new Account(email)
|
|
||||||
{
|
|
||||||
AccountName = $"{email} - {locale.Name}",
|
|
||||||
LibraryScan = true,
|
|
||||||
IdentityTokens = identity
|
|
||||||
};
|
|
||||||
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string getDecryptKey(Account account)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(account?.DecryptKey))
|
|
||||||
return account.DecryptKey;
|
|
||||||
|
|
||||||
if (!File.Exists(Configuration.Instance.SettingsFilePath) || account is null)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
|
||||||
if (JObject.Parse(settingsContents).TryGetValue("DecryptKey", out var jToken))
|
|
||||||
return jToken.Value<string>() ?? "";
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void updateSettingsFile()
|
|
||||||
{
|
|
||||||
if (!File.Exists(Configuration.Instance.SettingsFilePath))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// use JObject to remove decrypt key and locale from Settings.json
|
var defaultLibationFilesDir = Configuration.UserProfile;
|
||||||
var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
|
||||||
var jObj = JObject.Parse(settingsContents);
|
|
||||||
|
|
||||||
var jLocale = jObj.Property("LocaleCountryCode");
|
// check for existing settigns in default location
|
||||||
var jDecryptKey = jObj.Property("DecryptKey");
|
var defaultSettingsFile = Path.Combine(defaultLibationFilesDir, "Settings.json");
|
||||||
|
if (Configuration.SettingsFileIsValid(defaultSettingsFile))
|
||||||
|
config.TrySetLibationFiles(defaultLibationFilesDir);
|
||||||
|
|
||||||
jDecryptKey?.Remove();
|
if (config.LibationSettingsAreValid)
|
||||||
jLocale?.Remove();
|
return;
|
||||||
|
|
||||||
if (jDecryptKey != null || jLocale != null)
|
var setupDialog = new SetupDialog();
|
||||||
|
if (setupDialog.ShowDialog() != DialogResult.OK)
|
||||||
{
|
{
|
||||||
var newContents = jObj.ToString(Formatting.Indented);
|
CancelInstallation();
|
||||||
File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setupDialog.IsNewUser)
|
||||||
|
config.TrySetLibationFiles(defaultLibationFilesDir);
|
||||||
|
else if (setupDialog.IsReturningUser)
|
||||||
|
{
|
||||||
|
var libationFilesDialog = new LibationFilesDialog();
|
||||||
|
|
||||||
|
if (libationFilesDialog.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
CancelInstallation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.TrySetLibationFiles(libationFilesDialog.SelectedDirectory);
|
||||||
|
if (config.LibationSettingsAreValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// path did not result in valid settings
|
||||||
|
MessageBox.Show(
|
||||||
|
$"No valid settings were found at this location.\r\nWould you like to create a new install settings in this folder?\r\n\r\n{libationFilesDialog.SelectedDirectory}",
|
||||||
|
"New install?",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question);
|
||||||
|
|
||||||
|
if (libationFilesDialog.ShowDialog() != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
CancelInstallation();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region migrate_to_v5_0_0 re-gegister device if device info not in settings
|
// if 'new user' was clicked, or if 'returning user' chose new install: show basic settings dialog
|
||||||
private static void migrate_to_v5_0_0()
|
config.Books ??= Path.Combine(defaultLibationFilesDir, "Books");
|
||||||
{
|
config.InProgress ??= Configuration.WinTemp;
|
||||||
var persistentDictionary = new PersistentDictionary(Configuration.Instance.SettingsFilePath);
|
config.AllowLibationFixup = true;
|
||||||
|
config.DecryptToLossy = false;
|
||||||
|
|
||||||
var config = Configuration.Instance;
|
if (new SettingsDialog().ShowDialog() != DialogResult.OK)
|
||||||
if (persistentDictionary.GetString(nameof(config.AllowLibationFixup)) is null)
|
|
||||||
{
|
{
|
||||||
persistentDictionary.Set(nameof(config.AllowLibationFixup), true);
|
CancelInstallation();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.LibationSettingsAreValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CancelInstallation();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region migrate_to_v5_0_0 re-register device if device info not in settings
|
||||||
|
private static void migrate_to_v5_0_0(Configuration config)
|
||||||
|
{
|
||||||
|
if (!config.Exists(nameof(config.AllowLibationFixup)))
|
||||||
|
config.AllowLibationFixup = true;
|
||||||
|
|
||||||
if (!File.Exists(AudibleApiStorage.AccountsSettingsFile))
|
if (!File.Exists(AudibleApiStorage.AccountsSettingsFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -258,8 +178,9 @@ namespace LibationLauncher
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region migrate to v5.2.0 : get rid of meta-directories, combine DownloadsInProgressEnum and DecryptInProgressEnum => InProgress
|
#region migrate to v5.2.0
|
||||||
private static void migrate_to_v5_2_0()
|
// get rid of meta-directories, combine DownloadsInProgressEnum and DecryptInProgressEnum => InProgress
|
||||||
|
private static void migrate_to_v5_2_0__pre_config()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
var settingsKey = "DownloadsInProgressEnum";
|
var settingsKey = "DownloadsInProgressEnum";
|
||||||
@ -290,12 +211,19 @@ namespace LibationLauncher
|
|||||||
"WinTemp" => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation")),
|
"WinTemp" => Path.GetFullPath(Path.Combine(Path.GetTempPath(), "Libation")),
|
||||||
_ => path
|
_ => path
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static void migrate_to_v5_2_0__post_config(Configuration config)
|
||||||
|
{
|
||||||
|
if (!config.Exists(nameof(config.AllowLibationFixup)))
|
||||||
|
config.AllowLibationFixup = true;
|
||||||
|
|
||||||
|
if (!config.Exists(nameof(config.DecryptToLossy)))
|
||||||
|
config.DecryptToLossy = false;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static void ensureSerilogConfig()
|
private static void ensureSerilogConfig(Configuration config)
|
||||||
{
|
{
|
||||||
var config = Configuration.Instance;
|
|
||||||
|
|
||||||
if (config.GetObject("Serilog") != null)
|
if (config.GetObject("Serilog") != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -348,10 +276,8 @@ namespace LibationLauncher
|
|||||||
config.SetObject("Serilog", serilogObj);
|
config.SetObject("Serilog", serilogObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configureLogging()
|
private static void configureLogging(Configuration config)
|
||||||
{
|
{
|
||||||
var config = Configuration.Instance;
|
|
||||||
|
|
||||||
// override path. always use current libation files
|
// override path. always use current libation files
|
||||||
var logPath = Path.Combine(Configuration.Instance.LibationFiles, "Log.log");
|
var logPath = Path.Combine(Configuration.Instance.LibationFiles, "Log.log");
|
||||||
config.SetWithJsonPath("Serilog.WriteTo[1].Args", "path", logPath);
|
config.SetWithJsonPath("Serilog.WriteTo[1].Args", "path", logPath);
|
||||||
@ -382,7 +308,7 @@ namespace LibationLauncher
|
|||||||
//Log.Logger.Here().Debug("Begin Libation. Debug with line numbers");
|
//Log.Logger.Here().Debug("Begin Libation. Debug with line numbers");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkForUpdate()
|
private static void checkForUpdate(Configuration config)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -439,10 +365,8 @@ namespace LibationLauncher
|
|||||||
MessageBox.Show($"{message}\r\nSee log for details");
|
MessageBox.Show($"{message}\r\nSee log for details");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logStartupState()
|
private static void logStartupState(Configuration config)
|
||||||
{
|
{
|
||||||
var config = Configuration.Instance;
|
|
||||||
|
|
||||||
// begin logging session with a form feed
|
// begin logging session with a form feed
|
||||||
Log.Logger.Information("\r\n\f");
|
Log.Logger.Information("\r\n\f");
|
||||||
Log.Logger.Information("Begin Libation. {@DebugInfo}", new
|
Log.Logger.Information("Begin Libation. {@DebugInfo}", new
|
||||||
|
|||||||
@ -9,9 +9,11 @@ namespace LibationWinForms.Dialogs
|
|||||||
{
|
{
|
||||||
public partial class DirectoryOrCustomSelectControl : UserControl
|
public partial class DirectoryOrCustomSelectControl : UserControl
|
||||||
{
|
{
|
||||||
|
public bool SelectedDirectoryIsKnown => knownDirectoryRb.Checked;
|
||||||
|
public bool SelectedDirectoryIsCustom => customDirectoryRb.Checked;
|
||||||
public string SelectedDirectory
|
public string SelectedDirectory
|
||||||
=> customDirectoryRb.Checked ? customTb.Text.Trim()
|
=> SelectedDirectoryIsKnown ? directorySelectControl.SelectedDirectory
|
||||||
: knownDirectoryRb.Checked ? directorySelectControl.SelectedDirectory
|
: SelectedDirectoryIsCustom ? customTb.Text.Trim()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
public DirectoryOrCustomSelectControl()
|
public DirectoryOrCustomSelectControl()
|
||||||
@ -25,8 +27,8 @@ namespace LibationWinForms.Dialogs
|
|||||||
/// <summary>Set items for combobox</summary>
|
/// <summary>Set items for combobox</summary>
|
||||||
/// <param name="knownDirectories">List rather than IEnumerable so that client can determine display order</param>
|
/// <param name="knownDirectories">List rather than IEnumerable so that client can determine display order</param>
|
||||||
/// <param name="defaultDirectory"></param>
|
/// <param name="defaultDirectory"></param>
|
||||||
public void SetDirectoryItems(List<Configuration.KnownDirectories> knownDirectories, Configuration.KnownDirectories? defaultDirectory = Configuration.KnownDirectories.UserProfile)
|
public void SetDirectoryItems(List<Configuration.KnownDirectories> knownDirectories, Configuration.KnownDirectories? defaultDirectory = Configuration.KnownDirectories.UserProfile, string subDirectory = null)
|
||||||
=> this.directorySelectControl.SetDirectoryItems(knownDirectories, defaultDirectory);
|
=> this.directorySelectControl.SetDirectoryItems(knownDirectories, defaultDirectory, subDirectory);
|
||||||
|
|
||||||
/// <summary>set selection</summary>
|
/// <summary>set selection</summary>
|
||||||
/// <param name="directory"></param>
|
/// <param name="directory"></param>
|
||||||
@ -41,7 +43,13 @@ namespace LibationWinForms.Dialogs
|
|||||||
public void SelectDirectory(string directory)
|
public void SelectDirectory(string directory)
|
||||||
{
|
{
|
||||||
directory = directory?.Trim() ?? "";
|
directory = directory?.Trim() ?? "";
|
||||||
selectDir(Configuration.GetKnownDirectory(directory), directory);
|
|
||||||
|
// remove SubDirectory setting to find known directories
|
||||||
|
var noSubDir = this.directorySelectControl.RemoveSubDirectoryFromPath(directory);
|
||||||
|
var knownDir = Configuration.GetKnownDirectory(noSubDir);
|
||||||
|
// DO NOT remove SubDirectory setting for custom
|
||||||
|
var customDir = directory;
|
||||||
|
selectDir(knownDir, customDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectDir(Configuration.KnownDirectories knownDir, string customDir)
|
private void selectDir(Configuration.KnownDirectories knownDir, string customDir)
|
||||||
|
|||||||
@ -13,14 +13,17 @@ namespace LibationWinForms.Dialogs
|
|||||||
{
|
{
|
||||||
public string Description { get; }
|
public string Description { get; }
|
||||||
public Configuration.KnownDirectories Value { get; }
|
public Configuration.KnownDirectories Value { get; }
|
||||||
|
private DirectorySelectControl _parentControl;
|
||||||
|
|
||||||
public string FullPath => Configuration.GetKnownDirectoryPath(Value);
|
public string FullPath => _parentControl.AddSubDirectoryToPath(Configuration.GetKnownDirectoryPath(Value));
|
||||||
|
|
||||||
/// <summary>Displaying relative paths is confusing. UI should display absolute equivalent</summary>
|
/// <summary>Displaying relative paths is confusing. UI should display absolute equivalent</summary>
|
||||||
public string UiDisplayPath => Value == Configuration.KnownDirectories.AppDir ? Configuration.AppDir_Absolute : FullPath;
|
public string UiDisplayPath => Value == Configuration.KnownDirectories.AppDir ? _parentControl.AddSubDirectoryToPath(Configuration.AppDir_Absolute) : FullPath;
|
||||||
|
|
||||||
public DirectoryComboBoxItem(Configuration.KnownDirectories knownDirectory)
|
public DirectoryComboBoxItem(DirectorySelectControl parentControl, Configuration.KnownDirectories knownDirectory)
|
||||||
{
|
{
|
||||||
|
_parentControl = parentControl;
|
||||||
|
|
||||||
Value = knownDirectory;
|
Value = knownDirectory;
|
||||||
Description = Value.GetDescription();
|
Description = Value.GetDescription();
|
||||||
}
|
}
|
||||||
@ -28,20 +31,42 @@ namespace LibationWinForms.Dialogs
|
|||||||
public override string ToString() => Description;
|
public override string ToString() => Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirectoryComboBoxItem selectedItem => (DirectoryComboBoxItem)this.directoryComboBox.SelectedItem;
|
|
||||||
public string SelectedDirectory => selectedItem?.FullPath;
|
public string SelectedDirectory => selectedItem?.FullPath;
|
||||||
|
|
||||||
|
private string _subDirectory;
|
||||||
|
internal string AddSubDirectoryToPath(string path) => string.IsNullOrWhiteSpace(_subDirectory) ? path : System.IO.Path.Combine(path, _subDirectory);
|
||||||
|
internal string RemoveSubDirectoryFromPath(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_subDirectory))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
path = path?.Trim() ?? "";
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
var bottomDir = System.IO.Path.GetFileName(path);
|
||||||
|
if (_subDirectory.EqualsInsensitive(bottomDir))
|
||||||
|
return System.IO.Path.GetDirectoryName(path);
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DirectoryComboBoxItem selectedItem => (DirectoryComboBoxItem)this.directoryComboBox.SelectedItem;
|
||||||
|
|
||||||
public DirectorySelectControl() => InitializeComponent();
|
public DirectorySelectControl() => InitializeComponent();
|
||||||
|
|
||||||
/// <summary>Set items for combobox</summary>
|
/// <summary>Set items for combobox</summary>
|
||||||
/// <param name="knownDirectories">List rather than IEnumerable so that client can determine display order</param>
|
/// <param name="knownDirectories">List rather than IEnumerable so that client can determine display order</param>
|
||||||
/// <param name="defaultDirectory">Optional default item to select</param>
|
/// <param name="defaultDirectory">Optional default item to select</param>
|
||||||
public void SetDirectoryItems(List<Configuration.KnownDirectories> knownDirectories, Configuration.KnownDirectories? defaultDirectory = null)
|
public void SetDirectoryItems(List<Configuration.KnownDirectories> knownDirectories, Configuration.KnownDirectories? defaultDirectory = null, string subDirectory = null)
|
||||||
{
|
{
|
||||||
|
// set this 1st so all DirectoryComboBoxItems can reference it
|
||||||
|
_subDirectory = subDirectory;
|
||||||
|
|
||||||
this.directoryComboBox.Items.Clear();
|
this.directoryComboBox.Items.Clear();
|
||||||
|
|
||||||
foreach (var dir in knownDirectories.Where(d => d != Configuration.KnownDirectories.None).Distinct())
|
foreach (var dir in knownDirectories.Where(d => d != Configuration.KnownDirectories.None).Distinct())
|
||||||
this.directoryComboBox.Items.Add(new DirectoryComboBoxItem(dir));
|
this.directoryComboBox.Items.Add(new DirectoryComboBoxItem(this, dir));
|
||||||
|
|
||||||
SelectDirectory(defaultDirectory);
|
SelectDirectory(defaultDirectory);
|
||||||
}
|
}
|
||||||
@ -49,7 +74,14 @@ namespace LibationWinForms.Dialogs
|
|||||||
/// <summary>set selection</summary>
|
/// <summary>set selection</summary>
|
||||||
/// <param name="directory"></param>
|
/// <param name="directory"></param>
|
||||||
/// <returns>True is there was a matching entry</returns>
|
/// <returns>True is there was a matching entry</returns>
|
||||||
public bool SelectDirectory(string directory) => SelectDirectory(Configuration.GetKnownDirectory(directory));
|
public bool SelectDirectory(string directory)
|
||||||
|
{
|
||||||
|
directory = directory?.Trim() ?? "";
|
||||||
|
|
||||||
|
var noSubDir = RemoveSubDirectoryFromPath(directory);
|
||||||
|
var knownDir = Configuration.GetKnownDirectory(noSubDir);
|
||||||
|
return SelectDirectory(knownDir);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>set selection</summary>
|
/// <summary>set selection</summary>
|
||||||
/// <param name="directory"></param>
|
/// <param name="directory"></param>
|
||||||
|
|||||||
@ -6,8 +6,7 @@ namespace LibationWinForms.Dialogs
|
|||||||
{
|
{
|
||||||
public partial class LibationFilesDialog : Form
|
public partial class LibationFilesDialog : Form
|
||||||
{
|
{
|
||||||
private Configuration config { get; } = Configuration.Instance;
|
public string SelectedDirectory { get; private set; }
|
||||||
private Func<string, string> desc { get; } = Configuration.GetDescription;
|
|
||||||
|
|
||||||
public LibationFilesDialog() => InitializeComponent();
|
public LibationFilesDialog() => InitializeComponent();
|
||||||
|
|
||||||
@ -16,7 +15,9 @@ namespace LibationWinForms.Dialogs
|
|||||||
if (this.DesignMode)
|
if (this.DesignMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libationFilesDescLbl.Text = desc(nameof(config.LibationFiles));
|
var config = Configuration.Instance;
|
||||||
|
|
||||||
|
libationFilesDescLbl.Text = Configuration.GetDescription(nameof(config.LibationFiles));
|
||||||
|
|
||||||
libationFilesSelectControl.SetSearchTitle("Libation Files");
|
libationFilesSelectControl.SetSearchTitle("Libation Files");
|
||||||
libationFilesSelectControl.SetDirectoryItems(new()
|
libationFilesSelectControl.SetDirectoryItems(new()
|
||||||
@ -31,12 +32,15 @@ namespace LibationWinForms.Dialogs
|
|||||||
private void saveBtn_Click(object sender, EventArgs e)
|
private void saveBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var libationDir = libationFilesSelectControl.SelectedDirectory;
|
var libationDir = libationFilesSelectControl.SelectedDirectory;
|
||||||
if (!config.TrySetLibationFiles(libationDir))
|
|
||||||
|
if (!System.IO.Directory.Exists(libationDir))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationDir);
|
MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationDir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectedDirectory = libationDir;
|
||||||
|
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
149
LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
149
LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
@ -28,44 +28,35 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.booksLocationLbl = new System.Windows.Forms.Label();
|
|
||||||
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
this.booksLocationDescLbl = new System.Windows.Forms.Label();
|
||||||
this.inProgressDescLbl = new System.Windows.Forms.Label();
|
this.inProgressDescLbl = new System.Windows.Forms.Label();
|
||||||
this.saveBtn = new System.Windows.Forms.Button();
|
this.saveBtn = new System.Windows.Forms.Button();
|
||||||
this.cancelBtn = new System.Windows.Forms.Button();
|
this.cancelBtn = new System.Windows.Forms.Button();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.advancedSettingsGb = new System.Windows.Forms.GroupBox();
|
||||||
|
this.convertLossyRb = new System.Windows.Forms.RadioButton();
|
||||||
|
this.convertLosslessRb = new System.Windows.Forms.RadioButton();
|
||||||
this.inProgressSelectControl = new LibationWinForms.Dialogs.DirectorySelectControl();
|
this.inProgressSelectControl = new LibationWinForms.Dialogs.DirectorySelectControl();
|
||||||
this.allowLibationFixupCbox = new System.Windows.Forms.CheckBox();
|
this.allowLibationFixupCbox = new System.Windows.Forms.CheckBox();
|
||||||
this.booksSelectControl = new LibationWinForms.Dialogs.DirectoryOrCustomSelectControl();
|
this.booksSelectControl = new LibationWinForms.Dialogs.DirectoryOrCustomSelectControl();
|
||||||
this.convertLosslessRb = new System.Windows.Forms.RadioButton();
|
this.booksGb = new System.Windows.Forms.GroupBox();
|
||||||
this.convertLossyRb = new System.Windows.Forms.RadioButton();
|
this.advancedSettingsGb.SuspendLayout();
|
||||||
this.groupBox1.SuspendLayout();
|
this.booksGb.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// booksLocationLbl
|
|
||||||
//
|
|
||||||
this.booksLocationLbl.AutoSize = true;
|
|
||||||
this.booksLocationLbl.Location = new System.Drawing.Point(13, 15);
|
|
||||||
this.booksLocationLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
|
||||||
this.booksLocationLbl.Name = "booksLocationLbl";
|
|
||||||
this.booksLocationLbl.Size = new System.Drawing.Size(85, 15);
|
|
||||||
this.booksLocationLbl.TabIndex = 0;
|
|
||||||
this.booksLocationLbl.Text = "Books location";
|
|
||||||
//
|
|
||||||
// booksLocationDescLbl
|
// booksLocationDescLbl
|
||||||
//
|
//
|
||||||
this.booksLocationDescLbl.AutoSize = true;
|
this.booksLocationDescLbl.AutoSize = true;
|
||||||
this.booksLocationDescLbl.Location = new System.Drawing.Point(106, 96);
|
this.booksLocationDescLbl.Location = new System.Drawing.Point(7, 19);
|
||||||
this.booksLocationDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
this.booksLocationDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.booksLocationDescLbl.Name = "booksLocationDescLbl";
|
this.booksLocationDescLbl.Name = "booksLocationDescLbl";
|
||||||
this.booksLocationDescLbl.Size = new System.Drawing.Size(39, 15);
|
this.booksLocationDescLbl.Size = new System.Drawing.Size(69, 15);
|
||||||
this.booksLocationDescLbl.TabIndex = 2;
|
this.booksLocationDescLbl.TabIndex = 2;
|
||||||
this.booksLocationDescLbl.Text = "[desc]";
|
this.booksLocationDescLbl.Text = "[book desc]";
|
||||||
//
|
//
|
||||||
// inProgressDescLbl
|
// inProgressDescLbl
|
||||||
//
|
//
|
||||||
this.inProgressDescLbl.AutoSize = true;
|
this.inProgressDescLbl.AutoSize = true;
|
||||||
this.inProgressDescLbl.Location = new System.Drawing.Point(10, 46);
|
this.inProgressDescLbl.Location = new System.Drawing.Point(8, 127);
|
||||||
this.inProgressDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
this.inProgressDescLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.inProgressDescLbl.Name = "inProgressDescLbl";
|
this.inProgressDescLbl.Name = "inProgressDescLbl";
|
||||||
this.inProgressDescLbl.Size = new System.Drawing.Size(43, 45);
|
this.inProgressDescLbl.Size = new System.Drawing.Size(43, 45);
|
||||||
@ -75,7 +66,7 @@
|
|||||||
// saveBtn
|
// saveBtn
|
||||||
//
|
//
|
||||||
this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.saveBtn.Location = new System.Drawing.Point(714, 268);
|
this.saveBtn.Location = new System.Drawing.Point(714, 380);
|
||||||
this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.saveBtn.Name = "saveBtn";
|
this.saveBtn.Name = "saveBtn";
|
||||||
this.saveBtn.Size = new System.Drawing.Size(88, 27);
|
this.saveBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
@ -88,7 +79,7 @@
|
|||||||
//
|
//
|
||||||
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.cancelBtn.Location = new System.Drawing.Point(832, 268);
|
this.cancelBtn.Location = new System.Drawing.Point(832, 380);
|
||||||
this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.cancelBtn.Name = "cancelBtn";
|
this.cancelBtn.Name = "cancelBtn";
|
||||||
this.cancelBtn.Size = new System.Drawing.Size(88, 27);
|
this.cancelBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
@ -97,35 +88,61 @@
|
|||||||
this.cancelBtn.UseVisualStyleBackColor = true;
|
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||||
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||||
//
|
//
|
||||||
// groupBox1
|
// advancedSettingsGb
|
||||||
//
|
//
|
||||||
this.groupBox1.Controls.Add(this.convertLossyRb);
|
this.advancedSettingsGb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
this.groupBox1.Controls.Add(this.convertLosslessRb);
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.groupBox1.Controls.Add(this.inProgressSelectControl);
|
this.advancedSettingsGb.Controls.Add(this.convertLossyRb);
|
||||||
this.groupBox1.Controls.Add(this.allowLibationFixupCbox);
|
this.advancedSettingsGb.Controls.Add(this.convertLosslessRb);
|
||||||
this.groupBox1.Controls.Add(this.inProgressDescLbl);
|
this.advancedSettingsGb.Controls.Add(this.inProgressSelectControl);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(19, 114);
|
this.advancedSettingsGb.Controls.Add(this.allowLibationFixupCbox);
|
||||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.advancedSettingsGb.Controls.Add(this.inProgressDescLbl);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.advancedSettingsGb.Location = new System.Drawing.Point(12, 141);
|
||||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.advancedSettingsGb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.groupBox1.Size = new System.Drawing.Size(902, 143);
|
this.advancedSettingsGb.Name = "advancedSettingsGb";
|
||||||
this.groupBox1.TabIndex = 3;
|
this.advancedSettingsGb.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.groupBox1.TabStop = false;
|
this.advancedSettingsGb.Size = new System.Drawing.Size(908, 226);
|
||||||
this.groupBox1.Text = "Advanced settings for control freaks";
|
this.advancedSettingsGb.TabIndex = 3;
|
||||||
|
this.advancedSettingsGb.TabStop = false;
|
||||||
|
this.advancedSettingsGb.Text = "Advanced settings for control freaks";
|
||||||
|
//
|
||||||
|
// convertLossyRb
|
||||||
|
//
|
||||||
|
this.convertLossyRb.AutoSize = true;
|
||||||
|
this.convertLossyRb.Location = new System.Drawing.Point(7, 88);
|
||||||
|
this.convertLossyRb.Name = "convertLossyRb";
|
||||||
|
this.convertLossyRb.Size = new System.Drawing.Size(242, 19);
|
||||||
|
this.convertLossyRb.TabIndex = 0;
|
||||||
|
this.convertLossyRb.Text = "Download my books as .MP3 files (Lossy)";
|
||||||
|
this.convertLossyRb.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// convertLosslessRb
|
||||||
|
//
|
||||||
|
this.convertLosslessRb.AutoSize = true;
|
||||||
|
this.convertLosslessRb.Checked = true;
|
||||||
|
this.convertLosslessRb.Location = new System.Drawing.Point(7, 63);
|
||||||
|
this.convertLosslessRb.Name = "convertLosslessRb";
|
||||||
|
this.convertLosslessRb.Size = new System.Drawing.Size(307, 19);
|
||||||
|
this.convertLosslessRb.TabIndex = 0;
|
||||||
|
this.convertLosslessRb.TabStop = true;
|
||||||
|
this.convertLosslessRb.Text = "Download books as .M4B files (Lossless Mp4a format)";
|
||||||
|
this.convertLosslessRb.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// inProgressSelectControl
|
// inProgressSelectControl
|
||||||
//
|
//
|
||||||
this.inProgressSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.inProgressSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.inProgressSelectControl.Location = new System.Drawing.Point(10, 94);
|
this.inProgressSelectControl.Location = new System.Drawing.Point(10, 175);
|
||||||
this.inProgressSelectControl.Name = "inProgressSelectControl";
|
this.inProgressSelectControl.Name = "inProgressSelectControl";
|
||||||
this.inProgressSelectControl.Size = new System.Drawing.Size(885, 46);
|
this.inProgressSelectControl.Size = new System.Drawing.Size(552, 46);
|
||||||
this.inProgressSelectControl.TabIndex = 2;
|
this.inProgressSelectControl.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// allowLibationFixupCbox
|
// allowLibationFixupCbox
|
||||||
//
|
//
|
||||||
this.allowLibationFixupCbox.AutoSize = true;
|
this.allowLibationFixupCbox.AutoSize = true;
|
||||||
this.allowLibationFixupCbox.Location = new System.Drawing.Point(10, 24);
|
this.allowLibationFixupCbox.Checked = true;
|
||||||
|
this.allowLibationFixupCbox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.allowLibationFixupCbox.Location = new System.Drawing.Point(7, 22);
|
||||||
this.allowLibationFixupCbox.Name = "allowLibationFixupCbox";
|
this.allowLibationFixupCbox.Name = "allowLibationFixupCbox";
|
||||||
this.allowLibationFixupCbox.Size = new System.Drawing.Size(262, 19);
|
this.allowLibationFixupCbox.Size = new System.Drawing.Size(262, 19);
|
||||||
this.allowLibationFixupCbox.TabIndex = 0;
|
this.allowLibationFixupCbox.TabIndex = 0;
|
||||||
@ -137,34 +154,23 @@
|
|||||||
//
|
//
|
||||||
this.booksSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.booksSelectControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.booksSelectControl.Location = new System.Drawing.Point(106, 12);
|
this.booksSelectControl.Location = new System.Drawing.Point(7, 37);
|
||||||
this.booksSelectControl.Name = "booksSelectControl";
|
this.booksSelectControl.Name = "booksSelectControl";
|
||||||
this.booksSelectControl.Size = new System.Drawing.Size(815, 81);
|
this.booksSelectControl.Size = new System.Drawing.Size(895, 81);
|
||||||
this.booksSelectControl.TabIndex = 1;
|
this.booksSelectControl.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// convertLosslessRb
|
// booksGb
|
||||||
//
|
//
|
||||||
this.convertLosslessRb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.booksGb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
this.convertLosslessRb.AutoSize = true;
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.convertLosslessRb.Checked = true;
|
this.booksGb.Controls.Add(this.booksSelectControl);
|
||||||
this.convertLosslessRb.Location = new System.Drawing.Point(692, 24);
|
this.booksGb.Controls.Add(this.booksLocationDescLbl);
|
||||||
this.convertLosslessRb.Name = "convertLosslessRb";
|
this.booksGb.Location = new System.Drawing.Point(12, 12);
|
||||||
this.convertLosslessRb.Size = new System.Drawing.Size(108, 19);
|
this.booksGb.Name = "booksGb";
|
||||||
this.convertLosslessRb.TabIndex = 0;
|
this.booksGb.Size = new System.Drawing.Size(908, 123);
|
||||||
this.convertLosslessRb.TabStop = true;
|
this.booksGb.TabIndex = 6;
|
||||||
this.convertLosslessRb.Text = "Mp4a (Lossless)";
|
this.booksGb.TabStop = false;
|
||||||
this.convertLosslessRb.UseVisualStyleBackColor = true;
|
this.booksGb.Text = "Books location";
|
||||||
//
|
|
||||||
// convertLossyRb
|
|
||||||
//
|
|
||||||
this.convertLossyRb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.convertLossyRb.AutoSize = true;
|
|
||||||
this.convertLossyRb.Location = new System.Drawing.Point(806, 24);
|
|
||||||
this.convertLossyRb.Name = "convertLossyRb";
|
|
||||||
this.convertLossyRb.Size = new System.Drawing.Size(89, 19);
|
|
||||||
this.convertLossyRb.TabIndex = 0;
|
|
||||||
this.convertLossyRb.Text = "Mp3 (Lossy)";
|
|
||||||
this.convertLossyRb.UseVisualStyleBackColor = true;
|
|
||||||
//
|
//
|
||||||
// SettingsDialog
|
// SettingsDialog
|
||||||
//
|
//
|
||||||
@ -172,37 +178,36 @@
|
|||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.CancelButton = this.cancelBtn;
|
this.CancelButton = this.cancelBtn;
|
||||||
this.ClientSize = new System.Drawing.Size(933, 309);
|
this.ClientSize = new System.Drawing.Size(933, 421);
|
||||||
this.Controls.Add(this.booksSelectControl);
|
this.Controls.Add(this.booksGb);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.advancedSettingsGb);
|
||||||
this.Controls.Add(this.cancelBtn);
|
this.Controls.Add(this.cancelBtn);
|
||||||
this.Controls.Add(this.saveBtn);
|
this.Controls.Add(this.saveBtn);
|
||||||
this.Controls.Add(this.booksLocationDescLbl);
|
|
||||||
this.Controls.Add(this.booksLocationLbl);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.Name = "SettingsDialog";
|
this.Name = "SettingsDialog";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Edit Settings";
|
this.Text = "Edit Settings";
|
||||||
this.Load += new System.EventHandler(this.SettingsDialog_Load);
|
this.Load += new System.EventHandler(this.SettingsDialog_Load);
|
||||||
this.groupBox1.ResumeLayout(false);
|
this.advancedSettingsGb.ResumeLayout(false);
|
||||||
this.groupBox1.PerformLayout();
|
this.advancedSettingsGb.PerformLayout();
|
||||||
|
this.booksGb.ResumeLayout(false);
|
||||||
|
this.booksGb.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.Label booksLocationLbl;
|
|
||||||
private System.Windows.Forms.Label booksLocationDescLbl;
|
private System.Windows.Forms.Label booksLocationDescLbl;
|
||||||
private System.Windows.Forms.Label inProgressDescLbl;
|
private System.Windows.Forms.Label inProgressDescLbl;
|
||||||
private System.Windows.Forms.Button saveBtn;
|
private System.Windows.Forms.Button saveBtn;
|
||||||
private System.Windows.Forms.Button cancelBtn;
|
private System.Windows.Forms.Button cancelBtn;
|
||||||
private System.Windows.Forms.GroupBox groupBox1;
|
private System.Windows.Forms.GroupBox advancedSettingsGb;
|
||||||
private System.Windows.Forms.CheckBox allowLibationFixupCbox;
|
private System.Windows.Forms.CheckBox allowLibationFixupCbox;
|
||||||
private DirectoryOrCustomSelectControl booksSelectControl;
|
private DirectoryOrCustomSelectControl booksSelectControl;
|
||||||
private DirectorySelectControl inProgressSelectControl;
|
private DirectorySelectControl inProgressSelectControl;
|
||||||
private System.Windows.Forms.RadioButton convertLossyRb;
|
private System.Windows.Forms.RadioButton convertLossyRb;
|
||||||
private System.Windows.Forms.RadioButton convertLosslessRb;
|
private System.Windows.Forms.RadioButton convertLosslessRb;
|
||||||
|
private System.Windows.Forms.GroupBox booksGb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,12 +21,15 @@ namespace LibationWinForms.Dialogs
|
|||||||
this.inProgressDescLbl.Text = desc(nameof(config.InProgress));
|
this.inProgressDescLbl.Text = desc(nameof(config.InProgress));
|
||||||
|
|
||||||
booksSelectControl.SetSearchTitle("books location");
|
booksSelectControl.SetSearchTitle("books location");
|
||||||
booksSelectControl.SetDirectoryItems(new()
|
booksSelectControl.SetDirectoryItems(
|
||||||
|
new()
|
||||||
{
|
{
|
||||||
Configuration.KnownDirectories.UserProfile,
|
Configuration.KnownDirectories.UserProfile,
|
||||||
Configuration.KnownDirectories.AppDir,
|
Configuration.KnownDirectories.AppDir,
|
||||||
Configuration.KnownDirectories.MyDocs
|
Configuration.KnownDirectories.MyDocs
|
||||||
}, Configuration.KnownDirectories.UserProfile);
|
},
|
||||||
|
Configuration.KnownDirectories.UserProfile,
|
||||||
|
"Books");
|
||||||
booksSelectControl.SelectDirectory(config.Books);
|
booksSelectControl.SelectDirectory(config.Books);
|
||||||
|
|
||||||
allowLibationFixupCbox.Checked = config.AllowLibationFixup;
|
allowLibationFixupCbox.Checked = config.AllowLibationFixup;
|
||||||
@ -54,12 +57,25 @@ namespace LibationWinForms.Dialogs
|
|||||||
config.InProgress = inProgressSelectControl.SelectedDirectory;
|
config.InProgress = inProgressSelectControl.SelectedDirectory;
|
||||||
|
|
||||||
var newBooks = booksSelectControl.SelectedDirectory;
|
var newBooks = booksSelectControl.SelectedDirectory;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(newBooks))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Cannot set Books Location to blank");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(newBooks))
|
if (!Directory.Exists(newBooks))
|
||||||
|
{
|
||||||
|
if (booksSelectControl.SelectedDirectoryIsCustom)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Not saving change to Books location. This folder does not exist:\r\n{newBooks}");
|
MessageBox.Show($"Not saving change to Books location. This folder does not exist:\r\n{newBooks}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (booksSelectControl.SelectedDirectoryIsKnown)
|
||||||
|
Directory.CreateDirectory(newBooks);
|
||||||
|
}
|
||||||
|
|
||||||
config.Books = newBooks;
|
config.Books = newBooks;
|
||||||
|
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
|
|||||||
73
LibationWinForms/Dialogs/SetupDialog.Designer.cs
generated
73
LibationWinForms/Dialogs/SetupDialog.Designer.cs
generated
@ -30,63 +30,57 @@
|
|||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupDialog));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupDialog));
|
||||||
this.welcomeLbl = new System.Windows.Forms.Label();
|
this.welcomeLbl = new System.Windows.Forms.Label();
|
||||||
this.noQuestionsBtn = new System.Windows.Forms.Button();
|
this.newUserBtn = new System.Windows.Forms.Button();
|
||||||
this.basicBtn = new System.Windows.Forms.Button();
|
this.returningUserBtn = new System.Windows.Forms.Button();
|
||||||
this.advancedBtn = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// welcomeLbl
|
// welcomeLbl
|
||||||
//
|
//
|
||||||
this.welcomeLbl.AutoSize = true;
|
this.welcomeLbl.AutoSize = true;
|
||||||
this.welcomeLbl.Location = new System.Drawing.Point(12, 9);
|
this.welcomeLbl.Location = new System.Drawing.Point(14, 10);
|
||||||
|
this.welcomeLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.welcomeLbl.Name = "welcomeLbl";
|
this.welcomeLbl.Name = "welcomeLbl";
|
||||||
this.welcomeLbl.Size = new System.Drawing.Size(399, 117);
|
this.welcomeLbl.Size = new System.Drawing.Size(449, 135);
|
||||||
this.welcomeLbl.TabIndex = 0;
|
this.welcomeLbl.TabIndex = 0;
|
||||||
this.welcomeLbl.Text = resources.GetString("welcomeLbl.Text");
|
this.welcomeLbl.Text = resources.GetString("welcomeLbl.Text");
|
||||||
//
|
//
|
||||||
// noQuestionsBtn
|
// newUserBtn
|
||||||
//
|
//
|
||||||
this.noQuestionsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
this.newUserBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.noQuestionsBtn.Location = new System.Drawing.Point(15, 129);
|
this.newUserBtn.Location = new System.Drawing.Point(18, 156);
|
||||||
this.noQuestionsBtn.Name = "noQuestionsBtn";
|
this.newUserBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.noQuestionsBtn.Size = new System.Drawing.Size(396, 57);
|
this.newUserBtn.Name = "newUserBtn";
|
||||||
this.noQuestionsBtn.TabIndex = 1;
|
this.newUserBtn.Size = new System.Drawing.Size(462, 66);
|
||||||
this.noQuestionsBtn.Text = "NO-QUESTIONS SETUP\r\n\r\nAccept all defaults";
|
this.newUserBtn.TabIndex = 2;
|
||||||
this.noQuestionsBtn.UseVisualStyleBackColor = true;
|
this.newUserBtn.Text = "NEW USER\r\n\r\nChoose settings";
|
||||||
|
this.newUserBtn.UseVisualStyleBackColor = true;
|
||||||
|
this.newUserBtn.Click += new System.EventHandler(this.newUserBtn_Click);
|
||||||
//
|
//
|
||||||
// basicBtn
|
// returningUserBtn
|
||||||
//
|
//
|
||||||
this.basicBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
this.returningUserBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.basicBtn.Location = new System.Drawing.Point(15, 192);
|
this.returningUserBtn.Location = new System.Drawing.Point(18, 228);
|
||||||
this.basicBtn.Name = "basicBtn";
|
this.returningUserBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.basicBtn.Size = new System.Drawing.Size(396, 57);
|
this.returningUserBtn.Name = "returningUserBtn";
|
||||||
this.basicBtn.TabIndex = 2;
|
this.returningUserBtn.Size = new System.Drawing.Size(462, 66);
|
||||||
this.basicBtn.Text = "BASIC SETUP\r\n\r\nChoose settings";
|
this.returningUserBtn.TabIndex = 3;
|
||||||
this.basicBtn.UseVisualStyleBackColor = true;
|
this.returningUserBtn.Text = "RETURNING USER\r\n\r\nI have previously installed Libation. This is an upgrade or re-" +
|
||||||
//
|
"install";
|
||||||
// advancedBtn
|
this.returningUserBtn.UseVisualStyleBackColor = true;
|
||||||
//
|
this.returningUserBtn.Click += new System.EventHandler(this.returningUserBtn_Click);
|
||||||
this.advancedBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.advancedBtn.Location = new System.Drawing.Point(15, 255);
|
|
||||||
this.advancedBtn.Name = "advancedBtn";
|
|
||||||
this.advancedBtn.Size = new System.Drawing.Size(396, 57);
|
|
||||||
this.advancedBtn.TabIndex = 3;
|
|
||||||
this.advancedBtn.Text = "ADVANCED SETUP\r\n\r\nChoose settings and where to store them";
|
|
||||||
this.advancedBtn.UseVisualStyleBackColor = true;
|
|
||||||
//
|
//
|
||||||
// SetupDialog
|
// SetupDialog
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(423, 324);
|
this.ClientSize = new System.Drawing.Size(493, 308);
|
||||||
this.Controls.Add(this.advancedBtn);
|
this.Controls.Add(this.returningUserBtn);
|
||||||
this.Controls.Add(this.basicBtn);
|
this.Controls.Add(this.newUserBtn);
|
||||||
this.Controls.Add(this.noQuestionsBtn);
|
|
||||||
this.Controls.Add(this.welcomeLbl);
|
this.Controls.Add(this.welcomeLbl);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.Name = "SetupDialog";
|
this.Name = "SetupDialog";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Welcome to Libation";
|
this.Text = "Welcome to Libation";
|
||||||
@ -98,8 +92,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Label welcomeLbl;
|
private System.Windows.Forms.Label welcomeLbl;
|
||||||
private System.Windows.Forms.Button noQuestionsBtn;
|
private System.Windows.Forms.Button newUserBtn;
|
||||||
private System.Windows.Forms.Button basicBtn;
|
private System.Windows.Forms.Button returningUserBtn;
|
||||||
private System.Windows.Forms.Button advancedBtn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,33 +5,25 @@ namespace LibationWinForms.Dialogs
|
|||||||
{
|
{
|
||||||
public partial class SetupDialog : Form
|
public partial class SetupDialog : Form
|
||||||
{
|
{
|
||||||
public event EventHandler NoQuestionsBtn_Click
|
public bool IsNewUser { get; private set; }
|
||||||
|
public bool IsReturningUser { get; private set; }
|
||||||
|
|
||||||
|
public SetupDialog() => InitializeComponent();
|
||||||
|
|
||||||
|
private void newUserBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
add => noQuestionsBtn.Click += value;
|
IsNewUser = true;
|
||||||
remove => noQuestionsBtn.Click -= value;
|
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler BasicBtn_Click
|
private void returningUserBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
add => basicBtn.Click += value;
|
IsReturningUser = true;
|
||||||
remove => basicBtn.Click -= value;
|
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler AdvancedBtn_Click
|
|
||||||
{
|
|
||||||
add => advancedBtn.Click += value;
|
|
||||||
remove => advancedBtn.Click -= value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SetupDialog()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
noQuestionsBtn.Click += btn_Click;
|
|
||||||
basicBtn.Click += btn_Click;
|
|
||||||
advancedBtn.Click += btn_Click;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btn_Click(object sender, EventArgs e) => Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,6 @@ After you make your selections, get started by importing your library.
|
|||||||
Go to Import > Scan Library
|
Go to Import > Scan Library
|
||||||
|
|
||||||
Download your entire library from the "Liberate" tab or
|
Download your entire library from the "Liberate" tab or
|
||||||
liberate your books one at a time by clicking the stoplight</value>
|
liberate your books one at a time by clicking the stoplight.</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@ -399,13 +399,20 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
private void advancedSettingsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void advancedSettingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var oldLocation = Configuration.Instance.LibationFiles;
|
var libationFilesDialog = new LibationFilesDialog();
|
||||||
new LibationFilesDialog().ShowDialog();
|
if (libationFilesDialog.ShowDialog() != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
// no change
|
// no change
|
||||||
if (System.IO.Path.GetFullPath(oldLocation).EqualsInsensitive(System.IO.Path.GetFullPath(Configuration.Instance.LibationFiles)))
|
if (System.IO.Path.GetFullPath(libationFilesDialog.SelectedDirectory).EqualsInsensitive(System.IO.Path.GetFullPath(Configuration.Instance.LibationFiles)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Configuration.Instance.TrySetLibationFiles(libationFilesDialog.SelectedDirectory))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationFilesDialog.SelectedDirectory);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox.Show(
|
MessageBox.Show(
|
||||||
"You have changed a file path important for this program. All files will remain in their original location; nothing will be moved. Libation must be restarted so these changes are handled correctly.",
|
"You have changed a file path important for this program. All files will remain in their original location; nothing will be moved. Libation must be restarted so these changes are handled correctly.",
|
||||||
"Closing Libation",
|
"Closing Libation",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user