當前位置: 首頁>>代碼示例>>C#>>正文


C# MessageDialog.ShowAsync方法代碼示例

本文整理匯總了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();
            }
        }
開發者ID:yavuzgedik,項目名稱:Windows10_UWP,代碼行數:30,代碼來源:LoginPage.xaml.cs

示例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));
            }
            
           
        }
開發者ID:gwenoleR,項目名稱:yana_for_WP8.1,代碼行數:25,代碼來源:configPage.xaml.cs

示例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();
            }
        }
開發者ID:nanderto,項目名稱:Thinktecture.AuthorizationServer,代碼行數:26,代碼來源:MainPage.xaml.cs

示例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();
 }
開發者ID:forehalo,項目名稱:UWP-dev,代碼行數:28,代碼來源:MainPage.xaml.cs

示例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();

            }

        }
開發者ID:alonsonic,項目名稱:Desarrollo,代碼行數:35,代碼來源:DireccionPopup.xaml.cs

示例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();
            }

        }
開發者ID:wildergalvao,項目名稱:EnergyManager,代碼行數:56,代碼來源:InserirPage.xaml.cs

示例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();
 }
開發者ID:charla-n,項目名稱:FTR,代碼行數:13,代碼來源:MainPage.xaml.cs

示例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)

        }
開發者ID:SplendidSky,項目名稱:Visual-Studio-2015,代碼行數:49,代碼來源:MainPage.xaml.cs

示例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
		}
開發者ID:lPinchol,項目名稱:Reign-Unity-Plugin,代碼行數:48,代碼來源:MessageBoxPlugin.cs

示例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)
                {
                }
            }
        }
開發者ID:mnill,項目名稱:audioplayer,代碼行數:28,代碼來源:MainPage.xaml.cs

示例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);
            }
        }
開發者ID:tblue1994,項目名稱:SoftwareEngineeringProject2015,代碼行數:60,代碼來源:FacebookAuthentication.xaml.cs

示例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));
        }
開發者ID:RobinBrandt87,項目名稱:OSS,代碼行數:28,代碼來源:Nachrichten.xaml.cs

示例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();
 }
開發者ID:mohamedemam0,項目名稱:Lights-Demo,代碼行數:7,代碼來源:MainPage.xaml.cs

示例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;
            }
        }
開發者ID:mamarche,項目名稱:MyUniversalInfo,代碼行數:37,代碼來源:OfficeHelper.cs

示例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;

        }
開發者ID:karolzak,項目名稱:XAML-Blend-Tutorial,代碼行數:55,代碼來源:MainPageViewModel.cs


注:本文中的Windows.UI.Popups.MessageDialog.ShowAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。