本文整理匯總了C#中Windows.UI.Popups.MessageDialog類的典型用法代碼示例。如果您正苦於以下問題:C# MessageDialog類的具體用法?C# MessageDialog怎麽用?C# MessageDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MessageDialog類屬於Windows.UI.Popups命名空間,在下文中一共展示了MessageDialog類的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: 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);
}
}
示例5: CreateGraphics
// Create three List<Graphic> objects with random graphics to serve as layer GraphicsSources
private async void CreateGraphics()
{
try
{
await MyMapView.LayersLoadedAsync();
_graphicsSources = new List<List<Graphic>>()
{
new List<Graphic>(),
new List<Graphic>(),
new List<Graphic>()
};
foreach (var graphicList in _graphicsSources)
{
for (int n = 0; n < 10; ++n)
{
graphicList.Add(CreateRandomGraphic());
}
}
_graphicSourceIndex = 0;
_graphicsLayer.GraphicsSource = _graphicsSources[_graphicSourceIndex];
}
catch (Exception ex)
{
var _x = new MessageDialog("Exception occurred : " + ex.ToString(), "Sample error").ShowAsync();
}
}
示例6: 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;
}
示例7: JePropose1_Click
private async void JePropose1_Click(object sender, RoutedEventArgs e)
{
string message = "";
var dialog = new MessageDialog("");
dialog.Title = "Proposition d'évenement :";
dialog.Commands.Add(new UICommand("OK"));
var eventSending = new EventGest();
if (await verifForm())
{
var NewEvent = new Event();
NewEvent.TitreEvent = TextBoxTitre.Text;
NewEvent.NbParticipEvent = int.Parse(TextBoxNbrPartMax.Text);
NewEvent.ThemeEvent = ThemeCombo.SelectedItem.ToString();
NewEvent.AdresseEvent = adressSugest.Text;
NewEvent.DateEvent = CalendarStart.Date.ToString();
NewEvent.DescripEvent = DescriptionTextboxTitre.Text;
NewEvent.PhotoEvent = ImageTextBox.Text;
NewEvent.IdUser = App.MobileService.CurrentUser.UserId.ToString();
NewEvent.TimeEvent = TimePicker.Time.Hours.ToString();
NewEvent.Duration = DurationPicker.Time.ToString();
eventSending.sendEvent(NewEvent);
Frame.GoBack();
message = "Envoyé avec succé :D";
}
else
{
message = "Champs invalide :(";
}
dialog.Content = message;
await dialog.ShowAsync();
}
示例8: 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;
}
}
示例9: MyMapView_MapViewTapped
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_trafficOverlay.Visibility = Visibility.Collapsed;
_trafficOverlay.DataContext = null;
var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));
// Get current viewpoints extent from the MapView
var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
{
LayerIDs = new int[] { 2, 3, 4 },
LayerOption = LayerOption.Top,
SpatialReference = MyMapView.SpatialReference,
};
var result = await identifyTask.ExecuteAsync(identifyParams);
if (result != null && result.Results != null && result.Results.Count > 0)
{
_trafficOverlay.DataContext = result.Results.First();
_trafficOverlay.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例10: StartDrawingButton_Click
// Accepts two user shapes and adds them to the graphics layer
private async void StartDrawingButton_Click(object sender, RoutedEventArgs e)
{
try
{
btnDraw.IsEnabled = false;
btnTest.IsEnabled = false;
resultPanel.Visibility = Visibility.Collapsed;
_graphicsOverlay.Graphics.Clear();
// Shape One
Esri.ArcGISRuntime.Geometry.Geometry shapeOne = await MyMapView.Editor.RequestShapeAsync(
(DrawShape)comboShapeOne.SelectedValue, _symbols[comboShapeOne.SelectedIndex]);
_graphicsOverlay.Graphics.Add(new Graphic(shapeOne, _symbols[comboShapeOne.SelectedIndex]));
// Shape Two
Esri.ArcGISRuntime.Geometry.Geometry shapeTwo = await MyMapView.Editor.RequestShapeAsync(
(DrawShape)comboShapeTwo.SelectedValue, _symbols[comboShapeTwo.SelectedIndex]);
_graphicsOverlay.Graphics.Add(new Graphic(shapeTwo, _symbols[comboShapeTwo.SelectedIndex]));
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
finally
{
btnDraw.IsEnabled = true;
btnTest.IsEnabled = (_graphicsOverlay.Graphics.Count >= 2);
}
}
示例11: ShowYesNoMessage
/// <summary>
/// Shows a yes no dialog with a message.
/// MUST BE CALLED FROM THE UI THREAD!
/// </summary>
/// <param name="title"></param>
/// <param name="content"></param>
/// <returns></returns>
public async Task<bool?> ShowYesNoMessage(string title, string content, string postiveButton = "Yes", string negativeButton = "No")
{
// Don't show messages if we are in the background.
if (m_baconMan.IsBackgroundTask)
{
return null;
}
bool? response = null;
// Add the buttons
MessageDialog message = new MessageDialog(content, title);
message.Commands.Add(new UICommand(
postiveButton,
(IUICommand command)=> {
response = true; }));
message.Commands.Add(new UICommand(
negativeButton,
(IUICommand command) => { response = false; }));
message.DefaultCommandIndex = 0;
message.CancelCommandIndex = 1;
// Show the dialog
await message.ShowAsync();
return response;
}
示例12: checkInput
private async void checkInput()
{
int numCard = 0;
Int32.TryParse(numCardBox.Text, out numCard);
if (Int32.TryParse(numCardBox.Text, out numCard) != false && numCard <= 1000) //if input is valid
{
if (CardReturn.IsChecked == true)
{
//reset all drawned card list
drawned = new bool[4, 13];
numDrawned = 0;
cardDrawReturn(numCard);
}
else
cardDrawNoReturn(numCard);
}
else if (Int32.TryParse(numCardBox.Text, out numCard) != false && (numCard > 1000 || numCard < 0)) //if input is out of bound
{
var messageDialog = new MessageDialog("Please enter a number between 0 and 1000.");
messageDialog.Title = "Invalid Input";
// Show the message dialog and wait
await messageDialog.ShowAsync();
}
else
{
var messageDialog = new MessageDialog("Please enter a real number."); //if input is not an integer
messageDialog.Title = "Invalid Input";
// Show the message dialog and wait
await messageDialog.ShowAsync();
}
}
示例13: CheckIn
private async void CheckIn(int roomId)
{
if (string.IsNullOrWhiteSpace(FirstName) || string.IsNullOrWhiteSpace(LastName) || SelectedRoom == null)
{
MessageDialog dialog = new MessageDialog("You must enter first and last name and select a room", "Error");
await dialog.ShowAsync();
return;
}
var sensor = new Sensor
{
FirstName = FirstName,
LastName = LastName,
SensorId = 5,
SensorMac = "1"
};
var presence = new SensorPresence
{
RoomId = roomId,
SensorId = sensor.SensorId,
TimeStamp = DateTime.Now
};
await serverHubProxy.Invoke("RecordLocation", presence, sensor);
navigationService.NavigateTo("checkedInList");
}
示例14: NavigateToRightPage
private async Task NavigateToRightPage(bool loginContextPresent, bool projectContextPresent)
{
bool loginSuccess = false; ;
if(loginContextPresent && projectContextPresent)
{
Action executeAction = () =>
{
loginSuccess = LoginService.VSTSLogin();
};
executeAction();
if (loginSuccess == false)
{
MessageDialog msgBox = new MessageDialog("Failed to login. Check internet connectivity and try again!");
var res = await msgBox.ShowAsync();
if(Frame != null)
{
Frame.Navigate(typeof(LoginPage));
}
}
else
{
Frame.Navigate(typeof(ServiceSelectionPage));
}
}
else
{
Frame.Navigate(typeof(LoginPage));
}
}
示例15: ShowAsync
public static async Task<MessageBoxResult> ShowAsync ( string messageBoxText,
string caption,
MessageBoxButton button )
{
MessageDialog md = new MessageDialog ( messageBoxText, caption );
MessageBoxResult result = MessageBoxResult.None;
if ( button.HasFlag ( MessageBoxButton.OK ) )
{
md.Commands.Add ( new UICommand ( "OK",
new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.OK ) ) );
}
if ( button.HasFlag ( MessageBoxButton.Yes ) )
{
md.Commands.Add ( new UICommand ( "Yes",
new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Yes ) ) );
}
if ( button.HasFlag ( MessageBoxButton.No ) )
{
md.Commands.Add ( new UICommand ( "No",
new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.No ) ) );
}
if ( button.HasFlag ( MessageBoxButton.Cancel ) )
{
md.Commands.Add ( new UICommand ( "Cancel",
new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Cancel ) ) );
md.CancelCommandIndex = ( uint ) md.Commands.Count - 1;
}
var op = await md.ShowAsync ();
return result;
}