本文整理汇总了C#中MessageDialog.ShowAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MessageDialog.ShowAsync方法的具体用法?C# MessageDialog.ShowAsync怎么用?C# MessageDialog.ShowAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.ShowAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public async void Execute(object parameter)
{
var result = Task.FromResult(default(IUICommand));
owner.DownloadVisible = false;
owner.ProgressVisible = true;
var folder = await downloader.VerifyFolderCreation();
using (var client = new System.Net.Http.HttpClient())
{
// find all selected episodes.
List<Task> results = new List<Task>();
foreach (var episode in owner.selectedEpisodes)
{
var path = episode.Description;
var writeTask = downloader.SaveUrlAsync(folder, client, path);
results.Add(writeTask);
}
var allTasks = Task.WhenAll(results.ToArray());
owner.ActiveDownload = allTasks;
try
{
await allTasks;
}
catch (Exception)
{
// Umm, some download failed.
var errMsg = new MessageDialog("One or more downloads failed");
result = errMsg.ShowAsync().AsTask();
}
await result;
}
owner.DownloadVisible = true;
owner.ProgressVisible = false;
owner.selectedEpisodes.Clear();
}
示例2: ShowMessageBox
/// <summary>
/// Shows the message box.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="caption">The caption.</param>
/// <param name="button">The button.</param>
/// <param name="icon">The icon.</param>
/// <returns>The message result.</returns>
/// <exception cref="ArgumentException">The <paramref name="message"/> is <c>null</c> or whitespace.</exception>
protected virtual async Task<MessageResult> ShowMessageBox(string message, string caption = "", MessageButton button = MessageButton.OK, MessageImage icon = MessageImage.None)
{
// TODO: Add translations for system
var result = MessageBoxResult.None;
var messageBoxButton = TranslateMessageButton(button);
var messageDialog = new MessageDialog(message, caption);
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OK) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OKCancel))
{
messageDialog.Commands.Add(new UICommand("OK", cmd => result = MessageBoxResult.OK));
}
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNo) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNoCancel))
{
messageDialog.Commands.Add(new UICommand("Yes", cmd => result = MessageBoxResult.Yes));
messageDialog.Commands.Add(new UICommand("No", cmd => result = MessageBoxResult.No));
}
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OKCancel) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNoCancel))
{
messageDialog.Commands.Add(new UICommand("Cancel", cmd => result = MessageBoxResult.Cancel));
messageDialog.CancelCommandIndex = (uint)messageDialog.Commands.Count - 1;
}
await messageDialog.ShowAsync();
return TranslateMessageBoxResult(result);
}
示例3: DoExecute
private async Task DoExecute()
{
var result = Task.FromResult(default(IUICommand));
try
{
PodcastEpisode.playbackControl.setSource(new Uri(owner.Description, UriKind.Absolute));
PodcastEpisode.playbackControl.PlayPause();
}
catch (InvalidOperationException)
{
var errMsg = new MessageDialog("Error playing or pausing the media content");
result = errMsg.ShowAsync().AsTask();
}
await result;
}
示例4: AlertAsync
protected virtual IAsyncOperation<IUICommand> AlertAsync( Interaction interaction )
{
Arg.NotNull( interaction, nameof( interaction ) );
Contract.Ensures( Contract.Result<IAsyncOperation<IUICommand>>() != null );
var content = interaction.Content == null ? string.Empty : interaction.Content.ToString();
var dialog = new MessageDialog( content, interaction.Title );
dialog.DefaultCommandIndex = 0;
if ( interaction.Commands.Count == 0 )
dialog.Commands.Add( new UICommand( SR.OKCaption, DefaultAction.None ) );
else
dialog.Commands.Add( interaction.Commands[0].AsUICommand() );
return dialog.ShowAsync();
}
示例5: PromptAsync
protected virtual IAsyncOperation<IUICommand> PromptAsync( Interaction interaction )
{
Arg.NotNull( interaction, nameof( interaction ) );
Contract.Ensures( Contract.Result<IAsyncOperation<IUICommand>>() != null );
var content = interaction.Content == null ? string.Empty : interaction.Content.ToString();
var dialog = new MessageDialog( content, interaction.Title );
if ( interaction.DefaultCommandIndex >= 0 )
dialog.DefaultCommandIndex = (uint) interaction.DefaultCommandIndex;
if ( interaction.CancelCommandIndex >= 0 )
dialog.CancelCommandIndex = (uint) interaction.CancelCommandIndex;
dialog.Commands.AddRange( interaction.Commands.Select( c => c.AsUICommand() ) );
return dialog.ShowAsync();
}
示例6: ShowMessageBox
protected virtual MessageResult ShowMessageBox(string message, string caption = "", MessageButton button = MessageButton.OK, MessageImage icon = MessageImage.None)
#endif
{
Argument.IsNotNullOrWhitespace("message", message);
var result = MessageBoxResult.None;
var messageBoxButton = TranslateMessageButton(button);
#if NET
var messageBoxImage = TranslateMessageImage(icon);
var activeWindow = Application.Current.GetActiveWindow();
if (activeWindow != null)
{
result = MessageBox.Show(activeWindow, message, caption, messageBoxButton, messageBoxImage);
}
else
{
result = MessageBox.Show(message, caption, messageBoxButton, messageBoxImage);
}
#elif NETFX_CORE
// TODO: Add translations for system
var messageDialog = new MessageDialog(message, caption);
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OK) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OKCancel))
{
messageDialog.Commands.Add(new UICommand("OK", cmd => result = MessageBoxResult.OK));
}
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNo) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNoCancel))
{
messageDialog.Commands.Add(new UICommand("Yes", cmd => result = MessageBoxResult.Yes));
messageDialog.Commands.Add(new UICommand("No", cmd => result = MessageBoxResult.No));
}
if (Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.OKCancel) ||
Enum<MessageButton>.Flags.IsFlagSet(button, MessageButton.YesNoCancel))
{
messageDialog.Commands.Add(new UICommand("Cancel", cmd => result = MessageBoxResult.Cancel));
messageDialog.CancelCommandIndex = (uint)messageDialog.Commands.Count - 1;
}
await messageDialog.ShowAsync();
#else
result = MessageBox.Show(message, caption, messageBoxButton);
#endif
return TranslateMessageBoxResult(result);
}