some fixes for avalonia 0.9
MODIFY
WalletWasabi.Gui/App.xaml
WalletWasabi.Gui/App.xaml
<Application.DataTemplates>
<DataTemplate DataType="Views:MainView">
<Grid>
- <ContentControl Content="{Binding CurrentView}" />
+ <ContentControl Content="{Binding ActiveDockable}" />
</Grid>
</DataTemplate>
- <DataTemplate DataType="id:IView">
+ <DataTemplate DataType="id:IDockable">
<cont:ViewModelViewHost DataContext="{Binding Context}" />
</DataTemplate>
</Application.DataTemplates>

MODIFY
WalletWasabi.Gui/App.xaml.cs
WalletWasabi.Gui/App.xaml.cs
using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
+using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Gui
{
@@ -9,5 +11,18 @@ namespace WalletWasabi.Gui
{
AvaloniaXamlLoader.Load(this);
}
+
+ public override void OnFrameworkInitializationCompleted()
+ {
+ if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ desktop.MainWindow = new MainWindow()
+ {
+ DataContext = MainWindowViewModel.Instance
+ };
+ }
+
+ base.OnFrameworkInitializationCompleted();
+ }
}
}

MODIFY
WalletWasabi.Gui/MainWindow.xaml
WalletWasabi.Gui/MainWindow.xaml
Width="{Binding Width}" Height="{Binding Height}"
WindowState="{Binding WindowState}"
UseLayoutRounding="True"
- RenderOptions.BitmapInterpolationMode="HighQuality"
- id:DragBehavior.IsEnabled="False" id:DropBehavior.IsEnabled="False">
+ RenderOptions.BitmapInterpolationMode="HighQuality">
<cont:MetroWindow.TitleBarContent>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !LockScreen.IsLocked}">
<menu:MainMenuView DataContext="{Binding Shell.MainMenu}" Margin="4 0 0 0" Foreground="{DynamicResource ThemeForegroundBrush}" VerticalAlignment="Stretch" FontSize="13" />
<Setter Property="Padding" Value="7 0" />
</Style>
</cont:MetroWindow.Styles>
- <Grid>
+ <Grid id:DockProperties.IsDropArea="False">
<DockPanel LastChildFill="True">
<wasabi:StatusBar DockPanel.Dock="Bottom" DataContext="{Binding StatusBar}" />
<shell:ShellView DataContext="{Binding Shell}" />

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -20,14 +20,13 @@ namespace WalletWasabi.Gui
{
internal class Program
{
+ private static StatusBarViewModel StatusBar = null;
private static Global Global;
#pragma warning disable IDE1006 // Naming Styles
private static async Task Main(string[] args)
#pragma warning restore IDE1006 // Naming Styles
{
- StatusBarViewModel statusBar = null;
-
bool runGui = false;
try
{
@@ -44,26 +43,7 @@ namespace WalletWasabi.Gui
}
Logger.LogSoftwareStarted("Wasabi GUI");
- BuildAvaloniaApp()
- .StartShellApp<AppBuilder, MainWindow>("Wasabi Wallet", null, () => MainWindowViewModel.Instance,
- beforeStarting: async builder =>
- {
- MainWindowViewModel.Instance = new MainWindowViewModel { Global = Global };
- statusBar = new StatusBarViewModel(Global);
- MainWindowViewModel.Instance.StatusBar = statusBar;
- MainWindowViewModel.Instance.LockScreen = new LockScreenViewModel(Global);
-
- await Global.InitializeNoWalletAsync();
-
- statusBar.Initialize(Global.Nodes.ConnectedNodes, Global.Synchronizer, Global.UpdateChecker);
-
- if (Global.Network != Network.Main)
- {
- MainWindowViewModel.Instance.Title += $" - {Global.Network}";
- }
-
- Dispatcher.UIThread.Post(GC.Collect);
- });
+ BuildAvaloniaApp().StartShellApp("Wasabi Wallet", AppMain, args);
}
catch (Exception ex)
{
@@ -72,7 +52,7 @@ namespace WalletWasabi.Gui
}
finally
{
- statusBar?.Dispose();
+ StatusBar?.Dispose();
await Global.DisposeAsync();
AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
@@ -84,6 +64,25 @@ namespace WalletWasabi.Gui
}
}
+ private static async void AppMain(string[] args)
+ {
+ MainWindowViewModel.Instance = new MainWindowViewModel { Global = Global };
+ StatusBar = new StatusBarViewModel(Global);
+ MainWindowViewModel.Instance.StatusBar = StatusBar;
+ MainWindowViewModel.Instance.LockScreen = new LockScreenViewModel(Global);
+
+ await Global.InitializeNoWalletAsync();
+
+ StatusBar.Initialize(Global.Nodes.ConnectedNodes, Global.Synchronizer, Global.UpdateChecker);
+
+ if (Global.Network != Network.Main)
+ {
+ MainWindowViewModel.Instance.Title += $" - {Global.Network}";
+ }
+
+ Dispatcher.UIThread.Post(GC.Collect);
+ }
+
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Logger.LogWarning(e?.Exception);

MODIFY
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Diagnostics;
using AvalonStudio.Commands;
using AvalonStudio.Extensibility;
@@ -35,20 +36,7 @@ namespace WalletWasabi.Gui.Shell.Commands
#if DEBUG
var devToolsCommand = ReactiveCommand.Create(() =>
{
- var devTools = new DevTools(Application.Current.Windows.FirstOrDefault());
-
- var devToolsWindow = new Window
- {
- Width = 1024,
- Height = 512,
- Content = devTools,
- DataTemplates =
- {
- new ViewLocator<Avalonia.Diagnostics.ViewModels.ViewModelBase>()
- }
- };
-
- devToolsWindow.Show();
+ DevToolsExtensions.OpenDevTools((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow);
});
#endif

MODIFY
WalletWasabi.Gui/Styles/Styles.xaml
WalletWasabi.Gui/Styles/Styles.xaml
<sys:Double x:Key="FontSizeSmall">12</sys:Double>
<sys:Double x:Key="FontSizeNormal">14</sys:Double>
<sys:Double x:Key="FontSizeLarge">16</sys:Double>
- <FontFamily x:Key="MonospacedFont">
- <x:Arguments>
- <x:String>Inconsolata</x:String>
- <x:Uri>resm:WalletWasabi.Gui.Assets.*.ttf?assembly=WalletWasabi.Gui</x:Uri>
- </x:Arguments>
- </FontFamily>
+ <FontFamily x:Key="MonospacedFont">avares://WalletWasabi.Gui/Assets#Inconsolata</FontFamily>
<converters:ErrorDescriptorsJsonConverter x:Key="ErrorDescriptorsJsonConverter" />
<converters:ErrorSeverityColorConverter x:Key="ErrorSeverityColorConverter" />
<converters:ErrorDescriptorToBorderColorConverter x:Key="ErrorDescriptorToBorderColorConverter" />

MODIFY
WalletWasabi.Gui/ViewModels/WasabiDocumentTabViewModel.cs
WalletWasabi.Gui/ViewModels/WasabiDocumentTabViewModel.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.Gui.ViewModels
public object Context { get; set; }
public double Width { get; set; }
public double Height { get; set; }
- public IView Parent { get; set; }
+ public IDockable Parent { get; set; }
public string Title
{

MODIFY
WalletWasabi.Gui/WalletWasabi.Gui.csproj
WalletWasabi.Gui/WalletWasabi.Gui.csproj
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<EmbeddedResource Include="**\*.xaml;Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
+ <AvaloniaResource Include="Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ItemGroup>
<PackageReference Include="AvalonStudio.Shell" Version="0.8.9991" />
- <PackageReference Include="Avalonia" Version="0.8.999-cibuild0003780-beta" />
+ <PackageReference Include="Avalonia" Version="0.8.999-cibuild0004126-beta" />
<PackageReference Include="Dock.Avalonia.Themes.Default" Version="0.9.0-build20190904-02" />
<PackageReference Include="Dock.Avalonia.Themes.Metro" Version="0.9.0-build20190904-02" />

some fixes for avalonia 0.9