I have created my own messagebox window which is working however this is how I currently use it:
var msgbox = new msgbox("Please confirm patients phone number with them before proceeding");
msgbox.ShowDialog();
I want to be able to use it this way:
MessageBox.Show("Choose an Estimated Time of Arrival");
This is first of all so i can just replaceAll MessageBox with msgbox. I have lots in my application and now that I have my own custom messagebox it will be so much easier to replace this way rather than replacing with the first set of code.
The issue is I can't figure out how to have the overloads in the showDialog section?
There is probably more than one solution but I would create a new MyMessageBox
class with Show
method and I would create msgbox
inside this method.
public sealed class MyMessageBox
{
public static bool? Show(string messageBoxText)
{
var msgbox = new msgbox(messageBoxText);
return msgbox.ShowDialog();
}
}
Then just replace all MessageBox
with MyMessageBox
.
System.Windows.MessageBox.Show
returns MessageBoxResult
, so you can create Show
method that returns also MessageBoxResult
.
public sealed class MyMessageBox
{
public static MessageBoxResult Show(string messageBoxText)
{
var msgbox = new msgbox(messageBoxText);
msgbox.ShowDialog();
return MessageBoxResult.OK;
}
}