本文整理汇总了C#中Windows.UI.Popups.MessageDialog.ShowAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MessageDialog.ShowAsync方法的具体用法?C# MessageDialog.ShowAsync怎么用?C# MessageDialog.ShowAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Popups.MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.ShowAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button_Click
private async void Button_Click(object sender, RoutedEventArgs e)
{
if (CountryPhoneCode.SelectedItem != null)
{
var _id = Guid.NewGuid().ToString("N");
var _countryPhoneCode = (CountryPhoneCode.SelectedItem as Country).PhoneCode;
var _countryName = (CountryPhoneCode.SelectedItem as Country).CountryName;
var _name = FullName.Text;
var _phoneNumber = PhoneNumber.Text;
var _password = Password.Password;
var client = new HttpClient()
{
BaseAddress = new Uri("http://yochat.azurewebsites.net/chat/")
};
var json = await client.GetStringAsync("createuser?id=" + _id + "&fullName=" + _name + "&password=" + _password + "&phoneNumber=" + _phoneNumber + "&countryPhoneCode=" + _countryPhoneCode);
var serializer = new DataContractJsonSerializer(typeof(User));
var ms = new MemoryStream();
var user = serializer.ReadObject(ms) as User;
Frame.Navigate(typeof(MainPage), user);
}
else
{
MessageDialog dialog = new MessageDialog("Lütfen Ülkenizi Seçiniz!");
await dialog.ShowAsync();
}
}
示例2: saveConf_Click
private async void saveConf_Click(object sender, RoutedEventArgs e)
{
if(serverExt.Text == "" && token.Text == "" && port.Text == "" && serverInt.Text == "")
{
MessageDialog msgbox = new MessageDialog("Un ou plusieurs champs sont vide...");
await msgbox.ShowAsync();
}
else
{
localSettings.Values["savedServerExt"] = serverExt.Text;
localSettings.Values["savedServerInt"] = serverInt.Text;
localSettings.Values["savedToken"] = token.Text;
localSettings.Values["savedPort"] = port.Text;
if (tts.IsOn)
{
localSettings.Values["tts"] = true;
}
else localSettings.Values["tts"] = false;
Frame.Navigate(typeof(PageAction));
}
}
示例3: ButtonRequestToken_Click
private async void ButtonRequestToken_Click(object sender, RoutedEventArgs e)
{
var error = string.Empty;
try
{
var response = await WebAuthentication.DoImplicitFlowAsync(
endpoint: new Uri(Constants.AS.OAuth2AuthorizeEndpoint),
clientId: Constants.Clients.ImplicitClient,
scope: "read");
TokenVault.StoreToken(_resourceName, response);
RetrieveStoredToken();
}
catch (Exception ex)
{
error = ex.Message;
}
if (!string.IsNullOrEmpty(error))
{
var dialog = new MessageDialog(error);
await dialog.ShowAsync();
}
}
示例4: OnClick
private async void OnClick(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
MessageDialog msgBox = new MessageDialog("请输入姓名、城市和年龄。");
if(txtName.Text == "" || txtCity.Text == "" || txtAge.Text == "")
{
await msgBox.ShowAsync();
return;
}
btn.IsEnabled = false;
// 获取文档库目录
StorageFolder doclib = KnownFolders.DocumentsLibrary;
// 将输入的内容转化为 json 对象
JsonObject json = new JsonObject();
json.Add("name", JsonValue.CreateStringValue(txtName.Text));
json.Add("city", JsonValue.CreateStringValue(txtCity.Text));
json.Add("age", JsonValue.CreateNumberValue(Convert.ToDouble(txtAge.Text)));
// 提取出 json 字符串
string jsonStr = json.Stringify();
// 在文档库中创建新文件
string fileName = DateTime.Now.ToString("yyyy-M-d-HHmmss") + ".mydoc";
StorageFile newFile = await doclib.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
// 将 json 字符串写入文件
await FileIO.WriteTextAsync(newFile, jsonStr);
btn.IsEnabled = true;
msgBox.Content = "保存成功";
await msgBox.ShowAsync();
}
示例5: buttonAgregar_Click
private async void buttonAgregar_Click(object sender, RoutedEventArgs e)
{
MessageDialog mensajeError = new MessageDialog("Los campos con * son OBLIGATORIOS");
int error = -1;
if (comboBoxCiudad.SelectedIndex != 0 || comboBoxEstado.SelectedIndex != 0 || textboxCodigoPostal.Text.Length != 0)
{
int idCiudad = listaCiudad[comboBoxCiudad.SelectedIndex-1].Id;
if (BufferUsuario.Usuario != null)
{
error = await servicio.agregarDireccionUsuarioAsync(BufferUsuario.Usuario.Id, idCiudad, textBoxDetalle.Text, int.Parse(textboxCodigoPostal.Text));
if (error == 1)
{
BufferUsuario.Usuario.Direcciones = await servicio.buscarDireccionUsuarioAsync(BufferUsuario.Usuario.Id);
var rootFrame = new Frame();
pagina.cargarDireciones();
popup.IsOpen = false;
servicio.enviarCorreoDeModificacionAsync(BufferUsuario.Usuario);
}
}
}
else
{
mensajeError.ShowAsync();
}
if (error == 0)
{
mensajeError.Content = "No se pudo agregar la nueva dirección";
mensajeError.ShowAsync();
}
}
示例6: btSalvar_Click
private async void btSalvar_Click(object sender, RoutedEventArgs e)
{
MessageDialog dialog = new MessageDialog("");
double consumo = 0;
if (tbPotencia.Text != null && tbPotencia.Text.Trim() != "" && tbNome.Text != null && tbNome.Text.Trim() != ""
&& tbHoras.Text != null && tbHoras.Text.Trim() != "" && tbDias.Text != null && tbDias.Text.Trim() != "")
{
if (!(IsNumber(tbDias.Text) && IsNumber(tbHoras.Text) && IsNumber(tbPotencia.Text)))
{
dialog.Content = "Entrada inválida!";
await dialog.ShowAsync();
}
else
{
tbDias.Text = FinancasPage.ValidateAndReplaceComa(tbDias.Text);
tbHoras.Text = FinancasPage.ValidateAndReplaceComa(tbHoras.Text);
tbPotencia.Text = FinancasPage.ValidateAndReplaceComa(tbPotencia.Text);
if (double.Parse(tbDias.Text) > 0 && double.Parse(tbHoras.Text) > 0 && double.Parse(tbPotencia.Text) > 0)
{
consumo = ((double.Parse(tbPotencia.Text) / 1000) * double.Parse(tbDias.Text) * double.Parse(tbHoras.Text)) ;
Eletrodomestico eletrodomestico = new Eletrodomestico();
eletrodomestico.Consumo = consumo;
eletrodomestico.DiasUsado = int.Parse(tbDias.Text);
eletrodomestico.TempoDeUso = double.Parse(tbHoras.Text);
eletrodomestico.Potencia = double.Parse(tbPotencia.Text);
eletrodomestico.Nome = tbNome.Text;
eletrodomestico.UsuarioId = HomePage.currentUser.Id;
await App.MobileService.GetTable<Eletrodomestico>().InsertAsync(eletrodomestico);
dialog.Content = "Eletrodoméstico inserido com sucesso!";
await dialog.ShowAsync();
LimparTextBox();
App.MnFrame.Navigate(typeof(MeusEletrodomesticosPage));
}
else
{
dialog.Content = "Entrada inválida!";
await dialog.ShowAsync();
}
}
}
else
{
dialog.Content = "Todos os campos devem ser preenchidos!";
await dialog.ShowAsync();
}
}
示例7: ShowDialog
public async static void ShowDialog(MessageDialog dialog)
{
if (dispatcher != null)
{
await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
async () =>
{
await dialog.ShowAsync();
});
}
else
await dialog.ShowAsync();
}
示例8: login_Click
private async void login_Click(object sender, RoutedEventArgs e)
{
var i = new MessageDialog("");
//若没有输入账号密码就开始登录
if(account.Text == "")
{
i.Content = "请输入账号";
await i.ShowAsync();
}
else if(password.Text == "")
{
i.Content = "请输入密码";
await i.ShowAsync();
}
else
{
var db = App.conn;
using (var statement = db.Prepare("SELECT * FROM Players WHERE Account = ? AND Password = ?"))
{
statement.Bind(1, account.Text);
statement.Bind(2, password.Text);
if (statement.Step() == SQLiteResult.ROW)
{
try
{
var username = (string)statement[1];
var password = (string)statement[2];
var account = (string)statement[3];
long highestScore = (long)statement[4];
App.Player = new Models.player(username, password, account, (string)statement[5], highestScore);
//若登录成功
Frame.Navigate(typeof(EnterPage), App.Player);
}
catch (Exception err)
{
}
}
else
{
var p = new MessageDialog("请输入正确的账号和密码").ShowAsync();
}
}
}
//若登录不成功(账号密码不匹配之类)需添加代码(还有一个else if)
}
示例9: showAsync
private async void showAsync(string title, string message, MessageBoxTypes type, MessageBoxOptions options, MessageBoxCallback callback)
#endif
{
#if WINDOWS_PHONE
WinRTPlugin.Dispatcher.BeginInvoke(delegate()
{
// XNA method
Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(title, message,
new System.Collections.Generic.List<string> {options.OkButtonName, options.CancelButtonText}, 0, Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.Error,
asyncResult =>
{
int? result = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(asyncResult);
ReignServices.InvokeOnUnityThread(delegate
{
if (callback != null) callback(result == 0 ? MessageBoxResult.Ok : MessageBoxResult.Cancel);
});
}, null);
// Silverlight method. (Doesn't support custom named buttons)
//var result = MessageBox.Show(message, title, type == MessageBoxTypes.Ok ? MessageBoxButton.OK : MessageBoxButton.OKCancel);
//if (callback != null) callback(result == System.Windows.MessageBoxResult.OK ? MessageBoxResult.Ok : MessageBoxResult.Cancel);
});
#else
await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate()
{
var msg = new MessageDialog(message, title);
if (type == MessageBoxTypes.Ok)
{
await msg.ShowAsync();
ReignServices.InvokeOnUnityThread(delegate
{
if (callback != null) callback(MessageBoxResult.Ok);
});
}
else if (type == MessageBoxTypes.OkCancel)
{
bool result = false;
msg.Commands.Add(new UICommand(options.OkButtonName, new UICommandInvokedHandler((cmd) => result = true)));
msg.Commands.Add(new UICommand(options.CancelButtonText, new UICommandInvokedHandler((cmd) => result = false)));
await msg.ShowAsync();
ReignServices.InvokeOnUnityThread(delegate
{
if (callback != null) callback(result ? MessageBoxResult.Ok : MessageBoxResult.Cancel);
});
}
});
#endif
}
示例10: PlaySound
private async void PlaySound(Uri soundUri)
{
Exception exception = null;
try
{
if (_audioPlayer == null)
_audioPlayer = new AudioPlayer();
_audioPlayer.PlaySound(soundUri);
}
catch (Exception ex)
{
exception = ex;
}
if (exception != null)
{
var dialog = new MessageDialog(exception.ToString(), "Exception Caught!");
try
{
await dialog.ShowAsync();
}
catch (UnauthorizedAccessException)
{
}
}
}
示例11: RetriveUserInfo
private async System.Threading.Tasks.Task RetriveUserInfo(AccessTokenData accessToken)
{
var client = new Facebook.FacebookClient(accessToken.AccessToken);
dynamic result = null;
bool failed = false;
try
{
result = await client.GetTaskAsync("me?fields=id,birthday,first_name,last_name,middle_name,gender");
}
catch(Exception e)
{
failed = true;
}
if(failed)
{
MessageDialog dialog = new MessageDialog("Facebook is not responding to our authentication request. Sorry.");
await dialog.ShowAsync();
throw new Exception("Windows phone does not provide an exit function, so we have to crash the app.");
}
string fullName = string.Join(" ", new[] { result.first_name, result.middle_name, result.last_name });
string preferredName = result.last_name;
bool? gender = null;
if (result.gender == "female")
{
gender = true;
}
else if (result.gender == "male")
{
gender = false;
}
DateTime birthdate = DateTime.UtcNow - TimeSpan.FromDays(365 * 30);
if (result.birthday != null)
{
birthdate = DateTime.Parse(result.birthday);
}
var currentUser = new Facebook.Client.GraphUser(result);
long facebookId = long.Parse(result.id);
UserState.ActiveAccount = await Api.Do.AccountFacebook(facebookId);
if (UserState.ActiveAccount == null)
{
Frame.Navigate(typeof(CreatePage), new CreatePage.AutofillInfo
{
SocialId = facebookId,
Authenticator = Authenticator.Facebook,
Birthdate = birthdate,
FullName = fullName,
Gender = gender,
PreferredName = preferredName
});
}
else
{
Frame.Navigate(typeof(MainPage), UserState.CurrentId);
}
}
示例12: button_Click
private async void button_Click(object sender, RoutedEventArgs e)
{
String Antwort = "";
string Ziel = "/Nachricht.php?";
HttpContent content = new FormUrlEncodedContent(new[] // POST inhalt vorbereiten
{
new KeyValuePair<string, string>("NachrichtHead", GlobalData.Pers_ID),
new KeyValuePair<string, string>("Betreff",textBox1.Text),
new KeyValuePair<string, string>("inhalt", textBox.Text),
});
// Schritt 4 Abfrage abschicken und ergebnis entgegennehmen
try
{
Antwort = await Globafunctions.HttpAbfrage(Ziel, content);
}
catch
{
MessageDialog msgbox = new MessageDialog("Nachricht konnte nicht Versendet werden");
await msgbox.ShowAsync();
}
MessageDialog msgbox1 = new MessageDialog(Antwort);
await msgbox1.ShowAsync();
Frame.Navigate(typeof(Intern));
}
示例13: BluetoothManager_ExceptionOccured
private async void BluetoothManager_ExceptionOccured(object sender, Exception ex)
{
var md = new MessageDialog(ex.Message, "We've got a problem with bluetooth...");
md.Commands.Add(new UICommand("Ok"));
md.DefaultCommandIndex = 0;
var result = await md.ShowAsync();
}
示例14: GetMyInfoAsync
/// <summary>
/// Restituisce i dati dell'utente
/// </summary>
public static async Task<Microsoft.Graph.User> GetMyInfoAsync()
{
//JObject jResult = null;
try
{
HttpClient client = new HttpClient();
var token = await OfficeHelper.GetTokenAsync();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
// Endpoint dell'utente loggato
Uri usersEndpoint = new Uri($"{serviceEndpoint}me");
HttpResponseMessage response = await client.GetAsync(usersEndpoint);
if (response.IsSuccessStatusCode)
{
string responseContent = await response.Content.ReadAsStringAsync();
return Newtonsoft.Json.JsonConvert.DeserializeObject<Microsoft.Graph.User>(responseContent);
}
else
{
var msg = new MessageDialog("Non è stato possibile recuperare i dati dell'utente. Risposta del server: " + response.StatusCode);
await msg.ShowAsync();
return null;
}
}
catch (Exception e)
{
var msg = new MessageDialog("Si è verificato il seguente errore: " + e.Message);
await msg.ShowAsync();
return null;
}
}
示例15: LogoutAsync
// Define a method that performs the authentication process
// using a Facebook sign-in.
//private async System.Threading.Tasks.Task AuthenticateAsync()
//{
// while (user == null)
// {
// string message;
// try
// {
// // Change 'MobileService' to the name of your MobileServiceClient instance.
// // Sign-in using Facebook authentication.
// user = await App.MobileService
// .LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
// message =
// string.Format("You are now signed in - {0}", user.UserId);
// }
// catch (InvalidOperationException)
// {
// message = "You must log in. Login Required";
// }
// var dialog = new MessageDialog(message);
// dialog.Commands.Add(new UICommand("OK"));
// await dialog.ShowAsync();
// }
//}
public override async void LogoutAsync()
{
App.MobileService.Logout();
string message;
// This sample uses the Facebook provider.
var provider = "AAD";
// Use the PasswordVault to securely store and access credentials.
PasswordVault vault = new PasswordVault();
PasswordCredential credential = null;
try
{
// Try to get an existing credential from the vault.
credential = vault.FindAllByResource(provider).FirstOrDefault();
vault.Remove(credential);
}
catch (Exception)
{
// When there is no matching resource an error occurs, which we ignore.
}
message = string.Format("You are now logged out!");
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
IsLoggedIn = false;
}