TeamsNetphoneLink/TeamsNetphoneLinkWPF/WPF/ExceptionWindow.xaml.cs
2025-03-25 22:43:13 +01:00

68 lines
2.3 KiB
C#

using System.Diagnostics;
using System.Media;
using System.Windows;
namespace TeamsNetphoneLink.WPF
{
/// <summary>
/// Interaktionslogik für ExceptionWindow.xaml
/// </summary>
public partial class ExceptionWindow : Window
{
public ExceptionWindow(string module, string trace)
{
InitializeComponent();
ModuleText.Text = module;
TraceText.Text = trace;
SystemSounds.Hand.Play();
}
// Button zum Schließen
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
// Button zum Issue melden
private void ReportButton_Click(object sender, RoutedEventArgs e)
{
// Fehlerdetails aus der TextBox holen
string moduleDetails = ModuleText.Text;
string errorDetails = TraceText.Text;
// URL für das GitHub Issue, Fehlerdetails werden als Parameter angehängt
string url = $"https://git.jan.sx/krjan02/TeamsNetphoneLink/issues/new?body={Uri.EscapeDataString(String.Format("Modul: {0}\n\nTrace:\n{1}", moduleDetails, errorDetails))}";
// GitHub im Standardbrowser öffnen
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
}
public static class ExceptionWindowHelper
{
public static void Show(string classname, string method, string message, string trace)
{
var modulestr = String.Format("{0} - {1}", classname, method);
var errorstr = String.Format("{0}\n{1}", message, trace);
// Use the Dispatcher to show the window on the UI thread
Application.Current.Dispatcher.InvokeAsync(() =>
{
new ExceptionWindow(modulestr, errorstr).Show();
});
}
public static void Show(string classname, string method, string message, string tracemessage, string trace)
{
var modulestr = String.Format("{0} - {1}", classname, method);
var errorstr = String.Format("{0}\n{1}\n{2}", message, tracemessage, trace);
// Use the Dispatcher to show the window on the UI thread
Application.Current.Dispatcher.InvokeAsync(() =>
{
new ExceptionWindow(modulestr, errorstr).Show();
});
}
}
}