Skip to content

Commit

Permalink
Merge pull request #55 from 1hub/messagebox
Browse files Browse the repository at this point in the history
Show message box for errors
  • Loading branch information
filipnavara authored Jul 31, 2024
2 parents d1fe0ce + 914408a commit 21edca1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/OneHub.Tools.HeapView.Web/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using MsBox.Avalonia;
using System;
using System.Linq;

Expand Down Expand Up @@ -33,6 +34,9 @@ public async void Open(IStorageFile storageFile)
catch (Exception ex)
{
Console.WriteLine(ex);

var m = MessageBoxManager.GetMessageBoxStandard("Load error", ex.Message);
await m.ShowAsync();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="11.1.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.6" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/OneHub.Tools.HeapView/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System;
using System.IO;
using MsBox.Avalonia;

namespace OneHub.Tools.HeapView;

Expand All @@ -18,7 +19,7 @@ public MainWindow()
AddHandler(DragDrop.DropEvent, Drop);
}

public void Open(string fileName)
public async void Open(string fileName)
{
try
{
Expand Down Expand Up @@ -49,8 +50,10 @@ public void Open(string fileName)
}
catch (Exception ex)
{
// TODO: Show error
Console.WriteLine(ex);

var m = MessageBoxManager.GetMessageBoxStandard("Load error", ex.Message);
await m.ShowAsync();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/OneHub.Tools.HeapView/OneHub.Tools.HeapView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.6" />
</ItemGroup>
</Project>

0 comments on commit 21edca1

Please sign in to comment.