diff --git a/Source/HangoverAvalonia/App.axaml b/Source/HangoverAvalonia/App.axaml index f4f24946..0534c7e8 100644 --- a/Source/HangoverAvalonia/App.axaml +++ b/Source/HangoverAvalonia/App.axaml @@ -7,6 +7,6 @@ - + diff --git a/Source/HangoverAvalonia/HangoverAvalonia.csproj b/Source/HangoverAvalonia/HangoverAvalonia.csproj index af95f39e..fb32461e 100644 --- a/Source/HangoverAvalonia/HangoverAvalonia.csproj +++ b/Source/HangoverAvalonia/HangoverAvalonia.csproj @@ -66,13 +66,13 @@ - - + + - - - - + + + + diff --git a/Source/HangoverAvalonia/ViewLocator.cs b/Source/HangoverAvalonia/ViewLocator.cs index 44467ea7..8756c78d 100644 --- a/Source/HangoverAvalonia/ViewLocator.cs +++ b/Source/HangoverAvalonia/ViewLocator.cs @@ -7,7 +7,7 @@ namespace HangoverAvalonia { public class ViewLocator : IDataTemplate { - public IControl Build(object data) + public Control Build(object data) { var name = data.GetType().FullName!.Replace("ViewModel", "View"); var type = Type.GetType(name); diff --git a/Source/HangoverBase/DatabaseTab.cs b/Source/HangoverBase/DatabaseTab.cs index b9bcc88d..6c58b0f3 100644 --- a/Source/HangoverBase/DatabaseTab.cs +++ b/Source/HangoverBase/DatabaseTab.cs @@ -64,7 +64,8 @@ namespace HangoverBase try { - var sql = _commands.SqlInput().Trim(); + var sql = _commands.SqlInput()?.Trim(); + if (sql is null) return; #region // explanation // Routing statements to non-query is a convenience. diff --git a/Source/LibationAvalonia/App.axaml b/Source/LibationAvalonia/App.axaml index 9e8d399d..e76d03e1 100644 --- a/Source/LibationAvalonia/App.axaml +++ b/Source/LibationAvalonia/App.axaml @@ -8,10 +8,9 @@ - - - - + + + \ No newline at end of file diff --git a/Source/LibationAvalonia/Assets/DataGridTheme.xaml b/Source/LibationAvalonia/Assets/DataGridTheme.xaml deleted file mode 100644 index 904b6a2b..00000000 --- a/Source/LibationAvalonia/Assets/DataGridTheme.xaml +++ /dev/null @@ -1,658 +0,0 @@ - - - 0.6 - 0.8 - 12,0,12,0 - - M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z - M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z - M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/LibationAvalonia/AvaloniaUtils.cs b/Source/LibationAvalonia/AvaloniaUtils.cs index 9a1090be..842777cf 100644 --- a/Source/LibationAvalonia/AvaloniaUtils.cs +++ b/Source/LibationAvalonia/AvaloniaUtils.cs @@ -1,6 +1,7 @@ using Avalonia.Controls; using Avalonia.Media; using Avalonia.Media.Imaging; +using Avalonia.VisualTree; using LibationAvalonia.Dialogs; using LibationFileManager; using System.Threading.Tasks; @@ -13,7 +14,8 @@ namespace LibationAvalonia => GetBrushFromResources(name, Brushes.Transparent); public static IBrush GetBrushFromResources(string name, IBrush defaultBrush) { - if (App.Current.Styles.TryGetResource(name, out var value) && value is IBrush brush) + //TODO: use ThemeVariant + if (App.Current.Styles.TryGetResource(name, null, out var value) && value is IBrush brush) return brush; return defaultBrush; } @@ -21,7 +23,7 @@ namespace LibationAvalonia public static Task ShowDialogAsync(this DialogWindow dialogWindow, Window owner = null) => dialogWindow.ShowDialog(owner ?? App.MainWindow); - public static Window GetParentWindow(this IControl control) => control.VisualRoot as Window; + public static Window GetParentWindow(this Control control) => control.GetVisualRoot() as Window; private static Bitmap defaultImage; diff --git a/Source/LibationAvalonia/Controls/DataGridCheckBoxColumnExt.cs b/Source/LibationAvalonia/Controls/DataGridCheckBoxColumnExt.cs index de44df9a..eca89804 100644 --- a/Source/LibationAvalonia/Controls/DataGridCheckBoxColumnExt.cs +++ b/Source/LibationAvalonia/Controls/DataGridCheckBoxColumnExt.cs @@ -5,7 +5,7 @@ namespace LibationAvalonia.Controls { public class DataGridCheckBoxColumnExt : DataGridCheckBoxColumn { - protected override IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem) + protected override Control GenerateEditingElementDirect(DataGridCell cell, object dataItem) { //Only SeriesEntry types have three-state checks, individual LibraryEntry books are binary. var ele = base.GenerateEditingElementDirect(cell, dataItem) as CheckBox; diff --git a/Source/LibationAvalonia/Controls/DataGridMyRatingColumn.cs b/Source/LibationAvalonia/Controls/DataGridMyRatingColumn.cs index 5a655ceb..41b2be6f 100644 --- a/Source/LibationAvalonia/Controls/DataGridMyRatingColumn.cs +++ b/Source/LibationAvalonia/Controls/DataGridMyRatingColumn.cs @@ -18,7 +18,7 @@ namespace LibationAvalonia.Controls BindingTarget = MyRatingCellEditor.RatingProperty; } - protected override IControl GenerateElement(DataGridCell cell, object dataItem) + protected override Control GenerateElement(DataGridCell cell, object dataItem) { var myRatingElement = new MyRatingCellEditor { @@ -41,7 +41,7 @@ namespace LibationAvalonia.Controls return myRatingElement; } - protected override IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem) + protected override Control GenerateEditingElementDirect(DataGridCell cell, object dataItem) { var myRatingElement = new MyRatingCellEditor { @@ -57,12 +57,12 @@ namespace LibationAvalonia.Controls return myRatingElement; } - protected override object PrepareCellForEdit(IControl editingElement, RoutedEventArgs editingEventArgs) + protected override object PrepareCellForEdit(Control editingElement, RoutedEventArgs editingEventArgs) => editingElement is MyRatingCellEditor myRating ? myRating.Rating : DefaultRating; - protected override void CancelCellEdit(IControl editingElement, object uneditedValue) + protected override void CancelCellEdit(Control editingElement, object uneditedValue) { if (editingElement is MyRatingCellEditor myRating) { diff --git a/Source/LibationAvalonia/Controls/DataGridTemplateColumnExt.cs b/Source/LibationAvalonia/Controls/DataGridTemplateColumnExt.cs index bf5d84e3..b1ed35c7 100644 --- a/Source/LibationAvalonia/Controls/DataGridTemplateColumnExt.cs +++ b/Source/LibationAvalonia/Controls/DataGridTemplateColumnExt.cs @@ -6,7 +6,7 @@ namespace LibationAvalonia.Controls { public partial class DataGridTemplateColumnExt : DataGridTemplateColumn { - protected override IControl GenerateElement(DataGridCell cell, object dataItem) + protected override Control GenerateElement(DataGridCell cell, object dataItem) { cell?.AttachContextMenu(); return base.GenerateElement(cell, dataItem); diff --git a/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs b/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs index f5ff3746..338e48e7 100644 --- a/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs +++ b/Source/LibationAvalonia/Controls/DirectoryOrCustomSelectControl.axaml.cs @@ -97,12 +97,7 @@ namespace LibationAvalonia.Controls var selectedFolders = await (VisualRoot as Window).StorageProvider.OpenFolderPickerAsync(options); - customStates.CustomDir = - selectedFolders - .SingleOrDefault()?. - TryGetUri(out var uri) is true - ? uri.LocalPath - : customStates.CustomDir; + customStates.CustomDir = selectedFolders.SingleOrDefault()?.Path?.LocalPath ?? customStates.CustomDir; } private void CheckStates_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -180,10 +175,5 @@ namespace LibationAvalonia.Controls return path; } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Controls/DirectorySelectControl.axaml.cs b/Source/LibationAvalonia/Controls/DirectorySelectControl.axaml.cs index f9dae279..5cb84725 100644 --- a/Source/LibationAvalonia/Controls/DirectorySelectControl.axaml.cs +++ b/Source/LibationAvalonia/Controls/DirectorySelectControl.axaml.cs @@ -90,10 +90,5 @@ namespace LibationAvalonia.Controls get => GetValue(SubDirectoryProperty); set => SetValue(SubDirectoryProperty, value); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Controls/GroupBox.axaml.cs b/Source/LibationAvalonia/Controls/GroupBox.axaml.cs index 41bf2e2f..bf9a72b8 100644 --- a/Source/LibationAvalonia/Controls/GroupBox.axaml.cs +++ b/Source/LibationAvalonia/Controls/GroupBox.axaml.cs @@ -29,10 +29,5 @@ namespace LibationAvalonia.Controls get { return GetValue(LabelProperty); } set { SetValue(LabelProperty, value); } } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs b/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs index 951c6919..ac31ff40 100644 --- a/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs +++ b/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs @@ -33,10 +33,5 @@ namespace LibationAvalonia.Controls this.Cursor = Cursor.Default; base.OnPointerExited(e); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs b/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs index 0af4d398..9658ec3e 100644 --- a/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs +++ b/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs @@ -26,10 +26,5 @@ namespace LibationAvalonia.Controls base.OnPointerWheelChanged(e); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs index da450e0d..e2da5d21 100644 --- a/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/AccountsDialog.axaml.cs @@ -129,16 +129,16 @@ namespace LibationAvalonia.Dialogs string audibleAppDataDir = GetAudibleCliAppDataPath(); if (Directory.Exists(audibleAppDataDir)) - openFileDialogOptions.SuggestedStartLocation = new BclStorageFolder(audibleAppDataDir); + openFileDialogOptions.SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(audibleAppDataDir); var selectedFiles = await StorageProvider.OpenFilePickerAsync(openFileDialogOptions); - var selectedFile = selectedFiles.SingleOrDefault(); + var selectedFile = selectedFiles.SingleOrDefault()?.TryGetLocalPath(); - if (selectedFile?.TryGetUri(out var uri) is not true) return; + if (selectedFile is null) return; try { - var jsonText = File.ReadAllText(uri.LocalPath); + var jsonText = File.ReadAllText(selectedFile); var mkbAuth = Mkb79Auth.FromJson(jsonText); var account = await mkbAuth.ToAccountAsync(); @@ -159,7 +159,7 @@ namespace LibationAvalonia.Dialogs { await MessageBox.ShowAdminAlert( this, - $"An error occurred while importing an account from:\r\n{uri.LocalPath}\r\n\r\nIs the file encrypted?", + $"An error occurred while importing an account from:\r\n{selectedFile}\r\n\r\nIs the file encrypted?", "Error Importing Account", ex); } @@ -196,12 +196,6 @@ namespace LibationAvalonia.Dialogs public async void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e) => await SaveAndCloseAsync(); - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - private void persist(AccountsSettings accountsSettings) { var existingAccounts = accountsSettings.Accounts; @@ -293,20 +287,20 @@ namespace LibationAvalonia.Dialogs string audibleAppDataDir = GetAudibleCliAppDataPath(); if (Directory.Exists(audibleAppDataDir)) - options.SuggestedStartLocation = new BclStorageFolder(audibleAppDataDir); + options.SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(audibleAppDataDir); - var selectedFile = await StorageProvider.SaveFilePickerAsync(options); + var selectedFile = (await StorageProvider.SaveFilePickerAsync(options))?.TryGetLocalPath(); - if (selectedFile?.TryGetUri(out var uri) is not true) return; + if (selectedFile is null) return; try { var mkbAuth = Mkb79Auth.FromAccount(account); var jsonText = mkbAuth.ToJson(); - File.WriteAllText(uri.LocalPath, jsonText); + File.WriteAllText(selectedFile, jsonText); - await MessageBox.Show(this, $"Successfully exported {account.AccountName} to\r\n\r\n{uri.LocalPath}", "Success!"); + await MessageBox.Show(this, $"Successfully exported {account.AccountName} to\r\n\r\n{selectedFile}", "Success!"); } catch (Exception ex) { diff --git a/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs index 2896c08b..5f825f44 100644 --- a/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/BookDetailsDialog.axaml.cs @@ -63,11 +63,6 @@ namespace LibationAvalonia.Dialogs public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e) => SaveAndClose(); - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - private class BookDetailsDialogViewModel : ViewModelBase { public class liberatedComboBoxItem diff --git a/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs index fc4a4012..1389e0d7 100644 --- a/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/BookRecordsDialog.axaml.cs @@ -172,23 +172,23 @@ namespace LibationAvalonia.Dialogs } }); - var selectedFile = await StorageProvider.SaveFilePickerAsync(saveFileDialog); + var selectedFile = (await StorageProvider.SaveFilePickerAsync(saveFileDialog))?.TryGetLocalPath(); - if (selectedFile?.TryGetUri(out var uri) is not true) return; + if (selectedFile is null) return; - var ext = System.IO.Path.GetExtension(uri.LocalPath).ToLowerInvariant(); + var ext = System.IO.Path.GetExtension(selectedFile).ToLowerInvariant(); switch (ext) { case ".xlsx": default: - await Task.Run(() => RecordExporter.ToXlsx(uri.LocalPath, records)); + await Task.Run(() => RecordExporter.ToXlsx(selectedFile, records)); break; case ".csv": - await Task.Run(() => RecordExporter.ToCsv(uri.LocalPath, records)); + await Task.Run(() => RecordExporter.ToCsv(selectedFile, records)); break; case ".json": - await Task.Run(() => RecordExporter.ToJson(uri.LocalPath, libraryBook, records)); + await Task.Run(() => RecordExporter.ToJson(selectedFile, libraryBook, records)); break; } } diff --git a/Source/LibationAvalonia/Dialogs/DescriptionDisplayDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/DescriptionDisplayDialog.axaml.cs index a891b98f..1a934173 100644 --- a/Source/LibationAvalonia/Dialogs/DescriptionDisplayDialog.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/DescriptionDisplayDialog.axaml.cs @@ -52,11 +52,5 @@ namespace LibationAvalonia.Dialogs { Close(); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - } } diff --git a/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs b/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs index 9c48d6f4..91b8f039 100644 --- a/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/EditReplacementChars.axaml.cs @@ -170,10 +170,5 @@ namespace LibationAvalonia.Dialogs public char Character => string.IsNullOrEmpty(_characterToReplace) ? default : _characterToReplace[0]; public bool IsDefault { get; private set; } } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml b/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml index ee973cdd..4723e4d0 100644 --- a/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/EditTemplateDialog.axaml @@ -23,7 +23,6 @@ Grid.Column="0" Grid.Row="1" Name="userEditTbox" - FontFamily="{Binding FontFamily}" Text="{Binding UserTemplateText, Mode=TwoWay}" />