|
@@ -10,6 +10,9 @@ using System.Runtime.CompilerServices;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.IO;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
+using InABox.WPF;
|
|
|
|
|
|
namespace InABox.Wpf;
|
|
|
|
|
@@ -83,6 +86,17 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public ImageSource? _image = null;
|
|
|
+ public ImageSource? Image
|
|
|
+ {
|
|
|
+ get => _image;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _image = value;
|
|
|
+ OnPropertyChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private string _details = "";
|
|
|
|
|
|
public string Details
|
|
@@ -163,23 +177,27 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
|
|
|
#region Static Constructors
|
|
|
|
|
|
- public static void ShowMessage(string message, string title)
|
|
|
+ public static readonly BitmapImage _warning = InABox.Wpf.Resources.warning.AsBitmapImage();
|
|
|
+
|
|
|
+ public static void ShowMessage(string message, string title, ImageSource? image = null)
|
|
|
{
|
|
|
var window = new MessageWindow
|
|
|
{
|
|
|
Message = message,
|
|
|
- Title = title
|
|
|
+ Title = title,
|
|
|
+ Image = image
|
|
|
};
|
|
|
window.AddOKButton();
|
|
|
window.ShowDialog();
|
|
|
}
|
|
|
|
|
|
- public static bool ShowOKCancel(string message, string title)
|
|
|
+ public static bool ShowOKCancel(string message, string title, ImageSource? image = null)
|
|
|
{
|
|
|
var window = new MessageWindow
|
|
|
{
|
|
|
Message = message,
|
|
|
- Title = title
|
|
|
+ Title = title,
|
|
|
+ Image = image
|
|
|
};
|
|
|
window.AddOKButton();
|
|
|
window.AddCancelButton();
|
|
@@ -187,12 +205,13 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
return window.Result == MessageWindowResult.OK;
|
|
|
}
|
|
|
|
|
|
- public static bool ShowYesNo(string message, string title)
|
|
|
+ public static bool ShowYesNo(string message, string title, ImageSource? image = null)
|
|
|
{
|
|
|
var window = new MessageWindow
|
|
|
{
|
|
|
Message = message,
|
|
|
- Title = title
|
|
|
+ Title = title,
|
|
|
+ Image = image
|
|
|
};
|
|
|
window.AddOKButton("Yes");
|
|
|
window.AddCancelButton("No");
|
|
@@ -207,7 +226,7 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
/// <param name="exception"></param>
|
|
|
/// <param name="title"></param>
|
|
|
/// <param name="shouldLog">If <see langword="true"/>, also logs the exception.</param>
|
|
|
- public static void ShowError(string? message, Exception exception, string title = "Error", bool shouldLog = true)
|
|
|
+ public static void ShowError(string? message, Exception exception, string title = "Error", bool shouldLog = true, ImageSource? image = null)
|
|
|
{
|
|
|
if (shouldLog)
|
|
|
{
|
|
@@ -218,7 +237,8 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
{
|
|
|
Message = message ?? exception.Message,
|
|
|
Title = title,
|
|
|
- Details = CoreUtils.FormatException(exception)
|
|
|
+ Details = CoreUtils.FormatException(exception),
|
|
|
+ Image = image ?? _warning
|
|
|
};
|
|
|
|
|
|
window.AddButton(new MessageWindowButton("Show Logs", ShowLogs_Click, MessageWindowButtonPosition.Left));
|