From ab92fe2a6317a39cb626f307ecbf50c67fec7e8c Mon Sep 17 00:00:00 2001 From: Eviral Date: Tue, 5 Dec 2023 21:51:27 +0100 Subject: [PATCH] Dialogs fully themed with a lot of demos ! --- .../Avalonia.Themes.Neumorphism.csproj | 4 ++-- .../{ => Converters}/IBitmapToImageConverter.cs | 8 ++++---- .../Dialogs/Views/AlertDialog.axaml.cs | 7 ++++++- .../Dialogs/Views/CommonDialog.axaml.cs | 11 ++++++++--- .../Dialogs/Views/TextFieldDialog.axaml.cs | 4 ++++ Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml | 6 ++++-- .../ViewModels/DialogsDemoViewModel.cs | 3 ++- Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml | 6 +++--- 8 files changed, 33 insertions(+), 16 deletions(-) rename Avalonia.Themes.Neumorphism/{ => Converters}/IBitmapToImageConverter.cs (84%) diff --git a/Avalonia.Themes.Neumorphism/Avalonia.Themes.Neumorphism.csproj b/Avalonia.Themes.Neumorphism/Avalonia.Themes.Neumorphism.csproj index 9503402..b86dcbb 100644 --- a/Avalonia.Themes.Neumorphism/Avalonia.Themes.Neumorphism.csproj +++ b/Avalonia.Themes.Neumorphism/Avalonia.Themes.Neumorphism.csproj @@ -1,7 +1,7 @@  netstandard2.1 - 0.8.0 + 0.9.0 Neumorphism.Avalonia Eviral Eviral @@ -24,7 +24,7 @@ - + diff --git a/Avalonia.Themes.Neumorphism/IBitmapToImageConverter.cs b/Avalonia.Themes.Neumorphism/Converters/IBitmapToImageConverter.cs similarity index 84% rename from Avalonia.Themes.Neumorphism/IBitmapToImageConverter.cs rename to Avalonia.Themes.Neumorphism/Converters/IBitmapToImageConverter.cs index 187ca0b..ab3453a 100644 --- a/Avalonia.Themes.Neumorphism/IBitmapToImageConverter.cs +++ b/Avalonia.Themes.Neumorphism/Converters/IBitmapToImageConverter.cs @@ -4,15 +4,15 @@ using Avalonia.Data.Converters; using Avalonia.Media.Imaging; -namespace Avalonia.Themes.Neumorphism +namespace Avalonia.Themes.Neumorphism.Converters { internal class IBitmapToImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value is Bitmap bm) - return new Image { Source=bm }; - + return new Image { Source = bm }; + return null; } @@ -21,4 +21,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/Avalonia.Themes.Neumorphism/Dialogs/Views/AlertDialog.axaml.cs b/Avalonia.Themes.Neumorphism/Dialogs/Views/AlertDialog.axaml.cs index 693d2bb..83c10e0 100644 --- a/Avalonia.Themes.Neumorphism/Dialogs/Views/AlertDialog.axaml.cs +++ b/Avalonia.Themes.Neumorphism/Dialogs/Views/AlertDialog.axaml.cs @@ -1,4 +1,6 @@ using Avalonia.Controls; +using Avalonia.Media.Imaging; +using Avalonia.Media; using Avalonia.Themes.Neumorphism.Dialogs.Interfaces; using Avalonia.Themes.Neumorphism.Dialogs.ViewModels; @@ -6,8 +8,11 @@ namespace Avalonia.Themes.Neumorphism.Dialogs.Views { public partial class AlertDialog : Window, IDialogWindowResult, IHasNegativeResult { - public AlertDialog() { + public AlertDialog() + { InitializeComponent(); + + RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality); } public DialogResult GetResult() => (DataContext as AlertDialogViewModel)?.DialogResult; diff --git a/Avalonia.Themes.Neumorphism/Dialogs/Views/CommonDialog.axaml.cs b/Avalonia.Themes.Neumorphism/Dialogs/Views/CommonDialog.axaml.cs index 9f7c6cf..0ff8d2f 100644 --- a/Avalonia.Themes.Neumorphism/Dialogs/Views/CommonDialog.axaml.cs +++ b/Avalonia.Themes.Neumorphism/Dialogs/Views/CommonDialog.axaml.cs @@ -1,4 +1,6 @@ using Avalonia.Controls; +using Avalonia.Media; +using Avalonia.Media.Imaging; using Avalonia.Themes.Neumorphism.Dialogs.Interfaces; using Avalonia.Themes.Neumorphism.Dialogs.ViewModels; @@ -6,15 +8,18 @@ namespace Avalonia.Themes.Neumorphism.Dialogs.Views { public partial class CommonDialog : Window, IDialogWindowResult, IHasNegativeResult { - public CommonDialog() { + public CommonDialog() + { InitializeComponent(); + + RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality); } - public DialogResult GetResult() => (DataContext as AlertDialogViewModel)?.DialogResult; + public DialogResult GetResult() => (DataContext as CommonDialogViewModel)?.DialogResult; public void SetNegativeResult(DialogResult result) { - if (DataContext is AlertDialogViewModel viewModel) + if (DataContext is CommonDialogViewModel viewModel) viewModel.DialogResult = result; } } diff --git a/Avalonia.Themes.Neumorphism/Dialogs/Views/TextFieldDialog.axaml.cs b/Avalonia.Themes.Neumorphism/Dialogs/Views/TextFieldDialog.axaml.cs index 147906d..47ae443 100644 --- a/Avalonia.Themes.Neumorphism/Dialogs/Views/TextFieldDialog.axaml.cs +++ b/Avalonia.Themes.Neumorphism/Dialogs/Views/TextFieldDialog.axaml.cs @@ -1,6 +1,8 @@ using System; using Avalonia.Controls; using Avalonia.Controls.Presenters; +using Avalonia.Media.Imaging; +using Avalonia.Media; using Avalonia.Themes.Neumorphism.Dialogs.Interfaces; using Avalonia.Themes.Neumorphism.Dialogs.ViewModels; using Avalonia.Threading; @@ -14,6 +16,8 @@ public TextFieldDialog() { InitializeComponent(); + RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality); + Closed += TextFieldDialog_Closed; Opened += TextFieldDialog_Opened; } diff --git a/Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml b/Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml index 8ba8173..06bc3b9 100644 --- a/Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml +++ b/Avalonia.Themes.Neumorphism/Themes/NativeMenuBar.xaml @@ -1,7 +1,9 @@ - + xmlns:converters="using:Avalonia.Themes.Neumorphism.Converters"> + + + diff --git a/Neumorphism.Avalonia.Demo/ViewModels/DialogsDemoViewModel.cs b/Neumorphism.Avalonia.Demo/ViewModels/DialogsDemoViewModel.cs index 663b24b..25429cc 100644 --- a/Neumorphism.Avalonia.Demo/ViewModels/DialogsDemoViewModel.cs +++ b/Neumorphism.Avalonia.Demo/ViewModels/DialogsDemoViewModel.cs @@ -145,7 +145,7 @@ private async IAsyncEnumerable CreateErrorDialog() var dialog = DialogHelper.CreateAlertDialog(new AlertDialogBuilderParams { ContentHeader = "Error !", - SupportingText = "An error occured !", + SupportingText = "A strange unexpected error occured !", WindowTitle = "Error dialog", DialogHeaderIcon = DialogIconKind.Error, DialogIcon = DialogIconKind.Error, @@ -246,6 +246,7 @@ await DialogHelper.CreateCommonDialog(new CommonDialogBuilderParams StartupLocation = WindowStartupLocation.CenterOwner, DialogHeaderIcon = DialogIconKind.Success, Borderless = true, + Width = 480, }).ShowDialog(_window); _appModelBase.IsDialogOpened = false; diff --git a/Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml b/Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml index a5cf787..0d90f32 100644 --- a/Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml +++ b/Neumorphism.Avalonia.Demo/Windows/MainWindow.axaml @@ -205,12 +205,12 @@ - + @@ -302,7 +302,7 @@ - +