bloxstrap/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs
pizzaboxer 48afdd7036
Use CsWin32 in favor of NativeMethods
i was planning to use pinvoke but turns out it was deprecated just 6 days ago lol
2023-08-01 19:09:52 +01:00

46 lines
1.4 KiB
C#

using System.Media;
using System.Windows.Interop;
using Windows.Win32;
using Windows.Win32.Foundation;
namespace Bloxstrap.UI.Elements.Dialogs
{
// hmm... do i use MVVM for this?
// this is entirely static, so i think im fine without it, and this way is just so much more efficient
/// <summary>
/// Interaction logic for ExceptionDialog.xaml
/// </summary>
public partial class ConnectivityDialog
{
public ConnectivityDialog(string targetName, string description, Exception exception)
{
Exception? innerException = exception.InnerException;
InitializeComponent();
TitleTextBlock.Text = $"{App.ProjectName} is unable to connect to {targetName}";
DescriptionTextBlock.Text = description;
ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}";
if (innerException is not null)
ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}";
CloseButton.Click += delegate
{
Close();
};
SystemSounds.Hand.Play();
Loaded += delegate
{
var hWnd = new WindowInteropHelper(this).Handle;
PInvoke.FlashWindow((HWND)hWnd, true);
};
}
}
}