本文整理汇总了C#中MessageBoxResult.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MessageBoxResult.ToString方法的具体用法?C# MessageBoxResult.ToString怎么用?C# MessageBoxResult.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBoxResult
的用法示例。
在下文中一共展示了MessageBoxResult.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMessageboxResponceFromResult
/// <summary>
/// Converts the <see cref="MessageBoxResult"/> enum to its equivalent <see cref="MessageboxResponce"/> value.
/// </summary>
/// <param name="messageboxResult">
/// The native message box result
/// </param>
/// <returns>
/// The message box response
/// </returns>
private static MessageboxResponce GetMessageboxResponceFromResult(MessageBoxResult messageboxResult)
{
switch (messageboxResult)
{
case MessageBoxResult.Cancel:
return MessageboxResponce.Cancel;
case MessageBoxResult.No:
return MessageboxResponce.No;
case MessageBoxResult.None:
return MessageboxResponce.None;
case MessageBoxResult.OK:
return MessageboxResponce.Ok;
case MessageBoxResult.Yes:
return MessageboxResponce.Yes;
default:
throw new ArgumentException(string.Format("Unsupported message box result '{0}'"), messageboxResult.ToString());
}
}
示例2: TranslateMessageBoxResult
static MessageResult TranslateMessageBoxResult(MessageBoxResult result) {
var value = result.ToString();
return (MessageResult)Enum.Parse(typeof(MessageResult), value, true);
}
示例3: GiveResult
/// <summary>
/// Gives a result to the message box, allowing its underlying execution tree to continue.
/// </summary>
/// <param name="result"></param>
public void GiveResult(MessageBoxResult result)
{
// Message boxes with no callbacks don't give result and silenty return.
if (_callback == null)
{
return;
}
switch (result)
{
case MessageBoxResult.FirstButton:
if (FirstButtonLabel == null)
{
throw new InvalidOperationException("There is no first button on this message box.");
}
_callback("Button1");
break;
case MessageBoxResult.SecondButton:
if (SecondButtonLabel == null)
{
throw new InvalidOperationException("There is no second button on this message box.");
}
_callback("Button2");
break;
case MessageBoxResult.Cancel:
// Cancelled message boxes call the callback with a nil parameter.
_callback(null);
break;
default:
throw new NotImplementedException("This result type is not implemented: " + result.ToString());
}
}