|
@@ -32,9 +32,24 @@ public enum MessageWindowResult
|
|
|
Other
|
|
|
}
|
|
|
|
|
|
+public class MessageWindowButtonDelegateArgs : EventArgs
|
|
|
+{
|
|
|
+ public MessageWindowButton Button { get; private set; }
|
|
|
+ public bool Close { get; set; } = false;
|
|
|
+
|
|
|
+ public MessageWindowButtonDelegateArgs(MessageWindowButton button, bool close)
|
|
|
+ {
|
|
|
+ Button = button;
|
|
|
+ Close = close;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+public delegate void MessageWindowButtonDelegate(MessageWindow window, MessageWindowButtonDelegateArgs args);
|
|
|
+
|
|
|
+
|
|
|
public class MessageWindowButton : INotifyPropertyChanged
|
|
|
{
|
|
|
- public delegate void MessageWindowButtonDelegate(MessageWindow window, MessageWindowButton button);
|
|
|
|
|
|
public MessageWindowButtonPosition Position { get; set; }
|
|
|
|
|
@@ -134,7 +149,10 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
{
|
|
|
if (sender is not Button button || button.Tag is not MessageWindowButton winButton) return;
|
|
|
|
|
|
- winButton.Action(this, winButton);
|
|
|
+ var args = new MessageWindowButtonDelegateArgs(winButton, false);
|
|
|
+ winButton.Action(this, args);
|
|
|
+ if (args.Close)
|
|
|
+ Close();
|
|
|
}
|
|
|
|
|
|
private void Buttons_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
@@ -173,25 +191,25 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- private void YesButton_Click(MessageWindow window, MessageWindowButton button)
|
|
|
+ private void YesButton_Click(MessageWindow window, MessageWindowButtonDelegateArgs args)
|
|
|
{
|
|
|
Result = MessageWindowResult.Yes;
|
|
|
Close();
|
|
|
}
|
|
|
|
|
|
- private void NoButton_Click(MessageWindow window, MessageWindowButton button)
|
|
|
+ private void NoButton_Click(MessageWindow window, MessageWindowButtonDelegateArgs args)
|
|
|
{
|
|
|
Result = MessageWindowResult.No;
|
|
|
Close();
|
|
|
}
|
|
|
|
|
|
- private void CancelButton_Click(MessageWindow window, MessageWindowButton button)
|
|
|
+ private void CancelButton_Click(MessageWindow window, MessageWindowButtonDelegateArgs args)
|
|
|
{
|
|
|
Result = MessageWindowResult.Cancel;
|
|
|
Close();
|
|
|
}
|
|
|
|
|
|
- private void OKButton_Click(MessageWindow window, MessageWindowButton button)
|
|
|
+ private void OKButton_Click(MessageWindow window, MessageWindowButtonDelegateArgs args)
|
|
|
{
|
|
|
Result = MessageWindowResult.OK;
|
|
|
Close();
|
|
@@ -307,15 +325,15 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
.Title(title)
|
|
|
.Details(CoreUtils.FormatException(exception))
|
|
|
.Image(image ?? _warning)
|
|
|
- .AddButton(new MessageWindowButton("Email Logs", (window, button) =>
|
|
|
+ .AddButton(new MessageWindowButton("Email Logs", (window, args) =>
|
|
|
{
|
|
|
EmailLogs_Click(exception);
|
|
|
}, MessageWindowButtonPosition.Left));
|
|
|
|
|
|
- var showDetailsButton = new MessageWindowButton("Show Details", (win, button) =>
|
|
|
+ var showDetailsButton = new MessageWindowButton("Show Details", (win, args) =>
|
|
|
{
|
|
|
win.ShowDetails = !win.ShowDetails;
|
|
|
- button.Content = win.ShowDetails
|
|
|
+ args.Button.Content = win.ShowDetails
|
|
|
? "Hide Details"
|
|
|
: "Show Details";
|
|
|
}, MessageWindowButtonPosition.Left);
|
|
@@ -380,10 +398,10 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
|
|
|
|
|
|
if(details is not null)
|
|
|
{
|
|
|
- var showDetailsButton = new MessageWindowButton("Show Details", (win, button) =>
|
|
|
+ var showDetailsButton = new MessageWindowButton("Show Details", (win, args) =>
|
|
|
{
|
|
|
win.ShowDetails = !win.ShowDetails;
|
|
|
- button.Content = win.ShowDetails
|
|
|
+ args.Button.Content = win.ShowDetails
|
|
|
? "Hide Details"
|
|
|
: "Show Details";
|
|
|
}, MessageWindowButtonPosition.Left);
|