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); SelectTab(LibraryButton, null);
FillProgramsPanel(); FillProgramsPanel();
Logger.Log("launcher started"); 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); 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:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MessageBox" mc:Ignorable="d"
d:DesignHeight="450" Height="100"
d:DesignWidth="800" Width="200"
mc:Ignorable="d" /> 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 public partial class MessageBox : Window
{ {
@ -9,6 +11,15 @@ public partial class MessageBox : Window
public static void Show(string title, string text) 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.AutoFlush = true;
Trace.Listeners.Add(traceHandler); Trace.Listeners.Add(traceHandler);
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
throw new Exception("aaa");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -45,7 +44,7 @@ public static class LauncherMain
public static void LogError(string context, Exception ex) public static void LogError(string context, Exception ex)
{ {
string errmsg = $"{ex.Message}\n{ex.StackTrace}"; string errmsg = $"{ex.Message}\n{ex.StackTrace}";
//MessageBox.Show($"{context} ERROR", errmsg); MessageBox.Show($"{context} ERROR", errmsg);
Logger.Log(errmsg); Logger.Log(errmsg);
} }
} }

View File

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

View File

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