diff --git a/Source/AudibleUtilities/Account.cs b/Source/AudibleUtilities/Account.cs
index ddf2a0fb..8fe9e3f6 100644
--- a/Source/AudibleUtilities/Account.cs
+++ b/Source/AudibleUtilities/Account.cs
@@ -18,68 +18,64 @@ namespace AudibleUtilities
public string AccountId { get; }
// user-friendly, non-canonical name. mutable
- private string _accountName;
public string AccountName
{
- get => _accountName;
+ get => field;
set
{
if (string.IsNullOrWhiteSpace(value))
return;
var v = value.Trim();
- if (v == _accountName)
+ if (v == field)
return;
- _accountName = v;
+ field = v;
update();
}
}
// whether to include this account when scanning libraries.
// technically this is an app setting; not an attribute of account. but since it's managed with accounts, it makes sense to put this exception-to-the-rule here
- private bool _libraryScan = true;
public bool LibraryScan
{
- get => _libraryScan;
+ get => field;
set
{
- if (value == _libraryScan)
+ if (value == field)
return;
- _libraryScan = value;
+ field = value;
update();
}
}
- private string _decryptKey = "";
/// aka: activation bytes
public string DecryptKey
{
- get => _decryptKey;
+ get => field ?? "";
set
{
var v = (value ?? "").Trim();
- if (v == _decryptKey)
+ if (v == field)
return;
- _decryptKey = v;
+ field = v;
update();
}
}
- private Identity _identity;
public Identity IdentityTokens
{
- get => _identity;
+ get => field;
set
{
- if (_identity is null && value is null)
+ if (field is null && value is null)
return;
- if (_identity is not null)
- _identity.Updated -= update;
+ if (field is not null)
+ field.Updated -= update;
if (value is not null)
value.Updated += update;
- _identity = value;
+ field = value;
update();
}
}
diff --git a/Source/LibationAvalonia/Controls/CheckedListBox.axaml.cs b/Source/LibationAvalonia/Controls/CheckedListBox.axaml.cs
index 82d88622..ce8ea352 100644
--- a/Source/LibationAvalonia/Controls/CheckedListBox.axaml.cs
+++ b/Source/LibationAvalonia/Controls/CheckedListBox.axaml.cs
@@ -21,9 +21,7 @@ namespace LibationAvalonia.Controls
public class CheckBoxViewModel : ViewModelBase
{
- private bool _isChecked;
- public bool IsChecked { get => _isChecked; set => this.RaiseAndSetIfChanged(ref _isChecked, value); }
- private object _bookText;
- public object Item { get => _bookText; set => this.RaiseAndSetIfChanged(ref _bookText, value); }
+ public bool IsChecked { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public object Item { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
}
}
diff --git a/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs b/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs
index 13981d56..dc970a9b 100644
--- a/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs
+++ b/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs
@@ -140,19 +140,17 @@ namespace LibationAvalonia.Controls
private class KnownDirectoryItem : ReactiveObject
{
public Configuration.KnownDirectories KnownDirectory { get; set; }
- private string? _directory;
- public string? Directory { get => _directory; private set => this.RaiseAndSetIfChanged(ref _directory, value); }
+ public string? Directory { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
public string? Name { get; }
- private string? _subDir;
public string? SubDirectory
{
- get => _subDir;
+ get => field;
set
{
- _subDir = value;
+ field = value;
if (Configuration.GetKnownDirectoryPath(KnownDirectory) is string dir)
{
- Directory = Path.Combine(dir, _subDir ?? "");
+ Directory = Path.Combine(dir, field ?? "");
}
}
}
diff --git a/Source/LibationAvalonia/Dialogs/AboutDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/AboutDialog.axaml.cs
index 30ed6303..fd2975da 100644
--- a/Source/LibationAvalonia/Dialogs/AboutDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/AboutDialog.axaml.cs
@@ -64,12 +64,8 @@ namespace LibationAvalonia.Dialogs
public class AboutVM : ViewModelBase
{
public string Version { get; }
- public bool CanCheckForUpgrade { get => canCheckForUpgrade; set => this.RaiseAndSetIfChanged(ref canCheckForUpgrade, value); }
- public string UpgradeButtonText { get => upgradeButtonText; set => this.RaiseAndSetIfChanged(ref upgradeButtonText, value); }
-
-
- private bool canCheckForUpgrade = true;
- private string upgradeButtonText = "Check for Upgrade";
+ public bool CanCheckForUpgrade { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = true;
+ public string UpgradeButtonText { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }= "Check for Upgrade";
public IEnumerable PrimaryContributors => LibationContributor.PrimaryContributors;
public IEnumerable AdditionalContributors => LibationContributor.AdditionalContributors;
diff --git a/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs
index bb8b3168..68ee3d97 100644
--- a/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs
@@ -19,15 +19,14 @@ namespace LibationAvalonia.Dialogs
public AvaloniaList Accounts { get; } = new();
public class AccountDto : ViewModels.ViewModelBase
{
- private string _accountId;
public IReadOnlyList Locales => AccountsDialog.Locales;
public bool LibraryScan { get; set; } = true;
public string AccountId
{
- get => _accountId;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _accountId, value);
+ this.RaiseAndSetIfChanged(ref field, value);
this.RaisePropertyChanged(nameof(IsDefault));
}
}
diff --git a/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs
index 3f60f925..6ddf944f 100644
--- a/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs
@@ -17,16 +17,15 @@ namespace LibationAvalonia.Dialogs
{
public partial class BookDetailsDialog : DialogWindow
{
- private LibraryBook _libraryBook;
private BookDetailsDialogViewModel _viewModel;
public LibraryBook LibraryBook
{
- get => _libraryBook;
+ get => field;
set
{
- _libraryBook = value;
- Title = _libraryBook.Book.TitleWithSubtitle;
- DataContext = _viewModel = new BookDetailsDialogViewModel(_libraryBook);
+ field = value;
+ Title = field.Book.TitleWithSubtitle;
+ DataContext = _viewModel = new BookDetailsDialogViewModel(field);
}
}
diff --git a/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs
index d3860579..5265c99e 100644
--- a/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs
@@ -204,9 +204,8 @@ namespace LibationAvalonia.Dialogs
private class BookRecordEntry : ViewModels.ViewModelBase
{
private const string DateFormat = "yyyy-MM-dd HH\\:mm";
- private bool _ischecked;
public IRecord Record { get; }
- public bool IsChecked { get => _ischecked; set => this.RaiseAndSetIfChanged(ref _ischecked, value); }
+ public bool IsChecked { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
public string Type => Record.GetType().Name;
public string Start => formatTimeSpan(Record.Start);
public string Created => Record.Created.ToString(DateFormat);
diff --git a/Source/LibationAvalonia/Dialogs/EditQuickFilters.axaml.cs b/Source/LibationAvalonia/Dialogs/EditQuickFilters.axaml.cs
index aa51b7ed..b37fdc6f 100644
--- a/Source/LibationAvalonia/Dialogs/EditQuickFilters.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/EditQuickFilters.axaml.cs
@@ -13,29 +13,25 @@ namespace LibationAvalonia.Dialogs
public class Filter : ViewModels.ViewModelBase
{
- private string _name;
public string Name
{
- get => _name;
- set => this.RaiseAndSetIfChanged(ref _name, value);
+ get => field;
+ set => this.RaiseAndSetIfChanged(ref field, value);
}
- private string _filterString;
public string FilterString
{
- get => _filterString;
+ get => field;
set
{
IsDefault = string.IsNullOrEmpty(value);
- this.RaiseAndSetIfChanged(ref _filterString, value);
+ this.RaiseAndSetIfChanged(ref field, value);
this.RaisePropertyChanged(nameof(IsDefault));
}
}
public bool IsDefault { get; private set; } = true;
- private bool _isTop;
- private bool _isBottom;
- public bool IsTop { get => _isTop; set => this.RaiseAndSetIfChanged(ref _isTop, value); }
- public bool IsBottom { get => _isBottom; set => this.RaiseAndSetIfChanged(ref _isBottom, value); }
+ public bool IsTop { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool IsBottom { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
public QuickFilters.NamedFilter AsNamedFilter() => new(FilterString, Name);
diff --git a/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs b/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs
index e9311461..1a3949e5 100644
--- a/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs
@@ -123,25 +123,22 @@ namespace LibationAvalonia.Dialogs
{
public ReplacementsExt()
{
- _replacementText = string.Empty;
- _description = string.Empty;
- _characterToReplace = string.Empty;
+ ReplacementText = string.Empty;
+ Description = string.Empty;
+ CharacterToReplace = string.Empty;
}
public ReplacementsExt(Replacement replacement)
{
- _characterToReplace = replacement.CharacterToReplace == default ? "" : replacement.CharacterToReplace.ToString();
- _replacementText = replacement.ReplacementString;
- _description = replacement.Description;
+ CharacterToReplace = replacement.CharacterToReplace == default ? "" : replacement.CharacterToReplace.ToString();
+ ReplacementText = replacement.ReplacementString;
+ Description = replacement.Description;
Mandatory = replacement.Mandatory;
}
- private string _replacementText;
- private string _description;
- private string _characterToReplace;
- public string ReplacementText { get => _replacementText; set => this.RaiseAndSetIfChanged(ref _replacementText, value); }
- public string Description { get => _description; set => this.RaiseAndSetIfChanged(ref _description, value); }
- public string CharacterToReplace { get => _characterToReplace; set => this.RaiseAndSetIfChanged(ref _characterToReplace, value); }
- public char Character => string.IsNullOrEmpty(_characterToReplace) ? default : _characterToReplace[0];
+ public string ReplacementText { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public string Description { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public string CharacterToReplace { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public char Character => string.IsNullOrEmpty(CharacterToReplace) ? default : CharacterToReplace[0];
public bool IsDefault => !Mandatory && string.IsNullOrEmpty(CharacterToReplace);
public bool Mandatory { get; }
diff --git a/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml.cs
index e596a6bb..aba6bc88 100644
--- a/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml.cs
@@ -101,19 +101,17 @@ public partial class EditTemplateDialog : DialogWindow
=> Go.To.Url(@"ht" + "tps://github.com/rmcrackan/Libation/blob/master/Documentation/NamingTemplates.md");
// hold the work-in-progress value. not guaranteed to be valid
- private string _userTemplateText;
public string UserTemplateText
{
- get => _userTemplateText;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _userTemplateText, value);
+ this.RaiseAndSetIfChanged(ref field, value);
templateTb_TextChanged();
}
}
- private string _warningText;
- public string WarningText { get => _warningText; set => this.RaiseAndSetIfChanged(ref _warningText, value); }
+ public string WarningText { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
public string Description { get; }
diff --git a/Source/LibationAvalonia/Dialogs/ImageDisplayDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/ImageDisplayDialog.axaml.cs
index 86b9933a..01ef562e 100644
--- a/Source/LibationAvalonia/Dialogs/ImageDisplayDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/ImageDisplayDialog.axaml.cs
@@ -61,15 +61,7 @@ namespace LibationAvalonia.Dialogs
public class BitmapHolder : ViewModels.ViewModelBase
{
- private Bitmap _coverImage;
- public Bitmap CoverImage
- {
- get => _coverImage;
- set
- {
- this.RaiseAndSetIfChanged(ref _coverImage, value);
- }
- }
+ public Bitmap CoverImage { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
}
}
}
diff --git a/Source/LibationAvalonia/Dialogs/LocateAudiobooksDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/LocateAudiobooksDialog.axaml.cs
index dbabcf36..a06e19c6 100644
--- a/Source/LibationAvalonia/Dialogs/LocateAudiobooksDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/LocateAudiobooksDialog.axaml.cs
@@ -108,8 +108,7 @@ namespace LibationAvalonia.Dialogs
public class LocatedAudiobooksViewModel : ViewModelBase
{
- private int _foundAsins = 0;
public AvaloniaList> FoundFiles { get; } = new();
- public int FoundAsins { get => _foundAsins; set => this.RaiseAndSetIfChanged(ref _foundAsins, value); }
+ public int FoundAsins { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
}
}
diff --git a/Source/LibationAvalonia/Dialogs/ThemePickerDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/ThemePickerDialog.axaml.cs
index e3a2d9e3..d418cf0d 100644
--- a/Source/LibationAvalonia/Dialogs/ThemePickerDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/ThemePickerDialog.axaml.cs
@@ -180,16 +180,15 @@ public partial class ThemePickerDialog : DialogWindow
public required string ThemeItemName { get; init; }
public required Action? ColorSetter { get; set; }
- private Color _themeColor;
public Color ThemeColor
{
- get => _themeColor;
+ get => field;
set
{
- var setColors = !_themeColor.Equals(value);
- this.RaiseAndSetIfChanged(ref _themeColor, value);
+ var setColors = !field.Equals(value);
+ this.RaiseAndSetIfChanged(ref field, value);
if (setColors)
- ColorSetter?.Invoke(_themeColor, ThemeItemName);
+ ColorSetter?.Invoke(field, ThemeItemName);
}
}
}
diff --git a/Source/LibationAvalonia/Dialogs/TrashBinDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/TrashBinDialog.axaml.cs
index b3a69b4f..15518e50 100644
--- a/Source/LibationAvalonia/Dialogs/TrashBinDialog.axaml.cs
+++ b/Source/LibationAvalonia/Dialogs/TrashBinDialog.axaml.cs
@@ -35,9 +35,7 @@ namespace LibationAvalonia.Dialogs
{
public AvaloniaList DeletedBooks { get; }
public string CheckedCountText => $"Checked : {_checkedBooksCount} of {_totalBooksCount}";
-
- private bool _controlsEnabled = true;
- public bool ControlsEnabled { get => _controlsEnabled; set => this.RaiseAndSetIfChanged(ref _controlsEnabled, value); }
+ public bool ControlsEnabled { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = true;
private bool? everythingChecked = false;
public bool? EverythingChecked
diff --git a/Source/LibationAvalonia/ViewModels/Dialogs/MessageBoxViewModel.cs b/Source/LibationAvalonia/ViewModels/Dialogs/MessageBoxViewModel.cs
index ecf4bc90..c673b697 100644
--- a/Source/LibationAvalonia/ViewModels/Dialogs/MessageBoxViewModel.cs
+++ b/Source/LibationAvalonia/ViewModels/Dialogs/MessageBoxViewModel.cs
@@ -5,8 +5,7 @@ namespace LibationAvalonia.ViewModels.Dialogs
{
public class MessageBoxViewModel
{
- private string _message;
- public string Message { get { return _message; } set { _message = value; } }
+ public string Message { get => field; set => field = value; }
public string Caption { get; } = "Message Box";
private MessageBoxButtons _button;
private MessageBoxIcon _icon;
diff --git a/Source/LibationAvalonia/ViewModels/LiberateStatusButtonViewModel.cs b/Source/LibationAvalonia/ViewModels/LiberateStatusButtonViewModel.cs
index f1342600..b5bfc7b7 100644
--- a/Source/LibationAvalonia/ViewModels/LiberateStatusButtonViewModel.cs
+++ b/Source/LibationAvalonia/ViewModels/LiberateStatusButtonViewModel.cs
@@ -5,24 +5,14 @@ namespace LibationAvalonia.ViewModels
{
public class LiberateStatusButtonViewModel : ViewModelBase
{
- private bool isSeries;
- private bool isError;
- private bool isButtonEnabled;
- private bool expanded;
- private bool redVisible = true;
- private bool yellowVisible;
- private bool greenVisible;
- private bool pdfNotDownloadedVisible;
- private bool pdfDownloadedVisible;
-
- public bool IsError { get => isError; set => this.RaiseAndSetIfChanged(ref isError, value); }
- public bool IsButtonEnabled { get => isButtonEnabled; set => this.RaiseAndSetIfChanged(ref isButtonEnabled, value); }
- public bool IsSeries { get => isSeries; set => this.RaiseAndSetIfChanged(ref isSeries, value); }
- public bool Expanded { get => expanded; set => this.RaiseAndSetIfChanged(ref expanded, value); }
- public bool RedVisible { get => redVisible; set => this.RaiseAndSetIfChanged(ref redVisible, value); }
- public bool YellowVisible { get => yellowVisible; set => this.RaiseAndSetIfChanged(ref yellowVisible, value); }
- public bool GreenVisible { get => greenVisible; set => this.RaiseAndSetIfChanged(ref greenVisible, value); }
- public bool PdfDownloadedVisible { get => pdfDownloadedVisible; set => this.RaiseAndSetIfChanged(ref pdfDownloadedVisible, value); }
- public bool PdfNotDownloadedVisible { get => pdfNotDownloadedVisible; set => this.RaiseAndSetIfChanged(ref pdfNotDownloadedVisible, value); }
+ public bool IsError { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool IsButtonEnabled { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool IsSeries { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool Expanded { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool RedVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = true;
+ public bool YellowVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool GreenVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool PdfDownloadedVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool PdfNotDownloadedVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
}
}
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs b/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs
index deebd59c..ef02c030 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs
@@ -12,7 +12,6 @@ namespace LibationAvalonia.ViewModels
partial class MainVM
{
private Task? updateCountsTask;
- private LibraryCommands.LibraryStats? _libraryStats;
/// The "Begin Book and PDF Backup" menu item header text
public string BookBackupsToolStripText { get; private set; } = "Begin Book and PDF Backups: 0";
@@ -22,10 +21,10 @@ namespace LibationAvalonia.ViewModels
/// The user's library statistics
public LibraryCommands.LibraryStats? LibraryStats
{
- get => _libraryStats;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _libraryStats, value);
+ this.RaiseAndSetIfChanged(ref field, value);
BookBackupsToolStripText
= LibraryStats?.HasPendingBooks ?? false
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.Filters.cs b/Source/LibationAvalonia/ViewModels/MainVM.Filters.cs
index 86600760..d38109fa 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.Filters.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.Filters.cs
@@ -18,14 +18,11 @@ namespace LibationAvalonia.ViewModels
private string lastGoodSearch = string.Empty;
private QuickFilters.NamedFilter? lastGoodFilter => new(lastGoodSearch, null);
- private QuickFilters.NamedFilter? _selectedNamedFilter = new(string.Empty, null);
- private bool _firstFilterIsDefault = true;
-
/// Library filterting query
- public QuickFilters.NamedFilter? SelectedNamedFilter { get => _selectedNamedFilter; set => this.RaiseAndSetIfChanged(ref _selectedNamedFilter, value); }
+ public QuickFilters.NamedFilter? SelectedNamedFilter { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = new(string.Empty, null);
public AvaloniaList QuickFilterMenuItems { get; } = new();
/// Indicates if the first quick filter is the default filter
- public bool FirstFilterIsDefault { get => _firstFilterIsDefault; set => QuickFilters.UseDefault = this.RaiseAndSetIfChanged(ref _firstFilterIsDefault, value); }
+ public bool FirstFilterIsDefault { get => field; set => QuickFilters.UseDefault = this.RaiseAndSetIfChanged(ref field, value); }
private void Configure_Filters()
{
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.Import.cs b/Source/LibationAvalonia/ViewModels/MainVM.Import.cs
index de88b2bb..a31b7db9 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.Import.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.Import.cs
@@ -14,30 +14,26 @@ namespace LibationAvalonia.ViewModels
{
public partial class MainVM
{
- private bool _autoScanChecked = Configuration.Instance.AutoScan;
- private string _removeBooksButtonText = "Remove # Books from Libation";
- private bool _removeBooksButtonEnabled = Design.IsDesignMode;
- private bool _removeButtonsVisible = Design.IsDesignMode;
private int _numAccountsScanning = 2;
private int _accountsCount = 0;
public string LocateAudiobooksTip => Configuration.GetHelpText("LocateAudiobooks");
/// Auto scanning accounts is enables
- public bool AutoScanChecked { get => _autoScanChecked; set => Configuration.Instance.AutoScan = this.RaiseAndSetIfChanged(ref _autoScanChecked, value); }
+ public bool AutoScanChecked { get => field; set => Configuration.Instance.AutoScan = this.RaiseAndSetIfChanged(ref field, value); } = Configuration.Instance.AutoScan;
/// Display text for the "Remove # Books from Libation" button
- public string RemoveBooksButtonText { get => _removeBooksButtonText; set => this.RaiseAndSetIfChanged(ref _removeBooksButtonText, value); }
+ public string RemoveBooksButtonText { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }= "Remove # Books from Libation";
/// Indicates if the "Remove # Books from Libation" button is enabled
- public bool RemoveBooksButtonEnabled { get => _removeBooksButtonEnabled; set { this.RaiseAndSetIfChanged(ref _removeBooksButtonEnabled, value); } }
+ public bool RemoveBooksButtonEnabled { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } } = Design.IsDesignMode;
/// Indicates if the "Remove # Books from Libation" and "Done Removing" buttons should be visible
public bool RemoveButtonsVisible
{
- get => _removeButtonsVisible;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _removeButtonsVisible, value);
+ this.RaiseAndSetIfChanged(ref field, value);
this.RaisePropertyChanged(nameof(RemoveMenuItemsEnabled));
}
- }
+ } = Design.IsDesignMode;
/// Indicates if Libation is currently scanning account(s)
public bool ActivelyScanning => _numAccountsScanning > 0;
/// Indicates if the "Remove Books" menu items are enabled
@@ -53,10 +49,10 @@ namespace LibationAvalonia.ViewModels
/// The number of accounts added to Libation
public int AccountsCount
{
- get => _accountsCount;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _accountsCount, value);
+ this.RaiseAndSetIfChanged(ref field, value);
this.RaisePropertyChanged(nameof(AnyAccounts));
this.RaisePropertyChanged(nameof(OneAccount));
this.RaisePropertyChanged(nameof(MultipleAccounts));
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.ProcessQueue.cs b/Source/LibationAvalonia/ViewModels/MainVM.ProcessQueue.cs
index 21d1b509..b9790273 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.ProcessQueue.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.ProcessQueue.cs
@@ -12,15 +12,13 @@ namespace LibationAvalonia.ViewModels
{
partial class MainVM
{
- private bool _queueOpen = false;
-
/// The Process Queue panel is open
public bool QueueOpen
{
- get => _queueOpen;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _queueOpen, value);
+ this.RaiseAndSetIfChanged(ref field, value);
QueueButtonAngle = value ? 180 : 0;
this.RaisePropertyChanged(nameof(QueueButtonAngle));
}
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.Settings.cs b/Source/LibationAvalonia/ViewModels/MainVM.Settings.cs
index 72c25c27..a28ab910 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.Settings.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.Settings.cs
@@ -9,8 +9,7 @@ namespace LibationAvalonia.ViewModels
{
partial class MainVM
{
- private bool _menuBarVisible = !Configuration.IsMacOs;
- public bool MenuBarVisible { get => _menuBarVisible; set => this.RaiseAndSetIfChanged(ref _menuBarVisible, value); }
+ public bool MenuBarVisible { get => field; set => this.RaiseAndSetIfChanged(ref field, value); } = !Configuration.IsMacOs;
private void Configure_Settings()
{
if (App.Current is Avalonia.Application app &&
diff --git a/Source/LibationAvalonia/ViewModels/MainVM.cs b/Source/LibationAvalonia/ViewModels/MainVM.cs
index 809efb86..1115dc7b 100644
--- a/Source/LibationAvalonia/ViewModels/MainVM.cs
+++ b/Source/LibationAvalonia/ViewModels/MainVM.cs
@@ -16,8 +16,7 @@ namespace LibationAvalonia.ViewModels
public ProcessQueueViewModel ProcessQueue { get; } = new ProcessQueueViewModel();
public ProductsDisplayViewModel ProductsDisplay { get; } = new ProductsDisplayViewModel();
- private double? _downloadProgress = null;
- public double? DownloadProgress { get => _downloadProgress; set => this.RaiseAndSetIfChanged(ref _downloadProgress, value); }
+ public double? DownloadProgress { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
private readonly MainWindow MainWindow;
diff --git a/Source/LibationAvalonia/ViewModels/ProductsDisplayViewModel.cs b/Source/LibationAvalonia/ViewModels/ProductsDisplayViewModel.cs
index efeb25bd..cfa1b966 100644
--- a/Source/LibationAvalonia/ViewModels/ProductsDisplayViewModel.cs
+++ b/Source/LibationAvalonia/ViewModels/ProductsDisplayViewModel.cs
@@ -31,15 +31,8 @@ namespace LibationAvalonia.ViewModels
private HashSet? FilteredInGridEntries;
public string? FilterString { get; private set; }
- private DataGridCollectionView? _gridEntries;
- public DataGridCollectionView? GridEntries
- {
- get => _gridEntries;
- private set => this.RaiseAndSetIfChanged(ref _gridEntries, value);
- }
-
- private bool _removeColumnVisible;
- public bool RemoveColumnVisible { get => _removeColumnVisible; private set => this.RaiseAndSetIfChanged(ref _removeColumnVisible, value); }
+ public DataGridCollectionView? GridEntries { get => field; private set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool RemoveColumnVisible { get => field; private set => this.RaiseAndSetIfChanged(ref field, value); }
public List GetVisibleBookEntries()
=> FilteredInGridEntries?
@@ -104,8 +97,7 @@ namespace LibationAvalonia.ViewModels
internal async Task BindToGridAsync(List dbBooks)
{
- if (dbBooks == null)
- throw new ArgumentNullException(nameof(dbBooks));
+ ArgumentNullException.ThrowIfNull(dbBooks, nameof(dbBooks));
//Get the UI thread's synchronization context and set it on the current thread to ensure
//it's available for GetAllProductsAsync and GetAllSeriesEntriesAsync
@@ -158,8 +150,7 @@ namespace LibationAvalonia.ViewModels
///
internal async Task UpdateGridAsync(List dbBooks)
{
- if (dbBooks == null)
- throw new ArgumentNullException(nameof(dbBooks));
+ ArgumentNullException.ThrowIfNull(dbBooks, nameof(dbBooks));
if (GridEntries == null)
throw new InvalidOperationException($"Must call {nameof(BindToGridAsync)} before calling {nameof(UpdateGridAsync)}");
diff --git a/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs b/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs
index 44b0e90c..ac7b3ca0 100644
--- a/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs
+++ b/Source/LibationAvalonia/ViewModels/Settings/AudioSettingsVM.cs
@@ -13,14 +13,6 @@ namespace LibationAvalonia.ViewModels.Settings
{
public class AudioSettingsVM : ViewModelBase
{
- private bool _downloadClipsBookmarks;
- private bool _decryptToLossy;
- private bool _splitFilesByChapter;
- private bool _allowLibationFixup;
- private bool _lameTargetBitrate;
- private bool _lameMatchSource;
- private int _lameBitrate;
- private int _lameVBRQuality;
private string _chapterTitleTemplate;
public EnumDisplay SelectedSampleRate { get; set; }
public NAudio.Lame.EncoderQuality SelectedEncoderQuality { get; set; }
@@ -31,13 +23,11 @@ namespace LibationAvalonia.ViewModels.Settings
.Select(v => new EnumDisplay(v, $"{((int)v):N0} Hz")));
public AvaloniaList EncoderQualities { get; }
- = new(
- new[]
- {
+ = new([
NAudio.Lame.EncoderQuality.High,
NAudio.Lame.EncoderQuality.Standard,
NAudio.Lame.EncoderQuality.Fast,
- });
+ ]);
public AudioSettingsVM(Configuration config)
@@ -141,12 +131,10 @@ namespace LibationAvalonia.ViewModels.Settings
public bool DownloadCoverArt { get; set; }
public bool RetainAaxFile { get; set; }
public string RetainAaxFileTip => Configuration.GetHelpText(nameof(RetainAaxFile));
- public bool DownloadClipsBookmarks { get => _downloadClipsBookmarks; set => this.RaiseAndSetIfChanged(ref _downloadClipsBookmarks, value); }
-
- private bool _useWidevine, _requestSpatial, _request_xHE_AAC;
- public bool UseWidevine { get => _useWidevine; set => this.RaiseAndSetIfChanged(ref _useWidevine, value); }
- public bool Request_xHE_AAC { get => _request_xHE_AAC; set => this.RaiseAndSetIfChanged(ref _request_xHE_AAC, value); }
- public bool RequestSpatial { get => _requestSpatial; set => this.RaiseAndSetIfChanged(ref _requestSpatial, value); }
+ public bool DownloadClipsBookmarks { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool UseWidevine { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool Request_xHE_AAC { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
+ public bool RequestSpatial { get => field; set => this.RaiseAndSetIfChanged(ref field, value); }
public EnumDisplay FileDownloadQuality { get; set; }
public EnumDisplay SpatialAudioCodec { get; set; }
@@ -158,10 +146,10 @@ namespace LibationAvalonia.ViewModels.Settings
public bool StripUnabridged { get; set; }
public string StripUnabridgedTip => Configuration.GetHelpText(nameof(StripUnabridged));
public bool DecryptToLossy {
- get => _decryptToLossy;
+ get => field;
set
{
- this.RaiseAndSetIfChanged(ref _decryptToLossy, value);
+ this.RaiseAndSetIfChanged(ref field, value);
if (DecryptToLossy && SpatialAudioCodec.Value is Configuration.SpatialCodec.AC_4)
{
SpatialAudioCodec = SpatialAudioCodecs[0];
@@ -176,20 +164,20 @@ namespace LibationAvalonia.ViewModels.Settings
public string LameDownsampleMonoTip => Configuration.GetHelpText(nameof(LameDownsampleMono));
public bool LameConstantBitrate { get; set; } = Design.IsDesignMode;
- public bool SplitFilesByChapter { get => _splitFilesByChapter; set { this.RaiseAndSetIfChanged(ref _splitFilesByChapter, value); } }
- public bool LameTargetBitrate { get => _lameTargetBitrate; set { this.RaiseAndSetIfChanged(ref _lameTargetBitrate, value); } }
- public bool LameMatchSource { get => _lameMatchSource; set { this.RaiseAndSetIfChanged(ref _lameMatchSource, value); } }
- public int LameBitrate { get => _lameBitrate; set { this.RaiseAndSetIfChanged(ref _lameBitrate, value); } }
- public int LameVBRQuality { get => _lameVBRQuality; set { this.RaiseAndSetIfChanged(ref _lameVBRQuality, value); } }
+ public bool SplitFilesByChapter { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } }
+ public bool LameTargetBitrate { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } }
+ public bool LameMatchSource { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } }
+ public int LameBitrate { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } }
+ public int LameVBRQuality { get => field; set { this.RaiseAndSetIfChanged(ref field, value); } }
public string ChapterTitleTemplate { get => _chapterTitleTemplate; set { this.RaiseAndSetIfChanged(ref _chapterTitleTemplate, value); } }
public bool AllowLibationFixup
{
- get => _allowLibationFixup;
+ get => field;
set
{
- if (!this.RaiseAndSetIfChanged(ref _allowLibationFixup, value))
+ if (!this.RaiseAndSetIfChanged(ref field, value))
{
SplitFilesByChapter = false;
StripAudibleBrandAudio = false;
diff --git a/Source/LibationAvalonia/Views/MainWindow.axaml.cs b/Source/LibationAvalonia/Views/MainWindow.axaml.cs
index 37e9c016..53e0bf1f 100644
--- a/Source/LibationAvalonia/Views/MainWindow.axaml.cs
+++ b/Source/LibationAvalonia/Views/MainWindow.axaml.cs
@@ -150,6 +150,8 @@ namespace LibationAvalonia.Views
{
productsDisplay?.CloseImageDisplay();
this.SaveSizeAndLocation(Configuration.Instance);
+ //This is double firing with 11.3.9
+ Closing -= MainWindow_Closing;
}
private void selectAndFocusSearchBox()
diff --git a/Source/LibationCli/ConsoleProgressBar.cs b/Source/LibationCli/ConsoleProgressBar.cs
index 44231680..6a42bffc 100644
--- a/Source/LibationCli/ConsoleProgressBar.cs
+++ b/Source/LibationCli/ConsoleProgressBar.cs
@@ -12,10 +12,10 @@ internal class ConsoleProgressBar
public double? Progress
{
- get => m_Progress;
+ get => field;
set
{
- m_Progress = value ?? 0;
+ field = value ?? 0;
WriteProgress();
}
}
diff --git a/Source/LibationFileManager/Templates/Templates.cs b/Source/LibationFileManager/Templates/Templates.cs
index d2a63a86..aa44e552 100644
--- a/Source/LibationFileManager/Templates/Templates.cs
+++ b/Source/LibationFileManager/Templates/Templates.cs
@@ -86,11 +86,10 @@ namespace LibationFileManager.Templates
=> NamingTemplate?.TagsInUse.Cast() ?? Enumerable.Empty();
public string TemplateText => NamingTemplate?.TemplateText ?? "";
- private readonly NamingTemplate? _namingTemplate;
protected NamingTemplate NamingTemplate
{
- get => _namingTemplate ?? throw new NullReferenceException(nameof(_namingTemplate));
- private init => _namingTemplate = value;
+ get => field ?? throw new NullReferenceException(nameof(NamingTemplate));
+ private init => field = value;
}
#endregion
diff --git a/Source/LibationSearchEngine/LibationSearchEngine.csproj b/Source/LibationSearchEngine/LibationSearchEngine.csproj
index 06a79c85..d2e28ad2 100644
--- a/Source/LibationSearchEngine/LibationSearchEngine.csproj
+++ b/Source/LibationSearchEngine/LibationSearchEngine.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/Source/LibationUiBase/GridView/EntryStatus.cs b/Source/LibationUiBase/GridView/EntryStatus.cs
index 71cb5a13..b0d7ccb7 100644
--- a/Source/LibationUiBase/GridView/EntryStatus.cs
+++ b/Source/LibationUiBase/GridView/EntryStatus.cs
@@ -32,12 +32,12 @@ namespace LibationUiBase.GridView
public bool Expanded
{
- get => expanded;
+ get => field;
set
{
- if (value != expanded)
+ if (value != field)
{
- expanded = value;
+ field = value;
Invalidate(nameof(Expanded), nameof(ButtonImage));
}
}
@@ -59,7 +59,6 @@ namespace LibationUiBase.GridView
private DateTime lastBookUpdate;
private LiberatedStatus bookStatus;
- private bool expanded;
private readonly bool isAbsent;
private static readonly Dictionary iconCache = new();
diff --git a/Source/LibationUiBase/GridView/GridEntry.cs b/Source/LibationUiBase/GridView/GridEntry.cs
index 754a3324..acb7e6fd 100644
--- a/Source/LibationUiBase/GridView/GridEntry.cs
+++ b/Source/LibationUiBase/GridView/GridEntry.cs
@@ -32,44 +32,27 @@ namespace LibationUiBase.GridView
#region Model properties exposed to the view
protected bool? remove = false;
- private EntryStatus _liberate;
- private string _purchasedate;
- private string _length;
- private LastDownloadStatus _lastDownload;
private Lazy