public async void ShowMessageDialog(DialogMessage message) { using (await ALocker.LockAsync()) { callback = null; if (message.Description != null && message.Title != null) { Title = message.Title; Body.Text = message.Description; } else { Title = ""; Body.Text = message.Description; } LinkContainer.Children.Clear(); if (message.Buttons != null && message.Buttons.Count > 0) { IsPrimaryButtonEnabled = false; foreach (var b in message.Buttons) { HyperlinkButton button = new HyperlinkButton(); button.Content = b.Text; button.Tag = b.Id; button.Tapped += Button_Tapped; LinkContainer.Children.Add(button); } } else { IsPrimaryButtonEnabled = true; PrimaryButtonText = "Ok"; } if (message.CallBack != null) { callback = message.CallBack; } await ShowAsync(); } }
private async void dialogMessageReceiver(DialogMessage dm) { MessageDialog dialog = null; if (dm.Description != null && dm.Title != null) { dialog = new MessageDialog(dm.Description, dm.Title); } else { dialog = new MessageDialog(dm.Description ?? ""); } if (dm.Buttons != null && dm.Buttons.Count > 0) { foreach (var b in dm.Buttons) { dialog.Commands.Add(new UICommand(b.Text) { Id = b.Id }); } } IUICommand result; using (await alock.LockAsync()) { result = await dialog.ShowAsync(); } if (dm.CallBack != null) { dm.CallBack(Convert.ToInt32(result.Id)); } }
private void checkInternetAccess() { var profile = NetworkInformation.GetInternetConnectionProfile(); if (profile != null) { var state = profile.GetNetworkConnectivityLevel(); switch (state) { case NetworkConnectivityLevel.None: DialogMessage dm = new DialogMessage(); dm.Description = MM.M.GetString("Network_NoConnectivity"); ViewModelLocator.Messenger.Send(dm); break; case NetworkConnectivityLevel.ConstrainedInternetAccess: DialogMessage dm1 = new DialogMessage(); dm1.Description = MM.M.GetString("Network_ConstrainedInternetAccess"); ViewModelLocator.Messenger.Send(dm1); break; case NetworkConnectivityLevel.LocalAccess: DialogMessage dm2 = new DialogMessage(); dm2.Description = MM.M.GetString("Network_LocalAccess"); ViewModelLocator.Messenger.Send(dm2); break; default: break; } } else { DialogMessage d = new DialogMessage(); d.Description = MM.M.GetString("Network_NoConnectivity"); ViewModelLocator.Messenger.Send(d); } }
private void Settings_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) { args.Request.ApplicationCommands.Add(new SettingsCommand("ReportBug", MM.M.GetString("Settings_ReportBug"), (a) => { DialogMessage message = new DialogMessage(); message.Title = MM.M.GetString("RAB_Dialog_Title"); message.Description = MM.M.GetString("RAB_Dialog_Description"); message.Buttons = new System.Collections.Generic.List<Particle.Common.Models.MessageButtonModel>() { new Particle.Common.Models.MessageButtonModel() { Id = 1, Text = MM.M.GetString("RAB_Dialog_GoToGithub") }, new Particle.Common.Models.MessageButtonModel() { Id = 2, Text = MM.M.GetString("Cancel_Button") } }; message.CallBack = async (id) => { if (id == 1) { await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/ParticleNET/Particle-Windows-app/issues")); } }; ViewModelLocator.Messenger.Send(message); })); args.Request.ApplicationCommands.Add(new SettingsCommand("Store", MM.M.GetString("Settings_Store"), async (a) => { await Windows.System.Launcher.LaunchUriAsync(new Uri("https://store.particle.io/")); })); args.Request.ApplicationCommands.Add(new SettingsCommand("License", MM.M.GetString("Settings_License"), async (a) => { await Windows.System.Launcher.LaunchUriAsync(new Uri("https://raw.githubusercontent.com/ParticleNET/Particle-Windows-app/master/LICENSE")); })); }