Skip to content

Commit

Permalink
Update Avalonia 0.10 => 11.04
Browse files Browse the repository at this point in the history
  • Loading branch information
LosManos committed Sep 22, 2023
1 parent 7dee794 commit 9170751
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 38 deletions.
5 changes: 2 additions & 3 deletions PurpleExplorer/App.xaml → PurpleExplorer/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
</Application.DataTemplates>

<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Default.xaml"/>
<StyleInclude Source="/Styles/CommonStyles.xaml" />
<SimpleTheme/>
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Simple.xaml"/>
</Application.Styles>

<Design.DataContext>
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/App.xaml.cs → PurpleExplorer/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppState>();
var state = RxApp.SuspensionHost.GetAppState<AppState>() ?? new AppState();

Locator.CurrentMutable.RegisterLazySingleton(() => state, typeof(IAppState));
Locator.CurrentMutable.RegisterLazySingleton(() => new LoggingService(), typeof(ILoggingService));
Expand Down
9 changes: 4 additions & 5 deletions PurpleExplorer/Helpers/MessageBoxHelper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -27,7 +27,7 @@ public static async Task<ButtonResult> ShowMessage(string title, string message)

private static async Task<ButtonResult> 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,
Expand All @@ -38,7 +38,6 @@ private static async Task<ButtonResult> ShowMessageBox(ButtonEnum buttons, Icon
WindowStartupLocation = Avalonia.Controls.WindowStartupLocation.CenterOwner
});

return await msBoxStandardWindow.ShowDialog((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)
.Windows[0]);
return await msBoxStandardWindow.ShowAsync();
}
}
1 change: 0 additions & 1 deletion PurpleExplorer/Helpers/TopicHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 7 additions & 4 deletions PurpleExplorer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<App>()
{
IconProvider.Current
.Register<FontAwesomeIconProvider>();

return AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI()
.WithIcons(container => container
.Register<FontAwesomeIconProvider>());
.UseReactiveUI();
}
}
17 changes: 9 additions & 8 deletions PurpleExplorer/PurpleExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="MessageBox.Avalonia" Version="2.1.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.4" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.4" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.4" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
<PackageReference Include="Projektanker.Icons.Avalonia" Version="5.6.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="5.6.0" />
<PackageReference Include="Projektanker.Icons.Avalonia" Version="8.2.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="8.2.0" />
</ItemGroup>
<ItemGroup>
<None Update="appstate.json">
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/ViewLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ViewLocator : IDataTemplate
{
public bool SupportsRecycling => false;

public IControl Build(object data)
public Control Build(object data)

Check warning on line 15 in PurpleExplorer/ViewLocator.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'data' of 'Control ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because of nullability attributes).

Check warning on line 15 in PurpleExplorer/ViewLocator.cs

View workflow job for this annotation

GitHub Actions / publish

Nullability of reference types in type of parameter 'data' of 'Control ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because of nullability attributes).

Check warning on line 15 in PurpleExplorer/ViewLocator.cs

View workflow job for this annotation

GitHub Actions / publish

Nullability of reference types in type of parameter 'data' of 'Control ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because of nullability attributes).

Check warning on line 15 in PurpleExplorer/ViewLocator.cs

View workflow job for this annotation

GitHub Actions / publish

Nullability of reference types in type of parameter 'data' of 'Control ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because of nullability attributes).

Check warning on line 15 in PurpleExplorer/ViewLocator.cs

View workflow job for this annotation

GitHub Actions / publish

Nullability of reference types in type of parameter 'data' of 'Control ViewLocator.Build(object data)' doesn't match implicitly implemented member 'Control? ITemplate<object?, Control?>.Build(object? param)' (possibly because of nullability attributes).
{
var name = data.GetType().FullName.Replace("ViewModel", "View");
var type = Type.GetType(name);
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/ViewModels/MessageDetailsWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/Views/AddMessageWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
TextWrapping="Wrap" Text="{Binding Path=Title, Mode=TwoWay}" Watermark="Save message with title:" />
</StackPanel>

<DataGrid Grid.Row="2" Name="dgSavedMessages" Items="{Binding Path=SavedMessages, Mode=TwoWay}"
<DataGrid Grid.Row="2" Name="dgSavedMessages" ItemsSource="{Binding Path=SavedMessages, Mode=TwoWay}"
SelectionChanged="messageSelectionChanged"
IsReadOnly="True">
<DataGrid.Columns>
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/Views/ConnectionStringWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</DockPanel>

<DataGrid Grid.Row="6" Name="lsbSavedConnectionString" Margin="5, 0, 5, 0"
Items="{Binding Path=SavedConnectionStrings, Mode=TwoWay}"
ItemsSource="{Binding Path=SavedConnectionStrings, Mode=TwoWay}"
Height="300"
SelectionChanged="lsbConnectionStringSelectionChanged">
<DataGrid.Columns>
Expand Down
2 changes: 1 addition & 1 deletion PurpleExplorer/Views/ConnectionStringWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
/// <param name="ctrl"></param>
private static void SetFocus(IInputElement ctrl)
private static void SetFocus(InputElement ctrl)
{
ctrl.AttachedToVisualTree += (_,_) => ctrl.Focus();
}
Expand Down
8 changes: 4 additions & 4 deletions PurpleExplorer/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<DockPanel Grid.Column="0" Grid.Row="1" Dock="Left">
<TabControl Width="300">
<TabItem Header="{Binding TopicTabHeader}">
<TreeView SelectionChanged="TreeView_SelectionChanged" Items="{Binding ConnectedServiceBuses}" Name="tvTopics">
<TreeView SelectionChanged="TreeView_SelectionChanged" ItemsSource="{Binding ConnectedServiceBuses}" Name="tvTopics">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="models:ServiceBusResource" ItemsSource="{Binding Topics}">
<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -126,7 +126,7 @@
</TreeView>
</TabItem>
<TabItem Header="{Binding QueueTabHeader}">
<TreeView SelectionChanged="TreeView_SelectionChanged" Items="{Binding ConnectedServiceBuses}" Name="tvQueues">
<TreeView SelectionChanged="TreeView_SelectionChanged" ItemsSource="{Binding ConnectedServiceBuses}" Name="tvQueues">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="models:ServiceBusResource" ItemsSource="{Binding Queues}">
<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -161,7 +161,7 @@

<TabControl>
<TabItem Header="{Binding MessagesTabHeader}" VerticalContentAlignment="Center">
<DataGrid Items="{Binding Messages}" Tapped="MessagesGrid_Tapped"
<DataGrid ItemsSource="{Binding Messages}" Tapped="MessagesGrid_Tapped"
DoubleTapped="MessagesGrid_DoubleTapped"
IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DataGrid.Columns>
Expand All @@ -176,7 +176,7 @@
</DataGrid>
</TabItem>
<TabItem Header="{Binding DlqTabHeader}" VerticalContentAlignment="Center">
<DataGrid Items="{Binding DlqMessages}" Tapped="MessagesGrid_Tapped"
<DataGrid ItemsSource="{Binding DlqMessages}" Tapped="MessagesGrid_Tapped"
DoubleTapped="MessagesGrid_DoubleTapped" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Sequence Number" Binding="{Binding SequenceNumber}" />
Expand Down
6 changes: 3 additions & 3 deletions PurpleExplorer/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -53,7 +53,7 @@ private async void MessagesGrid_DoubleTapped(object sender, RoutedEventArgs e)
await ModalWindowHelper.ShowModalWindow<MessageDetailsWindow, MessageDetailsWindowViewModel>(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;
Expand Down
7 changes: 4 additions & 3 deletions PurpleExplorer/Views/MessageDetailsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -46,23 +47,23 @@
Command="{Binding DeleteMessage}"
CommandParameter="{Binding $parent[Window]}">
<StackPanel Orientation="Horizontal">
<DrawingPresenter Drawing="{DynamicResource Material.Delete}" />
<i:Icon Value="fa-trash" />
<TextBlock VerticalAlignment="Center">Delete message</TextBlock>
</StackPanel>
</Button>
<Button Command="{Binding DeadletterMessage}"
IsVisible="{Binding !Message.IsDlq}"
Classes="topButton">
<StackPanel Orientation="Horizontal">
<DrawingPresenter Drawing="{DynamicResource Material.EmailSend}" />
<i:Icon Value="fa-envelope" />
<TextBlock VerticalAlignment="Center">Send to dead-letter</TextBlock>
</StackPanel>
</Button>
<Button Name="ResendButton" Command="{Binding ResubmitMessage}"
IsVisible="{Binding !!Message.IsDlq}"
Classes="topButton">
<StackPanel Orientation="Horizontal">
<DrawingPresenter Drawing="{DynamicResource Material.EmailSend}" />
<i:Icon Value="fa-envelope" />
<TextBlock VerticalAlignment="Center">Resubmit back to topic</TextBlock>
</StackPanel>
</Button>
Expand Down

0 comments on commit 9170751

Please sign in to comment.