本文整理汇总了C#中MessageBox.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# MessageBox.ShowDialog方法的具体用法?C# MessageBox.ShowDialog怎么用?C# MessageBox.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBox
的用法示例。
在下文中一共展示了MessageBox.ShowDialog方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryToParse
private void TryToParse(string value)
{
int number;
bool result = Int32.TryParse(value, out number);
if (result)
{
Data.number = number;
}
else
{
if (value == null)
{
value = "";
var box = new MessageBox();
box.ShowDialog(this);
return;
}
}
}
示例2: Target_Click
private void Target_Click(object sender, RoutedEventArgs e)
{
MessageBox msg = new MessageBox(this.Owner as MainWindow, "Yes - Windows Path\nNo - Linux Path", MessageBoxButton.YesNo);
msg.Owner = this.Owner;
msg.ShowDialog();
if (msg.Result == MessageBoxResult.No)
{
}
else
{
using (OpenFileDialogEx dialog = new OpenFileDialogEx())
{
dialog.StartLocation = AddonWindowLocation.Right;
dialog.DefaultViewMode = FolderViewMode.Icon;
dialog.OpenDialog.InitialDirectory = Environment.SpecialFolder.MyComputer.ToString();
dialog.OpenDialog.AddExtension = true;
dialog.OpenDialog.Multiselect = false;
dialog.OpenDialog.ValidateNames = false;
dialog.OpenDialog.ShowDialog();
Forms.DialogResult result = dialog.ShowDialog();
if (result == Forms.DialogResult.OK)
{
Target.Content = dialog.OpenDialog.FileName;
}
dialog.Dispose();
}
}
}
示例3: FSE_Drop
private void FSE_Drop(object sender, DragEventArgs e)
{
ButtonExt btn = sender as ButtonExt;
string[] fileData = (string[])e.Data.GetData(DataFormats.FileDrop);
if (fileData.Length > 0)
{
object temp = btn.Content;
btn.Content = fileData[0];
if (Source.Content.ToString() != source && Target.Content.ToString() != target)
{
if (FSOpt.IsDirectory(Source.Content.ToString()) != FSOpt.IsDirectory(Target.Content.ToString()))
{
// warning
MessageBox msg = new MessageBox(this.Owner as MainWindow, "The type of the file entries are different!");
msg.Owner = this.Owner;
msg.ShowDialog();
btn.Content = temp;
}
}
}
}
示例4: ShowBox
//.........这里部分代码省略.........
newmessage += sval[i];
if (arguments.Count() - 1 >= i)
newmessage += arguments[i];
}
newmessage.Replace("@@@@@@", "");
messageID = newmessage;
}
newMsgBox.MsgContent.Text = messageID;
if (messageID.Length > 100) { newMsgBox.MsgContent.FontSize = 14.0; }
switch (RequiredIcon)
{
case (BMC_Icon.Information):
{
newMsgBox.icnInformation.Opacity = 1.0;
break;
}
case (BMC_Icon.Warning):
{
newMsgBox.icnWarning.Opacity = 1.0;
break;
}
case BMC_Icon.Question:
{
newMsgBox.icnQuestion.Opacity = 1.0;
break;
}
case BMC_Icon.Error:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
default:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
}
switch (RequiredButtons)
{
case BMC_Button.OK:
{
newMsgBox.OK.Visibility = Visibility.Visible;
break;
}
case BMC_Button.OKCancel:
{
newMsgBox.OK.Visibility = Visibility.Visible;
newMsgBox.Cancel.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNo:
{
newMsgBox.Yes.Visibility = Visibility.Visible;
newMsgBox.No.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNoCancel:
{
newMsgBox.Yes.Visibility = Visibility.Visible;
newMsgBox.No.Visibility = Visibility.Visible;
newMsgBox.Cancel.Visibility = Visibility.Visible;
break;
}
default:
{
break;
}
}
newMsgBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
//
if ((parentOwner != null) && (parentOwner.IsActive))
{
if ((childOwner != null) && (childOwner.IsActive))
{
newMsgBox.Owner = childOwner;
}
else
newMsgBox.Owner = parentOwner;
}
else
{
WindowCollection WinScreens = Application.Current.Windows;
foreach (Window screen in WinScreens)
{
if ((screen.IsActive) && (screen != newMsgBox))
newMsgBox.Owner = screen;
}
}
//
if (newMsgBox.Owner == null)
newMsgBox.Topmost = true;
//
newMsgBox.ShowDialog();
return _DialogResult;
}
示例5: ShowText
private static System.Windows.Forms.DialogResult ShowText(string message, BMC_Icon RequiredIcon, BMC_Button RequiredButtons, bool isPrivateFunction, params string[] arguments)
{
newMsgBox = new MessageBox();
newMsgBox.MsgContent.Text = message;
if (message.Length > 100) { newMsgBox.MsgContent.FontSize = 14.0; }
switch (RequiredIcon)
{
case (BMC_Icon.Information):
{
newMsgBox.icnInformation.Opacity = 1.0;
break;
}
case (BMC_Icon.Warning):
{
newMsgBox.icnWarning.Opacity = 1.0;
break;
}
case BMC_Icon.Question:
{
newMsgBox.icnQuestion.Opacity = 1.0;
break;
}
case BMC_Icon.Error:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
default:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
}
switch (RequiredButtons)
{
case BMC_Button.OK:
{
newMsgBox.OK.Visibility = Visibility.Visible;
break;
}
case BMC_Button.OKCancel:
{
newMsgBox.OK.Visibility = Visibility.Visible;
newMsgBox.Cancel.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNo:
{
newMsgBox.Yes.Visibility = Visibility.Visible;
newMsgBox.No.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNoCancel:
{
newMsgBox.Yes.Visibility = Visibility.Visible;
newMsgBox.No.Visibility = Visibility.Visible;
newMsgBox.Cancel.Visibility = Visibility.Visible;
break;
}
default:
{
break;
}
}
newMsgBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
newMsgBox.ShowDialog();
return _DialogResult;
}
示例6: Show
/// <summary>
/// Clase generica para capturar un valor alfanumerico extenso,
/// en varias lineas, usese de forma similar a <code>MessageBox</code>.
/// Nota: Este metodo ejecuta la forma regresando como parametros,
/// algunas propiedades significas de la forma.
/// Considerese este metodo estatico como funcion global del "namespace",
/// no como un metodo de esta clase.
/// </summary>
/// <param name="Title">Titulo de la forma.</param>
/// <param name="Msg">Texto del mensaje, puede tener saltos de linea.</param>
/// <param name="buttons">Grupo de Botones.</param>
/// <returns>Boton seleccionado.</returns>
/// public static DialogResult Show(string AMsg, string ATitle="", MessageBoxButtons buttons = MessageBoxButtons.OK)
public static DialogResult Show(string AMsg, string ATitle, MessageBoxButtons buttons)
{
DialogResult Result = DialogResult.None;
// --> construir forma auxiliar, sin ejecutar, todavia
MessageBox thisForm = new MessageBox();
// --> asignar parametros
thisForm.Text = ATitle;
thisForm.Message = AMsg;
thisForm.SelectedButtons = buttons;
// --> ahora si, desplegar forma
Result = thisForm.ShowDialog();
return Result;
}
示例7: Show
public static DialogResult Show(string title, string message, MessageBoxButtons buttons)
{
MessageBox mbox = new MessageBox(title, message, buttons, MessageBoxIcon.Information);
return mbox.ShowDialog();
}
示例8: showBox
/// <summary>
/// Creates a custom messagebox
/// </summary>
/// <param name="content">Content to be displayed</param>
/// <param name="RequiredIcon">Icon to be displayed</param>
/// <param name="RequiredButtons">Buttons to be displayed</param>
/// <returns>Dialogresult of the clicked button</returns>
public static System.Windows.Forms.DialogResult showBox(string content, BMC_Icon RequiredIcon, BMC_Button RequiredButtons)
{
newMsgBox = new MessageBox();
newMsgBox.MsgContent.Text = content;
//newMsgBox.tbHeader.Text = RequiredIcon.ToString();
switch (RequiredIcon)
{
case (BMC_Icon.Information):
{
newMsgBox.icnInformation.Opacity = 1.0;
break;
}
case (BMC_Icon.Warning):
{
newMsgBox.icnWarning.Opacity = 1.0;
break;
}
case BMC_Icon.Question:
{
newMsgBox.icnQuestion.Opacity = 1.0;
break;
}
case BMC_Icon.Error:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
default:
{
newMsgBox.icnError.Opacity = 1.0;
break;
}
}
switch (RequiredButtons)
{
case BMC_Button.OK:
{
newMsgBox.btnOK.Visibility = Visibility.Visible;
break;
}
case BMC_Button.OKCancel:
{
newMsgBox.btnOK.Visibility = Visibility.Visible;
newMsgBox.btnCancel.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNo:
{
newMsgBox.btnYes.Visibility = Visibility.Visible;
newMsgBox.btnNo.Visibility = Visibility.Visible;
break;
}
case BMC_Button.YesNoCancel:
{
newMsgBox.btnYes.Visibility = Visibility.Visible;
newMsgBox.btnNo.Visibility = Visibility.Visible;
newMsgBox.btnCancel.Visibility = Visibility.Visible;
break;
}
default:
{
break;
}
}
newMsgBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
newMsgBox.ShowDialog();
return _DialogResult;
}
示例9: Show
/// <summary>
/// メッセージダイアログを表示します。
/// </summary>
/// <param name="owner">ダイアログに対するオーナーウィンドウを指定します。</param>
/// <param name="message">表示するメッセージを指定します。</param>
/// <param name="title">ダイアログのタイトルを指定します。</param>
/// <param name="button">表示するボタンの種類を指定します。</param>
/// <param name="image">表示するアイコンの種類を指定します。</param>
/// <returns>ダイアログの結果を返します。</returns>
public static MessageBoxResult Show(System.Windows.Window owner, string message, string title, MessageBoxButton button, MessageBoxImage image)
{
var dlg = new MessageBox();
if (owner == null)
{
dlg.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
else
{
dlg.Owner = owner;
dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner;
dlg.Icon = owner.Icon;
}
dlg.Message = message;
dlg.Title = title;
dlg.MessageBoxButton = button;
dlg.MessageBoxImage = image;
dlg.PreviewKeyDown += (s, e) =>
{
if ((e.Key == Key.Escape) && (Keyboard.Modifiers == ModifierKeys.None))
{
var control = s as MessageBox;
switch (control.MessageBoxButton)
{
case MessageBoxButton.OK: control.MessageBoxResult = MessageBoxResult.OK; break;
case MessageBoxButton.OKCancel:
case MessageBoxButton.YesNoCancel: control.MessageBoxResult = MessageBoxResult.Cancel; break;
case MessageBoxButton.YesNo: control.MessageBoxResult = MessageBoxResult.No; break;
}
control.DialogResult = false;
}
};
dlg.ShowInTaskbar = false;
dlg.ShowDialog();
var result = dlg.MessageBoxResult;
dlg = null;
return result;
}
示例10: Show
public static MessageBoxResult Show(Window owner, string messageBoxText,
string caption, MessageBoxButton button, MessageBoxImage icon,
MessageBoxResult defaultResult)
{
MessageBox messageBox = new MessageBox();
messageBox.Caption = caption;
messageBox.DefaultResult = defaultResult;
if (owner != null) { messageBox.Owner = owner; }
messageBox.Message = messageBoxText;
messageBox.MessageBoxButton = button;
messageBox.MessageBoxImage = icon;
if (false == messageBox.ShowDialog())
{
return MessageBoxResult.Cancel;
}
return messageBox.MessageBoxResult;
}
示例11: displayMessage
private ResponseType displayMessage(string title, string message, MessageTypes type, Exception e, bool suppressable) {
MessageBox box = new MessageBox(type, title, message, e, suppressable, this, this.email_source);
box.ShowDialog();
if (box.Suppressed)
return ResponseType.OKSuppressed;
return ResponseType.OK;
}
示例12: displayQuestion
public bool displayQuestion(RequestEventArgs e) {
MessageBox box = new MessageBox(e, this, this.email_source);
bool result = box.ShowDialog() == true;
if (result) {
e.result.SelectedOption = "Yes";
e.result.SelectedIndex = 1;
e.response = ResponseType.OK;
} else {
e.response = ResponseType.Cancel;
}
e.result.Suppressed = box.Suppressed;
return result;
}
示例13: displayMessage
protected bool displayMessage(string title, string message, MessageTypes type, Exception e)
{
MessageBox box = new MessageBox(title,message, e,type, this);
return (bool)box.ShowDialog();
}
示例14: askQuestion
protected bool askQuestion(string title, string message)
{
MessageBox box = new MessageBox(title,message, RequestType.Question, this);
return (bool)box.ShowDialog();
}