From e3a3fb5e5e9591b8e886b70dc22792f4ea39287e Mon Sep 17 00:00:00 2001 From: timerix Date: Thu, 12 Oct 2023 13:28:59 +0600 Subject: [PATCH] try to implement MessageBox --- .../GUI/LauncherWindow.axaml.cs | 8 +++++++ Launcher.Client.Avalonia/GUI/MessageBox.axaml | 24 +++++++++++++++---- .../GUI/MessageBox.axaml.cs | 15 ++++++++++-- Launcher.Client.Avalonia/LauncherMain.cs | 3 +-- Launcher.Client/Launcher.Client.csproj | 3 +-- Launcher.Client/ProgramDescriptor.cs | 6 +++++ 6 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 Launcher.Client/ProgramDescriptor.cs diff --git a/Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs b/Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs index aa4bfbd..e7ecf07 100644 --- a/Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs +++ b/Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs @@ -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); diff --git a/Launcher.Client.Avalonia/GUI/MessageBox.axaml b/Launcher.Client.Avalonia/GUI/MessageBox.axaml index 5971b49..86bc2d3 100644 --- a/Launcher.Client.Avalonia/GUI/MessageBox.axaml +++ b/Launcher.Client.Avalonia/GUI/MessageBox.axaml @@ -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}"> + + * 30 + + + + diff --git a/Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs b/Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs index 612d752..7bd0634 100644 --- a/Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs +++ b/Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs @@ -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(); } } \ No newline at end of file diff --git a/Launcher.Client.Avalonia/LauncherMain.cs b/Launcher.Client.Avalonia/LauncherMain.cs index 156340e..6ac9f3b 100644 --- a/Launcher.Client.Avalonia/LauncherMain.cs +++ b/Launcher.Client.Avalonia/LauncherMain.cs @@ -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); } } \ No newline at end of file diff --git a/Launcher.Client/Launcher.Client.csproj b/Launcher.Client/Launcher.Client.csproj index 3f41749..29ddf27 100644 --- a/Launcher.Client/Launcher.Client.csproj +++ b/Launcher.Client/Launcher.Client.csproj @@ -18,9 +18,8 @@ + - - diff --git a/Launcher.Client/ProgramDescriptor.cs b/Launcher.Client/ProgramDescriptor.cs new file mode 100644 index 0000000..4238d44 --- /dev/null +++ b/Launcher.Client/ProgramDescriptor.cs @@ -0,0 +1,6 @@ +namespace Launcher.Client; + +public class ProgramDescriptor +{ + +} \ No newline at end of file