本文整理汇总了C#中MessageBox.Pack方法的典型用法代码示例。如果您正苦于以下问题:C# MessageBox.Pack方法的具体用法?C# MessageBox.Pack怎么用?C# MessageBox.Pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBox
的用法示例。
在下文中一共展示了MessageBox.Pack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{
if (text == null)
text = "";
if (caption == null)
caption = "";
MessageBox mymb = new MessageBox(caption);
mymb.mymb = mymb;
// ensure we are always in a known state
_state = DialogResult.None;
// convert to nice wrapped lines.
text = AddNewLinesToText(text);
// get pixel width and height
Graphics graphics = Graphics.FromImage(new Bitmap(1, 1));
SizeF textSize = graphics.MeasureString(text, SystemFonts.DefaultFont);
textSize = new SizeF(textSize.Width * 3, textSize.Height * 1);
// allow for icon
// if (icon != MessageBoxIcon.None)
// textSize.Width += SystemIcons.Question.Width;
mymb.Size = new AssortedWidgets.Util.Size(textSize.Width + 50, textSize.Height + 100);
//Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle);
//int titleHeight = screenRectangle.Top - msgBoxFrm.Top;
var lblMessage = new Label(text);
var actualIcon = getMessageBoxIcon(icon);
if (actualIcon == null)
{
// lblMessage.Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN);
}
else
{
// var iconPbox = new PictureBox
{
// Image = actualIcon.ToBitmap(),
// Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN)
};
// msgBoxFrm.Controls.Add(iconPbox);
}
mymb.Add(lblMessage);
//mymb.Add(actualIcon);
AddButtonsToForm(mymb, buttons);
mymb.Pack();
DialogManager.Instance.SetModalDialog(mymb);
DialogResult answer = _state;
return answer;
}