try to implement MessageBox

This commit is contained in:
timerix 2023-10-12 13:28:59 +06:00
parent e31df8e029
commit e3a3fb5e5e
6 changed files with 49 additions and 10 deletions

View File

@ -27,6 +27,14 @@ public partial class LauncherWindow : Window
SelectTab(LibraryButton, null);
FillProgramsPanel();
Logger.Log("launcher started");
try
{
throw new Exception("aaa");
}
catch (Exception ex)
{
LogError("main window", ex);
}
}
void LogHandler(string m) => Dispatcher.UIThread.InvokeAsync(()=>LogBox.Text += m);

View File

@ -3,7 +3,23 @@
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"
Title="MessageBox"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d" />
mc:Ignorable="d"
Height="100"
Width="200"
Background="{DynamicResource MyBackgroundColor}">
<Grid>
<Grid.RowDefinitions>* 30</Grid.RowDefinitions>
<TextBox Name="TextBlock" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Foreground="{DynamicResource MyWhite}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
IsReadOnly="True" TextWrapping="Wrap"
FontSize="14"/>
<Button Grid.Row="1" Click="Button_OnClick"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Foreground="{DynamicResource MyWhite}"
FontSize="16">
OK
</Button>
</Grid>
</Window>

View File

@ -1,4 +1,6 @@
namespace Launcher.Client.Avalonia.GUI;
using Avalonia.Interactivity;
namespace Launcher.Client.Avalonia.GUI;
public partial class MessageBox : Window
{
@ -9,6 +11,15 @@ public partial class MessageBox : Window
public static void Show(string title, string text)
{
throw new NotImplementedException();
var mb = new MessageBox();
mb.Title = title;
mb.TextBlock.Text = text;
mb.Topmost = true;
mb.Show();
}
private void Button_OnClick(object sender, RoutedEventArgs e)
{
this.Close();
}
}

View File

@ -34,7 +34,6 @@ public static class LauncherMain
Trace.AutoFlush = true;
Trace.Listeners.Add(traceHandler);
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
throw new Exception("aaa");
}
catch (Exception ex)
{
@ -45,7 +44,7 @@ public static class LauncherMain
public static void LogError(string context, Exception ex)
{
string errmsg = $"{ex.Message}\n{ex.StackTrace}";
//MessageBox.Show($"{context} ERROR", errmsg);
MessageBox.Show($"{context} ERROR", errmsg);
Logger.Log(errmsg);
}
}

View File

@ -18,9 +18,8 @@
<ItemGroup>
<Compile Remove="Resources\**\*" />
<EmbeddedResource Include="Resources\**\*" />
<Compile Remove="debug_assets\**\*" />
<EmbeddedResource Include="Resources\launcher.dtsod" />
<EmbeddedResource Include="Resources\default.descriptor.template" />
<None Update="debug_assets\**\*" CopyToOutputDirectory="Always" Condition="'$(Configuration)' == 'Debug'" />
</ItemGroup>

View File

@ -0,0 +1,6 @@
namespace Launcher.Client;
public class ProgramDescriptor
{
}