本文整理汇总了C#中MessageBoxIcon.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MessageBoxIcon.ToString方法的具体用法?C# MessageBoxIcon.ToString怎么用?C# MessageBoxIcon.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBoxIcon
的用法示例。
在下文中一共展示了MessageBoxIcon.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
/// <summary>
/// Показываем сообщение с иконкой и заголовком сообщения
/// </summary>
/// <param name="icon"> из пространства имен MessageBoxIcon</param>
public void Show(MessageBoxIcon icon,string nameForm)
{
string tCaption=string.Empty;
if (header!=null)
tCaption+=header+" ";
if (icon!=MessageBoxIcon.None)
{
switch(icon.ToString())
{
case "Error" :
case "Hand" : tCaption+="Ошибка!";break;
case "Information" : tCaption+="Информация!";break;
case "Question" :
case "Asterisk" : tCaption+="Вопрос!";break;
case "Stop" : tCaption+="Остановитесь!";break;
case "Warning" : tCaption+="Внимание!";break;
}
}
if (nameForm!=null && nameForm.Length>0)
tCaption=nameForm+" : "+tCaption;
if (tCaption!=string.Empty && text.Length>0)
MessageBox.Show (text,tCaption,MessageBoxButtons.OK,icon);
else if(description.Length>0)
MessageBox.Show (description,text,MessageBoxButtons.OK,MessageBoxIcon.Error);
else
MessageBox.Show (text,"",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
示例2: AddSound
private static void AddSound(MessageBoxIcon icon)
{
switch (icon.ToString())
{
case "Asterisk":
{
pictureBox1.Image = System.Drawing.SystemIcons.Asterisk.ToBitmap();
sound = System.Media.SystemSounds.Asterisk;
break;
}
case "Error":
{
pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
sound = System.Media.SystemSounds.Beep;
break;
}
case "Exclamation":
{
pictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
sound = System.Media.SystemSounds.Exclamation;
break;
}
case "Hand":
{
pictureBox1.Image = System.Drawing.SystemIcons.Hand.ToBitmap();
sound = System.Media.SystemSounds.Exclamation;
break;
}
case "Information":
{
pictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
sound = System.Media.SystemSounds.Exclamation;
break;
}
case "None":
{
sound = System.Media.SystemSounds.Asterisk;
break;
}
case "Question":
{
pictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
sound = System.Media.SystemSounds.Question;
break;
}
case "Stop":
{
pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
sound = System.Media.SystemSounds.Hand;
break;
}
case "Warning":
{
pictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();
sound = System.Media.SystemSounds.Asterisk;
break;
}
}
}