diff --git a/Source/FileLiberator/ConvertToMp3.cs b/Source/FileLiberator/ConvertToMp3.cs index 6b6be041..ae795c64 100644 --- a/Source/FileLiberator/ConvertToMp3.cs +++ b/Source/FileLiberator/ConvertToMp3.cs @@ -81,6 +81,9 @@ namespace FileLiberator extension: "mp3", Configuration.Instance.OverwriteExisting); + SetFileTime(libraryBook, realMp3Path); + SetDirectoryTime(libraryBook, Path.GetDirectoryName(realMp3Path)); + OnFileCreated(libraryBook, realMp3Path); } } diff --git a/Source/FileLiberator/DownloadDecryptBook.cs b/Source/FileLiberator/DownloadDecryptBook.cs index 26cdf82b..5f0902aa 100644 --- a/Source/FileLiberator/DownloadDecryptBook.cs +++ b/Source/FileLiberator/DownloadDecryptBook.cs @@ -99,8 +99,12 @@ namespace FileLiberator } finally { - if (moveFilesTask.IsCompletedSuccessfully) - await Task.Run(() => libraryBook.UpdateBookStatus(LiberatedStatus.Liberated, Configuration.LibationVersion)); + if (moveFilesTask.IsCompletedSuccessfully) + { + await Task.Run(() => libraryBook.UpdateBookStatus(LiberatedStatus.Liberated, Configuration.LibationVersion)); + + SetDirectoryTime(libraryBook, finalStorageDir); + } } return new StatusHandler(); @@ -366,8 +370,9 @@ namespace FileLiberator Path.Combine(destinationDir, Path.GetFileName(entry.Path)), Configuration.Instance.ReplacementCharacters, overwrite: Configuration.Instance.OverwriteExisting); - - FilePathCache.Insert(libraryBook.Book.AudibleProductId, realDest); + + SetFileTime(libraryBook, realDest); + FilePathCache.Insert(libraryBook.Book.AudibleProductId, realDest); // propagate corrected path. Must update cache with corrected path. Also want updated path for cue file (after this for-loop) entries[i] = entry with { Path = realDest }; @@ -375,7 +380,10 @@ namespace FileLiberator var cue = entries.FirstOrDefault(f => f.FileType == FileType.Cue); if (cue != default) + { Cue.UpdateFileName(cue.Path, getFirstAudioFile(entries).Path); + SetFileTime(libraryBook, cue.Path); + } AudibleFileStorage.Audio.Refresh(); } @@ -408,7 +416,10 @@ namespace FileLiberator var picBytes = PictureStorage.GetPictureSynchronously(new(libraryBook.Book.PictureLarge ?? libraryBook.Book.PictureId, PictureSize.Native)); if (picBytes.Length > 0) + { File.WriteAllBytes(coverPath, picBytes); + SetFileTime(libraryBook, coverPath); + } } catch (Exception ex) { diff --git a/Source/FileLiberator/DownloadPdf.cs b/Source/FileLiberator/DownloadPdf.cs index 8fe19a12..1e7f325a 100644 --- a/Source/FileLiberator/DownloadPdf.cs +++ b/Source/FileLiberator/DownloadPdf.cs @@ -30,6 +30,11 @@ namespace FileLiberator var actualDownloadedFilePath = await downloadPdfAsync(libraryBook, proposedDownloadFilePath); var result = verifyDownload(actualDownloadedFilePath); + if (result.IsSuccess) + { + SetFileTime(libraryBook, actualDownloadedFilePath); + SetDirectoryTime(libraryBook, Path.GetDirectoryName(actualDownloadedFilePath)); + } libraryBook.UpdatePdfStatus(result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated); return result; diff --git a/Source/FileLiberator/Processable.cs b/Source/FileLiberator/Processable.cs index 49ecd61b..724c0cdc 100644 --- a/Source/FileLiberator/Processable.cs +++ b/Source/FileLiberator/Processable.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; using DataLayer; @@ -98,5 +99,26 @@ namespace FileLiberator Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Completed), Book = libraryBook.LogFriendly() }); Completed?.Invoke(this, libraryBook); } - } + + protected static void SetFileTime(LibraryBook libraryBook, string file) + => setFileSystemTime(libraryBook, new FileInfo(file)); + protected static void SetDirectoryTime(LibraryBook libraryBook, string file) + => setFileSystemTime(libraryBook, new DirectoryInfo(file)); + + private static void setFileSystemTime(LibraryBook libraryBook, FileSystemInfo fileInfo) + { + if (!fileInfo.Exists) return; + + fileInfo.CreationTimeUtc = getTimeValue(Configuration.Instance.CreationTime) ?? fileInfo.CreationTimeUtc; + fileInfo.LastWriteTimeUtc = getTimeValue(Configuration.Instance.LastWriteTime) ?? fileInfo.LastWriteTimeUtc; + + DateTime? getTimeValue(Configuration.DateTimeSource source) => source switch + { + Configuration.DateTimeSource.Added => libraryBook.DateAdded, + Configuration.DateTimeSource.Published => libraryBook.Book.DatePublished, + _ => null, + }; + } + + } } diff --git a/Source/LibationAvalonia/Controls/Settings/Important.axaml b/Source/LibationAvalonia/Controls/Settings/Important.axaml index 2c0af107..528dbb56 100644 --- a/Source/LibationAvalonia/Controls/Settings/Important.axaml +++ b/Source/LibationAvalonia/Controls/Settings/Important.axaml @@ -13,7 +13,7 @@ Grid.Row="0" Margin="5" Label="Books Location"> - + + + + + + + + + + + + + diff --git a/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs b/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs index d1546e38..02987538 100644 --- a/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs +++ b/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs @@ -1,9 +1,11 @@ -using Avalonia.Collections; +using AAXClean; +using Avalonia.Collections; using Avalonia.Controls; using Dinah.Core; using LibationFileManager; using LibationUiBase; using ReactiveUI; +using System; using System.Linq; namespace LibationAvalonia.ViewModels.Settings @@ -19,21 +21,11 @@ namespace LibationAvalonia.ViewModels.Settings private int _lameBitrate; private int _lameVBRQuality; private string _chapterTitleTemplate; - public SampleRateSelection SelectedSampleRate { get; set; } + public EnumDiaplay SelectedSampleRate { get; set; } public NAudio.Lame.EncoderQuality SelectedEncoderQuality { get; set; } - public AvaloniaList SampleRates { get; } - = new( - new[] - { - AAXClean.SampleRate.Hz_44100, - AAXClean.SampleRate.Hz_32000, - AAXClean.SampleRate.Hz_24000, - AAXClean.SampleRate.Hz_22050, - AAXClean.SampleRate.Hz_16000, - AAXClean.SampleRate.Hz_12000, - } - .Select(s => new SampleRateSelection(s))); + public AvaloniaList> SampleRates { get; } + = new(Enum.GetValues().Select(v => new EnumDiaplay(v, $"{(int)v} Hz"))); public AvaloniaList EncoderQualities { get; } = new( @@ -71,7 +63,7 @@ namespace LibationAvalonia.ViewModels.Settings LameBitrate = config.LameBitrate; LameVBRQuality = config.LameVBRQuality; - SelectedSampleRate = SampleRates.FirstOrDefault(s => s.SampleRate == config.MaxSampleRate); + SelectedSampleRate = SampleRates.SingleOrDefault(s => s.Value == config.MaxSampleRate); SelectedEncoderQuality = config.LameEncoderQuality; } @@ -98,7 +90,7 @@ namespace LibationAvalonia.ViewModels.Settings config.LameVBRQuality = LameVBRQuality; config.LameEncoderQuality = SelectedEncoderQuality; - config.MaxSampleRate = SelectedSampleRate?.SampleRate ?? config.MaxSampleRate; + config.MaxSampleRate = SelectedSampleRate?.Value ?? config.MaxSampleRate; } public AvaloniaList ClipBookmarkFormats { get; } = new(Enum.GetValues()); diff --git a/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs b/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs index 30fd3229..6afdc4f9 100644 --- a/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs +++ b/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs @@ -1,9 +1,11 @@ using Dinah.Core; using FileManager; using LibationFileManager; +using LibationUiBase; using ReactiveUI; using System; using System.Collections.Generic; +using System.Linq; namespace LibationAvalonia.ViewModels.Settings { @@ -22,6 +24,8 @@ namespace LibationAvalonia.ViewModels.Settings BooksDirectory = config.Books.PathWithoutPrefix; SavePodcastsToParentFolder = config.SavePodcastsToParentFolder; OverwriteExisting = config.OverwriteExisting; + CreationTime = DateTimeSources.SingleOrDefault(v => v.Value == config.CreationTime) ?? DateTimeSources[0]; + LastWriteTime = DateTimeSources.SingleOrDefault(v => v.Value == config.LastWriteTime) ?? DateTimeSources[0]; LoggingLevel = config.LogLevel; ThemeVariant = initialThemeVariant = Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)) is nameof(Avalonia.Styling.ThemeVariant.Dark) @@ -37,6 +41,8 @@ namespace LibationAvalonia.ViewModels.Settings config.Books = lonNewBooks; config.SavePodcastsToParentFolder = SavePodcastsToParentFolder; config.OverwriteExisting = OverwriteExisting; + config.CreationTime = CreationTime.Value; + config.LastWriteTime = LastWriteTime.Value; config.LogLevel = LoggingLevel; Configuration.Instance.SetString(ThemeVariant, nameof(ThemeVariant)); } @@ -53,6 +59,12 @@ namespace LibationAvalonia.ViewModels.Settings public string BooksText { get; } = Configuration.GetDescription(nameof(Configuration.Books)); public string SavePodcastsToParentFolderText { get; } = Configuration.GetDescription(nameof(Configuration.SavePodcastsToParentFolder)); public string OverwriteExistingText { get; } = Configuration.GetDescription(nameof(Configuration.OverwriteExisting)); + public string CreationTimeText { get; } = Configuration.GetDescription(nameof(Configuration.CreationTime)); + public string LastWriteTimeText { get; } = Configuration.GetDescription(nameof(Configuration.LastWriteTime)); + public EnumDiaplay[] DateTimeSources { get; } + = Enum.GetValues() + .Select(v => new EnumDiaplay(v)) + .ToArray(); public Serilog.Events.LogEventLevel[] LoggingLevels { get; } = Enum.GetValues(); public string BetaOptInText { get; } = Configuration.GetDescription(nameof(Configuration.BetaOptIn)); public string[] Themes { get; } = { nameof(Avalonia.Styling.ThemeVariant.Light), nameof(Avalonia.Styling.ThemeVariant.Dark) }; @@ -60,6 +72,8 @@ namespace LibationAvalonia.ViewModels.Settings public string BooksDirectory { get; set; } public bool SavePodcastsToParentFolder { get; set; } public bool OverwriteExisting { get; set; } + public EnumDiaplay CreationTime { get; set; } + public EnumDiaplay LastWriteTime { get; set; } public Serilog.Events.LogEventLevel LoggingLevel { get; set; } public string ThemeVariant diff --git a/Source/LibationFileManager/Configuration.PersistentSettings.cs b/Source/LibationFileManager/Configuration.PersistentSettings.cs index 6c07ae00..32af7bd7 100644 --- a/Source/LibationFileManager/Configuration.PersistentSettings.cs +++ b/Source/LibationFileManager/Configuration.PersistentSettings.cs @@ -194,6 +194,23 @@ namespace LibationFileManager Ignore = 3 } + [JsonConverter(typeof(StringEnumConverter))] + public enum DateTimeSource + { + [Description("File creation date/time.")] + File, + [Description("Audiobook publication date")] + Published, + [Description("Date the book added to your Audible account")] + Added + } + + [Description("Set file \"created\" timestamp to:")] + public DateTimeSource CreationTime { get => GetNonString(defaultValue: DateTimeSource.Published); set => SetNonString(value); } + + [Description("Set file \"modified\" timestamp to:")] + public DateTimeSource LastWriteTime { get => GetNonString(defaultValue: DateTimeSource.Published); set => SetNonString(value); } + [Description("Indicates that this is the first time Libation has been run")] public bool FirstLaunch { get => GetNonString(defaultValue: true); set => SetNonString(value); } diff --git a/Source/LibationUiBase/EnumDiaplay[T].cs b/Source/LibationUiBase/EnumDiaplay[T].cs new file mode 100644 index 00000000..ecf5e225 --- /dev/null +++ b/Source/LibationUiBase/EnumDiaplay[T].cs @@ -0,0 +1,17 @@ +using Dinah.Core; +using System; + +namespace LibationUiBase +{ + public record EnumDiaplay where T : Enum + { + public T Value { get; } + public string Description { get; } + public EnumDiaplay(T value, string description = null) + { + Value = value; + Description = description ?? value.GetDescription() ?? value.ToString(); + } + public override string ToString() => Description; + } +} diff --git a/Source/LibationUiBase/SampleRateSelection.cs b/Source/LibationUiBase/SampleRateSelection.cs deleted file mode 100644 index d91c1ea8..00000000 --- a/Source/LibationUiBase/SampleRateSelection.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace LibationUiBase -{ - public class SampleRateSelection - { - public AAXClean.SampleRate SampleRate { get; } - public SampleRateSelection(AAXClean.SampleRate sampleRate) - { - SampleRate = sampleRate; - } - public override string ToString() => $"{(int)SampleRate} Hz"; - } -} diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs index c36e9652..b19d99ac 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.AudioSettings.cs @@ -28,15 +28,9 @@ namespace LibationWinForms.Dialogs }); maxSampleRateCb.Items.AddRange( - new object[] - { - new SampleRateSelection(AAXClean.SampleRate.Hz_44100), - new SampleRateSelection(AAXClean.SampleRate.Hz_32000), - new SampleRateSelection(AAXClean.SampleRate.Hz_24000), - new SampleRateSelection(AAXClean.SampleRate.Hz_22050), - new SampleRateSelection(AAXClean.SampleRate.Hz_16000), - new SampleRateSelection(AAXClean.SampleRate.Hz_12000) - }); + Enum.GetValues() + .Select(v => new EnumDiaplay(v, $"{(int)v} Hz")) + .ToArray()); encoderQualityCb.Items.AddRange( new object[] @@ -62,7 +56,13 @@ namespace LibationWinForms.Dialogs lameTargetBitrateRb.Checked = config.LameTargetBitrate; lameTargetQualityRb.Checked = !config.LameTargetBitrate; - maxSampleRateCb.SelectedItem = maxSampleRateCb.Items.Cast().Single(s => s.SampleRate == config.MaxSampleRate); + + maxSampleRateCb.SelectedItem + = maxSampleRateCb.Items + .Cast>() + .SingleOrDefault(v => v.Value == config.MaxSampleRate) + ?? maxSampleRateCb.Items[0]; + encoderQualityCb.SelectedItem = config.LameEncoderQuality; lameDownsampleMonoCbox.Checked = config.LameDownsampleMono; lameBitrateTb.Value = config.LameBitrate; @@ -95,9 +95,8 @@ namespace LibationWinForms.Dialogs config.StripAudibleBrandAudio = stripAudibleBrandingCbox.Checked; config.DecryptToLossy = convertLossyRb.Checked; config.MoveMoovToBeginning = moveMoovAtomCbox.Checked; - config.LameTargetBitrate = lameTargetBitrateRb.Checked; - config.MaxSampleRate = ((SampleRateSelection)maxSampleRateCb.SelectedItem).SampleRate; + config.MaxSampleRate = ((EnumDiaplay)maxSampleRateCb.SelectedItem).Value; config.LameEncoderQuality = (NAudio.Lame.EncoderQuality)encoderQualityCb.SelectedItem; encoderQualityCb.SelectedItem = config.LameEncoderQuality; config.LameDownsampleMono = lameDownsampleMonoCbox.Checked; diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs index 420fff22..007be020 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs @@ -53,6 +53,11 @@ tab1ImportantSettings = new System.Windows.Forms.TabPage(); betaOptInCbox = new System.Windows.Forms.CheckBox(); booksGb = new System.Windows.Forms.GroupBox(); + lastWriteTimeCb = new System.Windows.Forms.ComboBox(); + creationTimeCb = new System.Windows.Forms.ComboBox(); + lastWriteTimeLbl = new System.Windows.Forms.Label(); + creationTimeLbl = new System.Windows.Forms.Label(); + overwriteExistingCbox = new System.Windows.Forms.CheckBox(); saveEpisodesToSeriesFolderCbox = new System.Windows.Forms.CheckBox(); tab2ImportLibrary = new System.Windows.Forms.TabPage(); autoDownloadEpisodesCb = new System.Windows.Forms.CheckBox(); @@ -119,7 +124,6 @@ retainAaxFileCbox = new System.Windows.Forms.CheckBox(); downloadCoverArtCbox = new System.Windows.Forms.CheckBox(); createCueSheetCbox = new System.Windows.Forms.CheckBox(); - overwriteExistingCbox = new System.Windows.Forms.CheckBox(); badBookGb.SuspendLayout(); tabControl.SuspendLayout(); tab1ImportantSettings.SuspendLayout(); @@ -331,7 +335,7 @@ // // logsBtn // - logsBtn.Location = new System.Drawing.Point(256, 220); + logsBtn.Location = new System.Drawing.Point(256, 261); logsBtn.Name = "logsBtn"; logsBtn.Size = new System.Drawing.Size(132, 23); logsBtn.TabIndex = 5; @@ -351,7 +355,7 @@ // loggingLevelLbl // loggingLevelLbl.AutoSize = true; - loggingLevelLbl.Location = new System.Drawing.Point(6, 223); + loggingLevelLbl.Location = new System.Drawing.Point(6, 264); loggingLevelLbl.Name = "loggingLevelLbl"; loggingLevelLbl.Size = new System.Drawing.Size(78, 15); loggingLevelLbl.TabIndex = 3; @@ -361,7 +365,7 @@ // loggingLevelCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; loggingLevelCb.FormattingEnabled = true; - loggingLevelCb.Location = new System.Drawing.Point(90, 220); + loggingLevelCb.Location = new System.Drawing.Point(90, 261); loggingLevelCb.Name = "loggingLevelCb"; loggingLevelCb.Size = new System.Drawing.Size(129, 23); loggingLevelCb.TabIndex = 4; @@ -409,17 +413,69 @@ // booksGb // booksGb.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + booksGb.Controls.Add(lastWriteTimeCb); + booksGb.Controls.Add(creationTimeCb); + booksGb.Controls.Add(lastWriteTimeLbl); + booksGb.Controls.Add(creationTimeLbl); booksGb.Controls.Add(overwriteExistingCbox); booksGb.Controls.Add(saveEpisodesToSeriesFolderCbox); booksGb.Controls.Add(booksSelectControl); booksGb.Controls.Add(booksLocationDescLbl); booksGb.Location = new System.Drawing.Point(6, 6); booksGb.Name = "booksGb"; - booksGb.Size = new System.Drawing.Size(842, 182); + booksGb.Size = new System.Drawing.Size(842, 249); booksGb.TabIndex = 0; booksGb.TabStop = false; booksGb.Text = "Books location"; // + // lastWriteTimeCb + // + lastWriteTimeCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + lastWriteTimeCb.FormattingEnabled = true; + lastWriteTimeCb.Location = new System.Drawing.Point(188, 214); + lastWriteTimeCb.Name = "lastWriteTimeCb"; + lastWriteTimeCb.Size = new System.Drawing.Size(266, 23); + lastWriteTimeCb.TabIndex = 5; + // + // creationTimeCb + // + creationTimeCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + creationTimeCb.FormattingEnabled = true; + creationTimeCb.Location = new System.Drawing.Point(188, 185); + creationTimeCb.Name = "creationTimeCb"; + creationTimeCb.Size = new System.Drawing.Size(266, 23); + creationTimeCb.TabIndex = 5; + // + // lastWriteTimeLbl + // + lastWriteTimeLbl.AutoSize = true; + lastWriteTimeLbl.Location = new System.Drawing.Point(7, 217); + lastWriteTimeLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lastWriteTimeLbl.Name = "lastWriteTimeLbl"; + lastWriteTimeLbl.Size = new System.Drawing.Size(116, 15); + lastWriteTimeLbl.TabIndex = 4; + lastWriteTimeLbl.Text = "[last write time desc]"; + // + // creationTimeLbl + // + creationTimeLbl.AutoSize = true; + creationTimeLbl.Location = new System.Drawing.Point(7, 188); + creationTimeLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + creationTimeLbl.Name = "creationTimeLbl"; + creationTimeLbl.Size = new System.Drawing.Size(112, 15); + creationTimeLbl.TabIndex = 4; + creationTimeLbl.Text = "[creation time desc]"; + // + // overwriteExistingCbox + // + overwriteExistingCbox.AutoSize = true; + overwriteExistingCbox.Location = new System.Drawing.Point(7, 156); + overwriteExistingCbox.Name = "overwriteExistingCbox"; + overwriteExistingCbox.Size = new System.Drawing.Size(129, 19); + overwriteExistingCbox.TabIndex = 3; + overwriteExistingCbox.Text = "[Overwrite Existing]"; + overwriteExistingCbox.UseVisualStyleBackColor = true; + // // saveEpisodesToSeriesFolderCbox // saveEpisodesToSeriesFolderCbox.AutoSize = true; @@ -1145,16 +1201,6 @@ createCueSheetCbox.UseVisualStyleBackColor = true; createCueSheetCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged; // - // overwriteExistingCbox - // - overwriteExistingCbox.AutoSize = true; - overwriteExistingCbox.Location = new System.Drawing.Point(7, 156); - overwriteExistingCbox.Name = "overwriteExistingCbox"; - overwriteExistingCbox.Size = new System.Drawing.Size(129, 19); - overwriteExistingCbox.TabIndex = 3; - overwriteExistingCbox.Text = "[Overwrite Existing]"; - overwriteExistingCbox.UseVisualStyleBackColor = true; - // // SettingsDialog // AcceptButton = saveBtn; @@ -1300,5 +1346,9 @@ private System.Windows.Forms.Label label21; private System.Windows.Forms.Label label20; private System.Windows.Forms.CheckBox overwriteExistingCbox; + private System.Windows.Forms.Label creationTimeLbl; + private System.Windows.Forms.ComboBox lastWriteTimeCb; + private System.Windows.Forms.ComboBox creationTimeCb; + private System.Windows.Forms.Label lastWriteTimeLbl; } } \ No newline at end of file diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.ImportLibrary.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.ImportLibrary.cs index d9930932..8c419572 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.ImportLibrary.cs +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.ImportLibrary.cs @@ -1,4 +1,5 @@ using LibationFileManager; +using LibationUiBase; using System; using System.Linq; @@ -13,6 +14,15 @@ namespace LibationWinForms.Dialogs this.importEpisodesCb.Text = desc(nameof(config.ImportEpisodes)); this.downloadEpisodesCb.Text = desc(nameof(config.DownloadEpisodes)); this.autoDownloadEpisodesCb.Text = desc(nameof(config.AutoDownloadEpisodes)); + creationTimeLbl.Text = desc(nameof(config.CreationTime)); + lastWriteTimeLbl.Text = desc(nameof(config.LastWriteTime)); + + var dateTimeSources = Enum.GetValues().Select(v => new EnumDiaplay(v)).ToArray(); + creationTimeCb.Items.AddRange(dateTimeSources); + lastWriteTimeCb.Items.AddRange(dateTimeSources); + + creationTimeCb.SelectedItem = dateTimeSources.SingleOrDefault(v => v.Value == config.CreationTime) ?? dateTimeSources[0]; + lastWriteTimeCb.SelectedItem = dateTimeSources.SingleOrDefault(v => v.Value == config.LastWriteTime) ?? dateTimeSources[0]; autoScanCb.Checked = config.AutoScan; showImportedStatsCb.Checked = config.ShowImportedStats; @@ -22,6 +32,9 @@ namespace LibationWinForms.Dialogs } private void Save_ImportLibrary(Configuration config) { + config.CreationTime = ((EnumDiaplay)creationTimeCb.SelectedItem).Value; + config.LastWriteTime = ((EnumDiaplay)lastWriteTimeCb.SelectedItem).Value; + config.AutoScan = autoScanCb.Checked; config.ShowImportedStats = showImportedStatsCb.Checked; config.ImportEpisodes = importEpisodesCb.Checked; diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.resx b/Source/LibationWinForms/Dialogs/SettingsDialog.resx index a395bffc..f298a7be 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.resx +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.resx @@ -1,64 +1,4 @@ - - - +