From 9170751cefc9c83a3a7cc73b372a0a5a8e5a8850 Mon Sep 17 00:00:00 2001 From: Ola Fjelddahl Date: Thu, 21 Sep 2023 19:56:22 +0200 Subject: [PATCH] Update Avalonia 0.10 => 11.04 --- PurpleExplorer/{App.xaml => App.axaml} | 5 ++--- PurpleExplorer/{App.xaml.cs => App.axaml.cs} | 2 +- PurpleExplorer/Helpers/MessageBoxHelper.cs | 9 ++++----- PurpleExplorer/Helpers/TopicHelper.cs | 1 - PurpleExplorer/Program.cs | 11 +++++++---- PurpleExplorer/PurpleExplorer.csproj | 17 +++++++++-------- PurpleExplorer/ViewLocator.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 2 +- .../ViewModels/MessageDetailsWindowViewModel.cs | 2 +- PurpleExplorer/Views/AddMessageWindow.xaml | 2 +- .../Views/ConnectionStringWindow.xaml | 2 +- .../Views/ConnectionStringWindow.xaml.cs | 2 +- PurpleExplorer/Views/MainWindow.xaml | 8 ++++---- PurpleExplorer/Views/MainWindow.xaml.cs | 6 +++--- PurpleExplorer/Views/MessageDetailsWindow.xaml | 7 ++++--- 15 files changed, 40 insertions(+), 38 deletions(-) rename PurpleExplorer/{App.xaml => App.axaml} (81%) rename PurpleExplorer/{App.xaml.cs => App.axaml.cs} (98%) diff --git a/PurpleExplorer/App.xaml b/PurpleExplorer/App.axaml similarity index 81% rename from PurpleExplorer/App.xaml rename to PurpleExplorer/App.axaml index 31c2ef3..d79ef7b 100644 --- a/PurpleExplorer/App.xaml +++ b/PurpleExplorer/App.axaml @@ -9,10 +9,9 @@ - - - + + diff --git a/PurpleExplorer/App.xaml.cs b/PurpleExplorer/App.axaml.cs similarity index 98% rename from PurpleExplorer/App.xaml.cs rename to PurpleExplorer/App.axaml.cs index 57d9e45..456bf2a 100644 --- a/PurpleExplorer/App.xaml.cs +++ b/PurpleExplorer/App.axaml.cs @@ -31,7 +31,7 @@ public override void OnFrameworkInitializationCompleted() RxApp.SuspensionHost.CreateNewAppState = () => new AppState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver(appStatePath)); suspension.OnFrameworkInitializationCompleted(); - var state = RxApp.SuspensionHost.GetAppState(); + var state = RxApp.SuspensionHost.GetAppState() ?? new AppState(); Locator.CurrentMutable.RegisterLazySingleton(() => state, typeof(IAppState)); Locator.CurrentMutable.RegisterLazySingleton(() => new LoggingService(), typeof(ILoggingService)); diff --git a/PurpleExplorer/Helpers/MessageBoxHelper.cs b/PurpleExplorer/Helpers/MessageBoxHelper.cs index 6f418b4..00ee3cc 100644 --- a/PurpleExplorer/Helpers/MessageBoxHelper.cs +++ b/PurpleExplorer/Helpers/MessageBoxHelper.cs @@ -1,7 +1,7 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; -using MessageBox.Avalonia.DTO; -using MessageBox.Avalonia.Enums; +using MsBox.Avalonia.Dto; +using MsBox.Avalonia.Enums; using System.Threading.Tasks; namespace PurpleExplorer.Helpers; @@ -27,7 +27,7 @@ public static async Task ShowMessage(string title, string message) private static async Task ShowMessageBox(ButtonEnum buttons, Icon icon, string title, string message) { - var msBoxStandardWindow = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams + var msBoxStandardWindow = MsBox.Avalonia.MessageBoxManager.GetMessageBoxStandard(new MessageBoxStandardParams { ButtonDefinitions = buttons, ContentTitle = title, @@ -38,7 +38,6 @@ private static async Task ShowMessageBox(ButtonEnum buttons, Icon WindowStartupLocation = Avalonia.Controls.WindowStartupLocation.CenterOwner }); - return await msBoxStandardWindow.ShowDialog((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime) - .Windows[0]); + return await msBoxStandardWindow.ShowAsync(); } } \ No newline at end of file diff --git a/PurpleExplorer/Helpers/TopicHelper.cs b/PurpleExplorer/Helpers/TopicHelper.cs index 9774ee4..a8d4873 100644 --- a/PurpleExplorer/Helpers/TopicHelper.cs +++ b/PurpleExplorer/Helpers/TopicHelper.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using AvaloniaEdit.Utils; using Message = PurpleExplorer.Models.Message; using AzureMessage = Microsoft.Azure.ServiceBus.Message; diff --git a/PurpleExplorer/Program.cs b/PurpleExplorer/Program.cs index e246488..2a30510 100644 --- a/PurpleExplorer/Program.cs +++ b/PurpleExplorer/Program.cs @@ -15,10 +15,13 @@ public static void Main(string[] args) => BuildAvaloniaApp() // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() + { + IconProvider.Current + .Register(); + + return AppBuilder.Configure() .UsePlatformDetect() .LogToTrace() - .UseReactiveUI() - .WithIcons(container => container - .Register()); + .UseReactiveUI(); + } } \ No newline at end of file diff --git a/PurpleExplorer/PurpleExplorer.csproj b/PurpleExplorer/PurpleExplorer.csproj index f4ab090..67b7f5b 100644 --- a/PurpleExplorer/PurpleExplorer.csproj +++ b/PurpleExplorer/PurpleExplorer.csproj @@ -18,16 +18,17 @@ - - - + + + - - - + + + + - - + + diff --git a/PurpleExplorer/ViewLocator.cs b/PurpleExplorer/ViewLocator.cs index 54e0886..b4129c6 100644 --- a/PurpleExplorer/ViewLocator.cs +++ b/PurpleExplorer/ViewLocator.cs @@ -12,7 +12,7 @@ public class ViewLocator : IDataTemplate { public bool SupportsRecycling => false; - 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/PurpleExplorer/ViewModels/MainWindowViewModel.cs b/PurpleExplorer/ViewModels/MainWindowViewModel.cs index b494206..15ea22f 100644 --- a/PurpleExplorer/ViewModels/MainWindowViewModel.cs +++ b/PurpleExplorer/ViewModels/MainWindowViewModel.cs @@ -8,7 +8,7 @@ using PurpleExplorer.Views; using ReactiveUI; using System.Threading.Tasks; -using MessageBox.Avalonia.Enums; +using MsBox.Avalonia.Enums; using Microsoft.Azure.ServiceBus; using PurpleExplorer.Services; using Splat; diff --git a/PurpleExplorer/ViewModels/MessageDetailsWindowViewModel.cs b/PurpleExplorer/ViewModels/MessageDetailsWindowViewModel.cs index 2cfd0ab..9ff2a0d 100644 --- a/PurpleExplorer/ViewModels/MessageDetailsWindowViewModel.cs +++ b/PurpleExplorer/ViewModels/MessageDetailsWindowViewModel.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using Avalonia.Controls; -using MessageBox.Avalonia.Enums; +using MsBox.Avalonia.Enums; using PurpleExplorer.Helpers; using PurpleExplorer.Models; using PurpleExplorer.Services; diff --git a/PurpleExplorer/Views/AddMessageWindow.xaml b/PurpleExplorer/Views/AddMessageWindow.xaml index 71b86d1..743f2a6 100644 --- a/PurpleExplorer/Views/AddMessageWindow.xaml +++ b/PurpleExplorer/Views/AddMessageWindow.xaml @@ -47,7 +47,7 @@ TextWrapping="Wrap" Text="{Binding Path=Title, Mode=TwoWay}" Watermark="Save message with title:" /> - diff --git a/PurpleExplorer/Views/ConnectionStringWindow.xaml b/PurpleExplorer/Views/ConnectionStringWindow.xaml index df3d084..172d8cc 100644 --- a/PurpleExplorer/Views/ConnectionStringWindow.xaml +++ b/PurpleExplorer/Views/ConnectionStringWindow.xaml @@ -51,7 +51,7 @@ diff --git a/PurpleExplorer/Views/ConnectionStringWindow.xaml.cs b/PurpleExplorer/Views/ConnectionStringWindow.xaml.cs index 5aaa7ea..2f85630 100644 --- a/PurpleExplorer/Views/ConnectionStringWindow.xaml.cs +++ b/PurpleExplorer/Views/ConnectionStringWindow.xaml.cs @@ -80,7 +80,7 @@ public void OnClose(object? sender, RoutedEventArgs args) /// but I cannot get the code to work. Possibly because the present version of Avalonia is 11 but I am working a 0.10. /// /// - private static void SetFocus(IInputElement ctrl) + private static void SetFocus(InputElement ctrl) { ctrl.AttachedToVisualTree += (_,_) => ctrl.Focus(); } diff --git a/PurpleExplorer/Views/MainWindow.xaml b/PurpleExplorer/Views/MainWindow.xaml index 1b8f9c1..c74f924 100644 --- a/PurpleExplorer/Views/MainWindow.xaml +++ b/PurpleExplorer/Views/MainWindow.xaml @@ -88,7 +88,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -161,7 +161,7 @@ - @@ -176,7 +176,7 @@ - diff --git a/PurpleExplorer/Views/MainWindow.xaml.cs b/PurpleExplorer/Views/MainWindow.xaml.cs index d22bc82..48809b0 100644 --- a/PurpleExplorer/Views/MainWindow.xaml.cs +++ b/PurpleExplorer/Views/MainWindow.xaml.cs @@ -1,7 +1,7 @@ using System; using Avalonia; using Avalonia.Controls; -using Avalonia.Interactivity; +using Avalonia.Input; using Avalonia.Markup.Xaml; using PurpleExplorer.Helpers; using PurpleExplorer.Models; @@ -32,7 +32,7 @@ protected override async void OnOpened(EventArgs e) base.OnOpened(e); } - private async void MessagesGrid_DoubleTapped(object sender, RoutedEventArgs e) + private async void MessagesGrid_DoubleTapped(object sender, TappedEventArgs e) { var grid = sender as DataGrid; var mainWindowViewModel = DataContext as MainWindowViewModel; @@ -53,7 +53,7 @@ private async void MessagesGrid_DoubleTapped(object sender, RoutedEventArgs e) await ModalWindowHelper.ShowModalWindow(viewModal); } - private void MessagesGrid_Tapped(object sender, RoutedEventArgs e) + private void MessagesGrid_Tapped(object sender, TappedEventArgs e) { var grid = sender as DataGrid; var mainWindowViewModel = DataContext as MainWindowViewModel; diff --git a/PurpleExplorer/Views/MessageDetailsWindow.xaml b/PurpleExplorer/Views/MessageDetailsWindow.xaml index 330a6a7..f7fd8c3 100644 --- a/PurpleExplorer/Views/MessageDetailsWindow.xaml +++ b/PurpleExplorer/Views/MessageDetailsWindow.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="780" d:DesignHeight="630" x:Class="PurpleExplorer.Views.MessageDetailsWindow" xmlns:vm="clr-namespace:PurpleExplorer.ViewModels;assembly=PurpleExplorer" @@ -46,7 +47,7 @@ Command="{Binding DeleteMessage}" CommandParameter="{Binding $parent[Window]}"> - + Delete message @@ -54,7 +55,7 @@ IsVisible="{Binding !Message.IsDlq}" Classes="topButton"> - + Send to dead-letter @@ -62,7 +63,7 @@ IsVisible="{Binding !!Message.IsDlq}" Classes="topButton"> - + Resubmit back to topic