private async void RecipeGridView_ItemClick(object sender, ItemClickEventArgs e) { FoodRecipe fr = e.ClickedItem as FoodRecipe; var contentDialog = new ContentDialog() { Content = new FoodRecipeDialog(fr), PrimaryButtonText = "确定", FullSizeDesired = false }; contentDialog.Style = transparent; contentDialog.Closed += async(_s, _e) => { await FoodGrid.Blur(value : 0, duration : 0, delay : 0).StartAsync(); contentDialog.Hide(); }; contentDialog.PrimaryButtonClick += async(_s, _e) => { await FoodGrid.Blur(value : 0, duration : 0, delay : 0).StartAsync(); contentDialog.Hide(); }; await FoodGrid.Blur(value : 7, duration : 100, delay : 0).StartAsync(); await contentDialog.ShowAsync(); }
/// <summary> /// Shows a yes/no dialog box that will return true for yes and false for no. /// </summary> /// <param name="title"></param> /// <param name="message"></param> public static async Task <DialogResult> ShowYesNo(string message, string title) { var dialog = new ContentDialog { Title = title, Content = message, PrimaryButtonText = "Yes", SecondaryButtonText = "No" }; var signal = new TaskCompletionSource <DialogResult>(); dialog.PrimaryButtonClick += (o, e) => { dialog.Hide(); signal.SetResult(DialogResult.Yes); }; dialog.SecondaryButtonClick += (o, e) => { dialog.Hide(); signal.SetResult(DialogResult.No); }; // https://stackoverflow.com/questions/55305898/contentdialog-delay-after-ok-clicked // We will not await the dialog, we will await the signal so the caller page gets the result instantly without // a lagged delay that is noticable. #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed dialog.ShowAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed await signal.Task; return(signal.Task.Result); }
public static async void openGameOverScreen(Windows.UI.Xaml.Controls.Grid BoardGrid) { if (Board.Instance.isGameOver()) { var dialog = new ContentDialog() { Title = "Game over!", MaxWidth = 400,// Required for Mobile! Content = "Winner is " + Board.Instance.getWinner() + "\n" + Board.Instance.getScores() }; dialog.PrimaryButtonText = "Start new game"; dialog.SecondaryButtonText = "Go back to set up"; dialog.IsPrimaryButtonEnabled = true; dialog.PrimaryButtonClick += delegate { Board.Instance.startGame(Board.Instance.NumberOfCards, Board.Instance.NumberOfPlayers); displayBoard(Convert.ToInt32(Math.Sqrt(Board.Instance.NumberOfCards)), BoardGrid); dialog.Hide(); }; dialog.SecondaryButtonClick += delegate { Page boardPage = getParentPage(BoardGrid); boardPage.Frame.Navigate(typeof(MainPage)); dialog.Hide(); }; var result = await dialog.ShowAsync(); } }
private async void GameCacnceled(string userName) { await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { _AnswerForGameDialog.Hide(); await new MessageDialog($"{userName} canceled the game request").ShowAsync(); }); }
private void OnButtonPress(GpioPin sender, GpioPinValueChangedEventArgs e) { var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (e.Edge == GpioPinEdge.FallingEdge) { if (sender == _greenButtonPin) { if (_dialogueOpen == false) { PlayAlert(); } else { ConfirmRemoveAlert(); _removeAlertDialog.Hide(); } } else if (sender == _yellowButtonPin) { if (_dialogueOpen == false) { SnoozeAlert(); } } else if (sender == _redButtonPin) { if (_dialogueOpen == false) { RemoveAlert(); } else { _redLedPin.Write(GpioPinValue.Low); _removeAlertDialog.Hide(); } } else if (sender == _upButtonPin) { if (_dialogueOpen == false) { GoUp(); } } else if (sender == _downButtonPin) { if (_dialogueOpen == false) { GoDown(); } } else if (sender == _cancelButtonPin) { Cancel(); } } }); }
private void TextBox_Selected(object sender, SelectionChangedEventArgs e) { #if WINDOWS_PHONE_APP if (e.AddedItems.Count == 1) { Selected = e.AddedItems.Cast <StopModel>().First().Value; customDialog.Hide(); } #endif }
public MapController(MapControl myMap) { this._myMap = myMap; Debug.WriteLine("now in mappage" + _myMap); dialog.Hide(); dialog.FullSizeDesired = true; dialog.PrimaryButtonClick += Dialog_CloseButton; //drawRoute(new Geopoint(new BasicGeoposition { Longitude = 4.780172, Latitude = 51.586267 }), new Geopoint(new BasicGeoposition { Longitude = 4.0, Latitude = 51.0 })); GeofenceMonitor.Current.GeofenceStateChanged += OnGeofenceStateChanged; }
/// <summary> /// Closes the dialog /// </summary> public void Close() { _isClosing = true; _contentDialog.Hide(); _touchHandler.Dispose(); Window.Current.CoreWindow.KeyDown -= CoreWindowOnKeyDown; SystemNavigationManager.GetForCurrentView().BackRequested -= OnBackRequested; DisplayInformation.GetForCurrentView().OrientationChanged -= OnOrientationChanged; var inputPane = InputPane.GetForCurrentView(); inputPane.Hiding -= InputPaneOnHidingOrShowing; inputPane.Showing -= InputPaneOnHidingOrShowing; this.GetReactContext().GetNativeModule <ExceptionsManagerModule>().BeforeShowDevOptionsDialog -= Close; }
private async void BookmarkPage_Click(object sender, RoutedEventArgs e) { var BookMarkThisPage = new ContentDialog() { Title = "Bookmark current Page" }; var savedBookmarkMessage = new MessageDialog("Bookmark Saved successfully.", "Message"); var panel = new StackPanel(); var titleText = new TextBlock(); titleText.Text = "Title"; var UriText = new TextBlock(); UriText.Text = "URL"; var titleBox = new TextBox(); titleBox.Text = MainWeb.DocumentTitle.ToString(); var UriBox = new TextBox(); UriBox.Text = MainWeb.Source.AbsoluteUri.ToString(); panel.Children.Add(titleText); panel.Children.Add(titleBox); panel.Children.Add(UriText); panel.Children.Add(UriBox); BookMarkThisPage.Content = panel; BookMarkThisPage.PrimaryButtonText = "Save"; BookMarkThisPage.SecondaryButtonText = "Cancel"; var resultOfBookmarkDialog = await BookMarkThisPage.ShowAsync(); if (resultOfBookmarkDialog == ContentDialogResult.Primary) { WriteBookmarkFile("BookTitle.txt", titleBox.Text); WriteBookmarkFile("BookUri.txt", UriBox.Text); BookMarkThisPage.Hide(); await savedBookmarkMessage.ShowAsync(); } else { BookMarkThisPage.Hide(); } }
private async void BtnDelPurse_Click(object sender, RoutedEventArgs e) { if (purseList.SelectedItem != null) { ContentDialog deletePurse = new ContentDialog() { Title = "Подтверждение действия", Content = "Вы действительно хотите удалить данный счет?" + "\n" + "Удалятся все операции, связанные с данным счетом.", PrimaryButtonText = "Удалить", SecondaryButtonText = "Отмена" }; ContentDialogResult result = await deletePurse.ShowAsync(); if (result == ContentDialogResult.Primary) { Purse purse = purseList.SelectedItem as Purse; if (purse != null) { DeletePurseItem(purse); } } else { deletePurse.Hide(); } } else { errorText.Text = "Не выбран элемент"; } }
private async void AboutMe_Click(object sender, RoutedEventArgs e) { var contentDialog = new ContentDialog() { Content = new AboutMePage(), PrimaryButtonText = "确定", FullSizeDesired = true }; contentDialog.Style = transparent; contentDialog.Closing += async(_s, _e) => { await AboutGrid.Blur(0, 0, 0).StartAsync(); }; contentDialog.PrimaryButtonClick += async(_s, _e) => { await AboutGrid.Blur(0, 0, 0).StartAsync(); contentDialog.Hide(); }; await AboutGrid.Blur(10, 100, 0).StartAsync(); await contentDialog.ShowAsync(); }
public async void btnExecuteCommand(object sender, RoutedEventArgs e) { string command = commandBox.Text.ToLower(); ContinuousRecognize_Click(null, null); await Task.Run(async() => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { ContentDialog dialog = new ContentDialog() { Title = " ⓘ Information", PrimaryButtonText = "", Content = new ExampleControl(commandBox.Text), MaxWidth = 650, MinWidth = 650, MinHeight = 200, MaxHeight = 200, Style = Application.Current.Resources["MyContentDialogStyle"] as Style }; dialog.ShowAsync(); await Task.Delay(3500); dialog.Hide(); if (command.Contains("log") && command.Contains("out")) { SignOut_Click(null, null); } }); }); }
static async Task CreateDialog(ContentDialog Dialog, bool awaitPreviousDialog) { if (ActiveDialog != null) { if (awaitPreviousDialog) { ActiveDialog.Hide(); } else { switch (Info.Status) { case AsyncStatus.Started: Info.Cancel(); break; case AsyncStatus.Completed: Info.Close(); break; case AsyncStatus.Error: break; case AsyncStatus.Canceled: break; } } } ActiveDialog = Dialog; ActiveDialog.Closing += ActiveDialog_Closing; Info = ActiveDialog.ShowAsync(); }
private async void ColorPointRadioButton_DoubleTapped(object sender, RoutedEventArgs e) { ContentDialog dialog = GetCurrentContentDialog(); if (dialog != null) { dialog.Hide(); } ColorPickerDialog colorPickerDialog = new ColorPickerDialog(m_ColorPointModel.Color); await colorPickerDialog.ShowAsync(); if (colorPickerDialog.ColorPickerResult) { m_ColorPointModel.Color = colorPickerDialog.CurrentColor; ColorPatternViewModel.Self.OnCustomizeChanged(); } if (dialog != null) { await dialog.ShowAsync(); } else { MainPage.Self.ShowDeviceUpdateDialogOrNot(); } }
private void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { var model = (sender as FrameworkElement).DataContext as LayerModel; var d = new ContentDialog() { PrimaryButtonText = "Ok", SecondaryButtonText = "Cancel" }; //旧手机加上会闪退, CloseButtonText="Cancel" }; var s = new StackPanel(); var h = new TextBlock() { Text = "rename" }; var t = new TextBox() { Text = model.Name, AcceptsReturn = true, }; s.Children.Add(h); s.Children.Add(t); d.Content = s; d.PrimaryButtonClick += (ss, ee) => { model.Name = t.Text; }; d.SecondaryButtonClick += (ss, ee) => { d.Hide(); }; d.ShowMux(); }
private static async Task <ContentDialogResult> CreateDialog(ContentDialog Dialog, bool awaitPreviousDialog, bool Lock = false) { if (ActiveDialog != null) { if (awaitPreviousDialog || Locked) { await DialogAwaiter.Task; } else { ActiveDialog.Hide(); } } Locked = Lock; DialogAwaiter = new TaskCompletionSource <bool>(); ActiveDialog = Dialog; ActiveDialog.Closed += ActiveDialog_Closed; var result = await ActiveDialog.ShowAsync(); ActiveDialog.Closed -= ActiveDialog_Closed; if (Lock) { Locked = false; } return(result); }
public async Task <string> RenameAsync(string currentName) { if (IsDialogOpen) { return(currentName); } IsDialogOpen = true; var inputBoxControl = new RenameInputBox() { Input = currentName }; bool enterClicked = false; var dialog = new ContentDialog() { Title = Strings.Resources.RenameText, CloseButtonText = Strings.Resources.CancelText, PrimaryButtonText = Strings.Resources.RenameText, Content = inputBoxControl }; inputBoxControl.EnterClicked += (s, e) => { dialog.Hide(); enterClicked = true; }; var result = await dialog.ShowAsync(); IsDialogOpen = false; return(result == ContentDialogResult.Primary || enterClicked ? inputBoxControl.Input : currentName); }
public async Task UpdateLock() { await Task.Run(async() => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var imageSource = new BitmapImage(new Uri("ms-appx:///Images/voice_reco.gif")); voicereco.Source = imageSource; voicereco.Visibility = Visibility.Visible; playVoice.Play(); await Task.Delay(4500); lock_icon.Source = new BitmapImage(new Uri("ms-appx:///Images/lock_gif.gif")); lock_icon.Source = new BitmapImage(new Uri("ms-appx:///Images/lock_gif.gif")); await Task.Delay(3500); ContentDialog dialog = new ContentDialog() { Title = "Confirmation", MaxWidth = this.ActualWidth, IsPrimaryButtonEnabled = false, Content = new AuthentificationMessage() }; voicereco.Source = null; dialog.ShowAsync(); await Task.Delay(2000); dialog.Hide(); Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(MainPage)); //lock_icon.Source = new BitmapImage(new Uri("ms-appx:///Images/lock_modern_unlocked.png")); // RadialProgressBarControl.Visibility = Visibility.Collapsed; }); }); }
public static ContentDialog CommonContentDialog(string title, string message, string primaryButtonText, string secondaryButtonText = "") { HideProgressDialog(); if (_confirmationDialog != null) { _confirmationDialog.Hide(); _confirmationDialog = null; } var textBlock = new TextBlock(); var grid = new Grid { Height = 40, Width = 500, HorizontalAlignment = HorizontalAlignment.Stretch }; textBlock.Text = message; textBlock.TextWrapping = TextWrapping.Wrap; grid.Children.Add(textBlock); _confirmationDialog = new ContentDialog { Title = title, Content = grid, PrimaryButtonText = primaryButtonText, SecondaryButtonText = secondaryButtonText, }; return(_confirmationDialog); }
private void OKButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var html = String.Format(LINK_HTML, linkRefTextBox.Text, linkNameTextBox.Text); sender.Hide(); HyperlinkCreateEvent?.Invoke(html); }
private async void allowAccessButtonClicked(object sender, RoutedEventArgs e) { if (usersNotAllowedDropdown.SelectedItem == null) { Synthesizer.Speak("Please select the user you want to allow in the room."); } else { String[] userInfo = usersNotAllowedDropdown.SelectedItem.ToString().Split(','); ContentDialog deleteUserDialog = new ContentDialog { Title = "Are you sure you want to allow " + userInfo[1] + " in the room?", PrimaryButtonText = "Yes", SecondaryButtonText = "Cancel", }; ContentDialogResult result = await deleteUserDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { SqliteTransactions.ModifyAccessByUserId(userInfo[0], true); LoadUsers(); } else { deleteUserDialog.Hide(); } } }
private async void Button_Click(object sender, RoutedEventArgs e) { if (!IsLegal()) { TipsText.Text = "输入不合法,请检查输入后重新提交"; return; } else { TipsText.Text = "输入合法!"; if (DataBase.Instence.ChangeAirline(airline)) { father.Hide(); await new ContentDialog() { CloseButtonText = "关闭", Title = "修改航班成功!(若有用户在抢票则已经自动放票)", }.ShowAsync(); int moreticket = airline.remainticket - air.remainticket; if (moreticket > 0) { airline._remainticket -= DataBase.Instence.GiveTicket(air.airlinenum, air.date, moreticket); } air.remainticket = airline.remainticket; air.price = airline.price; } else { TipsText.Text = "航班号重复!!请重新输入"; } } }
private async void deleteFiliereAction(object sender, RoutedEventArgs e) { ContentDialog res = new ContentDialog { Title = "Suppression d'une Filiere !", Content = "Voulez-vous vraiment supprimer cette filière ?", PrimaryButtonText = "Supprimer", CloseButtonText = "Annuler" }; ContentDialogResult result = await res.ShowAsync(); if (result == ContentDialogResult.Primary) { // delete the student if (ListFilieres.Contains(selectedFiliere)) { // delete in db string query = @"Delete from Filieres WHERE id_filiere='" + selectedFiliere.Id_filiere.ToString() + "'"; ISQLiteStatement stmt = con.Prepare(query); stmt.Step(); // show tooltip MessageDialog dialog = new MessageDialog("Supprimée"); await dialog.ShowAsync(); // delete in local table ListFilieres.Remove(selectedFiliere); // clear the textbox filiereLabel.Text = ""; } } res.Hide(); }
private async void web_UnviewableContentIdentified(WebView sender, WebViewUnviewableContentIdentifiedEventArgs args) { this.FindName("_ucDownloadUI"); _ucDownloadUI.btDownload.Click += btStartDownload; _ucDownloadUI.tsDownload.Toggled += TsDownload_Toggled; if (_ucDownloadUI.tsDownload.IsOn) { ContentDialog cntExisitingDownload = new ContentDialog { Content = "A File is Downloading Currently, let it finish and then try again", Title = "Another file is Downloading", PrimaryButtonText = "Ok", SecondaryButtonText = "Check Download" }; cntExisitingDownload.SecondaryButtonClick += (s, a) => { cntExisitingDownload.Hide(); _ucDownloadUI.Visibility = Visibility.Visible; }; await cntExisitingDownload.ShowAsync(); return; } else { _ucDownloadUI.txbDownloadLink.Text = args.Uri.ToString(); _ucDownloadUI.txbFileName.Text = await UtilityClass.GetFileName(args.Uri); _ucDownloadUI.Visibility = Visibility.Visible; } }
async public void Submit() { ContentDialog dialog = new ContentDialog(); dialog.Title = "Error"; dialog.IsPrimaryButtonEnabled = true; dialog.PrimaryButtonText = "OK"; dialog.PrimaryButtonClick += delegate { dialog.Hide(); }; var sett = Services.SettingsServices.SettingsService.Instance.UserId; Views.Busy.SetBusy(true, "Saving Data"); var teams = await ProjectServices.UpdateTeamInProject(Users, projectId); Views.Busy.SetBusy(false); if (teams.result) { dialog.Content = teams.message; await dialog.ShowAsync(); NavigationService.Navigate(typeof(Views.ProjectManagement.ProjectHome), projectId.projectId); } else { dialog.Content = teams.result; await dialog.ShowAsync(); } }
public static async Task <string> PromptForSecret(string title, string msg, double maxWidth) { var dialog = new ContentDialog(); dialog.Title = title; dialog.MaxWidth = maxWidth; var panel = new StackPanel(); panel.Children.Add(new TextBlock { Text = msg, TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap }); var passwordBox = new PasswordBox(); passwordBox.IsPasswordRevealButtonEnabled = true; passwordBox.KeyUp += (o, e) => { if (e.Key == Windows.System.VirtualKey.Enter) { dialog.Hide(); } e.Handled = true; }; panel.Children.Add(passwordBox); dialog.Content = panel; dialog.PrimaryButtonText = "OK"; await dialog.ShowAsync(); return(passwordBox.Password); }
/// <summary> /// Calls the GetAllStudents Method in the APIHelper class /// </summary> /// <returns></returns> public async Task DownloadStudents() { loadScreen.ShowAsync(); allStudents = await ApiHelper.Instance.GetAllStudentsTestsQuestions(); loadScreen.Hide(); }
private async void DeleteDisplacement_Click(object sender, RoutedEventArgs e) { ContentDialog deleteDisplacement = new ContentDialog() { Title = "Подтверждение действия", Content = "Вы действительно хотите удалить данную операцию?", PrimaryButtonText = "Удалить", SecondaryButtonText = "Отмена" }; ContentDialogResult result = await deleteDisplacement.ShowAsync(); if (result == ContentDialogResult.Primary) { if (displacementElemnt != null) { DeleteDisplacementItem(displacementElemnt); if (sealedItemDisplacement) { sealedItemDisplacement = false; detailPanelDisplacement.Visibility = Visibility.Collapsed; } } } else { deleteDisplacement.Hide(); } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var picker = new FolderPicker(); picker.FileTypeFilter.Add(".jpg"); var folder = await picker.PickSingleFolderAsync(); if (folder != null) { try { var file = await StorageFile.GetFileFromPathAsync(OutputFilePath); await file.MoveAsync(folder, file.Name, NameCollisionOption.ReplaceExisting); CanDismiss = true; sender.Hide(); } catch { MessageDialog errorDialog = new MessageDialog("Something went wrong."); await errorDialog.ShowAsync(); } } }
private async void Button_Click(object sender, RoutedEventArgs e) { if (!IsLegal()) { TipsText.Text = "输入不合法,请检查输入后重新提交"; return; } else { TipsText.Text = "输入合法!"; if (DataBase.Instence.AddAirline(airline)) { father.Hide(); await new ContentDialog() { CloseButtonText = "关闭", Title = "插入航班成功!", }.ShowAsync(); } else { TipsText.Text = "航班号重复!!请重新输入"; } } }
private async void CallAppService() { await EnsureConnectionToService(); //Send data to the service var message = new ValueSet(); message.Add("Command", "CalcSum"); message.Add("Value1", Int32.Parse(Value1.Text)); message.Add("Value2", Int32.Parse(Value2.Text)); //Send a message AppServiceResponse response = await connection.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success) { int sum = (int)response.Message["Result"]; var cd = new ContentDialog(); cd.Title = "Result=" + sum; cd.PrimaryButtonText = "OK"; cd.PrimaryButtonClick += (s, a) => cd.Hide(); cd.ShowAsync(); } }
protected virtual void Show(IBitmap image, string message, Color bgColor, int timeoutMillis) { var stack = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Opacity = 0.7 }; if (image != null) { var source = image.ToNative(); stack.Children.Add(new Image { Source = source }); } stack.Children.Add(new TextBlock { Text = message, FontSize = 24f, TextAlignment = TextAlignment.Center, FontWeight = FontWeights.Bold }); var cd = new ContentDialog { Background = new SolidColorBrush(bgColor.ToNative()), BorderBrush = new SolidColorBrush(bgColor.ToNative()), Content = stack }; stack.Tapped += (sender, args) => cd.Hide(); this.Dispatch(() => cd.ShowAsync()); Task.Delay(TimeSpan.FromMilliseconds(timeoutMillis)) .ContinueWith(x => this.Dispatch(cd.Hide)); }
void Show(IBitmap image, string message, Color bgColor, int timeoutMillis) { var cd = new ContentDialog { Background = new SolidColorBrush(bgColor.ToNative()), Content = new TextBlock { Text = message } }; cd.ShowAsync(); Task.Delay(TimeSpan.FromMilliseconds(timeoutMillis)).ContinueWith(x => cd.Hide()); }
public static void ShowInDialog() { var dialog = new ContentDialog() { Template = Application.Current.Resources["ButtonLessContentDialogControlTemplate"] as ControlTemplate, RequestedTheme = ElementTheme.Light }; var frame = new Frame(); frame.Navigate(typeof(IntroPage), null); var page = frame.Content as IntroPage; page.DismissDialog = () => { dialog.Hide(); }; dialog.Content = frame; dialog.ShowAsync().Forget(); }
public override void Prompt(PromptConfig config) { var dialog = new ContentDialog { Title = config.Title }; var txt = new TextBox { PlaceholderText = config.Placeholder, Text = config.Text ?? String.Empty }; var stack = new StackPanel { Children = { new TextBlock { Text = config.Message }, txt } }; dialog.Content = stack; dialog.PrimaryButtonText = config.OkText; dialog.PrimaryButtonCommand = new Command(() => { config.OnResult?.Invoke(new PromptResult { Ok = true, Text = txt.Text.Trim() }); dialog.Hide(); }); if (config.IsCancellable) { dialog.SecondaryButtonText = config.CancelText; dialog.SecondaryButtonCommand = new Command(() => { config.OnResult?.Invoke(new PromptResult { Ok = false, Text = txt.Text.Trim() }); dialog.Hide(); }); } dialog.ShowAsync(); }
private async System.Threading.Tasks.Task DisplaySynonymsResponse(SynonymsServiceClientLibrary.SynonymsServiceResponse synonymsResponse) { string synonymsOutput = ""; if (synonymsResponse.Status == AppServiceResponseStatus.Success) { foreach (var item in synonymsResponse.Synonyms) { synonymsOutput += "|" + item; } var cd = new ContentDialog(); cd.Title = "Synonyms=" + synonymsOutput; cd.PrimaryButtonText = "OK"; cd.PrimaryButtonClick += (s, a) => cd.Hide(); await cd.ShowAsync(); } else { await new MessageDialog("Synonyms API call failed").ShowAsync(); } }
async void OnPageActionSheet(Page sender, ActionSheetArguments options) { List<string> buttons = options.Buttons.ToList(); var list = new Windows.UI.Xaml.Controls.ListView { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetList"], ItemsSource = buttons, IsItemClickEnabled = true }; var dialog = new ContentDialog { Template = (Windows.UI.Xaml.Controls.ControlTemplate)Windows.UI.Xaml.Application.Current.Resources["MyContentDialogControlTemplate"], Content = list, Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetStyle"] }; if (options.Title != null) dialog.Title = options.Title; list.ItemClick += (s, e) => { dialog.Hide(); options.SetResult((string)e.ClickedItem); }; _actionSheetOptions = options; if (options.Cancel != null) dialog.SecondaryButtonText = options.Cancel; if (options.Destruction != null) dialog.PrimaryButtonText = options.Destruction; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) options.SetResult(options.Cancel); else if (result == ContentDialogResult.Primary) options.SetResult(options.Destruction); }
private async Task<Credential> DoSignInInUIThread(CredentialRequestInfo credentialRequestInfo) { var signInDialog = this; // Create the ContentDialog that contains the SignInDialog var contentDialog = new ContentDialog { SecondaryButtonText = "cancel", PrimaryButtonText = "sign in", FullSizeDesired = true, Content = signInDialog, }; contentDialog.PrimaryButtonClick += ContentDialogOnPrimaryButtonClick; // Bind the Title so the ContentDialog Title is the SignInDialog title (that will be initialized later) contentDialog.SetBinding(ContentDialog.TitleProperty, new Binding { Path = new PropertyPath("Title"), Source = signInDialog }); contentDialog.SetBinding(ContentDialog.IsPrimaryButtonEnabledProperty, new Binding { Path = new PropertyPath("IsReady"), Source = signInDialog }); contentDialog.Closed += ContentDialogOnClosed; // be sure the SignInDialog is deactivated when pressing back button // Show the content dialog var _ = contentDialog.ShowAsync(); // don't await else that would block here // Wait for the creation of the credential Credential crd; try { crd = await signInDialog.WaitForCredentialAsync(credentialRequestInfo); } finally { // Close the content dialog contentDialog.Hide(); } return crd; }
public override void Toast(ToastConfig config) { // TODO: action text and action command will work here! var stack = new StackPanel { Orientation = Orientation.Horizontal }; if (config.Icon != null) { var icon = config.Icon.ToNative(); stack.Children.Add(new Image { Source = icon }); } stack.Children.Add(new TextBlock { Text = config.Text, Foreground = new SolidColorBrush(config.TextColor.ToNative()) }); var dialog = new ContentDialog { Content = stack, Background = new SolidColorBrush(config.BackgroundColor.ToNative()) }; dialog.Tapped += (sender, args) => { dialog.Hide(); config.Action?.Invoke(); }; dialog.ShowAsync(); Task.Delay(config.Duration) .ContinueWith(x => { try { dialog.Hide(); } catch { } // swallow race condition }); }
protected virtual void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config) { var txt = new PasswordBox { PlaceholderText = config.Placeholder ?? String.Empty, Password = config.Text ?? String.Empty }; if (config.MaxLength != null) txt.MaxLength = config.MaxLength.Value; stack.Children.Add(txt); dialog.PrimaryButtonCommand = new Command(() => { config.OnAction?.Invoke(new PromptResult(true, txt.Password)); dialog.Hide(); }); }
void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config) { var txt = new PasswordBox { PlaceholderText = config.Placeholder, Password = config.Text ?? String.Empty }; stack.Children.Add(txt); dialog.PrimaryButtonCommand = new Command(() => { config.OnResult?.Invoke(new PromptResult { Ok = true, Text = txt.Password }); dialog.Hide(); }); }
private void C_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { sender.Hide(); }
/// <summary> /// Shows the dialog. It takes <see cref="InputDialogViewModel"/> to populate the system dialog. It also sets the first command to be /// the default and last one to be the cancel command. /// </summary> /// <param name="viewType"> Type of dialog control. </param> public async void Show(Type viewType) { this.Initialize(); var dialog = new ContentDialog { Title = this.ViewModel.ActivationData.Title, MaxWidth = Window.Current.CoreWindow.Bounds.Width }; var panel = new StackPanel(); panel.Children.Add(new TextBlock { Text = this.ViewModel.ActivationData.Message, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 6, 0, 12) }); var tb = new TextBox { Text = this.ViewModel.ActivationData.Text }; panel.Children.Add(tb); var primaryText = this.ViewModel.ActivationData.Commands.FirstOrDefault() ?? "Ok"; var secondaryText = this.ViewModel.ActivationData.Commands.Skip(1).FirstOrDefault() ?? string.Empty; var returnValue = secondaryText; tb.KeyUp += (sender, args) => { if (args.Key == VirtualKey.Enter) { returnValue = primaryText; dialog.Hide(); } }; dialog.Content = panel; dialog.PrimaryButtonText = primaryText; dialog.SecondaryButtonText = secondaryText; tb.SelectionStart = tb.Text.Length; tb.Focus(FocusState.Programmatic); try { this.dialogTask = dialog.ShowAsync(); var result = await this.dialogTask; var resultValue = string.Empty; this.dialogTask = null; switch (result) { case ContentDialogResult.None: resultValue = returnValue; break; case ContentDialogResult.Primary: resultValue = primaryText; break; case ContentDialogResult.Secondary: resultValue = secondaryText; break; } await this.NavigationService.GoBackAsync(new InputDialogResult(resultValue, tb.Text)); } catch (TaskCanceledException ex) { // Happens when you call nanavigationSerivce.GoBack(...) while the dialog is still open. } }
public override void Prompt(PromptConfig config) { var stack = new StackPanel { Children = { new TextBlock { Text = config.Message } } }; var dialog = new ContentDialog { Title = config.Title, Content = stack, PrimaryButtonText = config.OkText }; if (config.InputType == InputType.Password) this.SetPasswordPrompt(dialog, stack, config); else this.SetDefaultPrompt(dialog, stack, config); if (config.IsCancellable) { dialog.SecondaryButtonText = config.CancelText; dialog.SecondaryButtonCommand = new Command(() => { config.OnResult?.Invoke(new PromptResult { Ok = false }); dialog.Hide(); }); } this.Dispatch(() => dialog.ShowAsync()); }
async void OnPageActionSheet(Page sender, ActionSheetArguments options) { List<string> buttons = options.Buttons.ToList(); var list = new Windows.UI.Xaml.Controls.ListView { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetList"], ItemsSource = buttons, IsItemClickEnabled = true }; var dialog = new ContentDialog { Template = (Windows.UI.Xaml.Controls.ControlTemplate)Windows.UI.Xaml.Application.Current.Resources["MyContentDialogControlTemplate"], Content = list, Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetStyle"] }; if (options.Title != null) dialog.Title = options.Title; list.ItemClick += (s, e) => { dialog.Hide(); options.SetResult((string)e.ClickedItem); }; TypedEventHandler<CoreWindow, CharacterReceivedEventArgs> onEscapeButtonPressed = delegate(CoreWindow window, CharacterReceivedEventArgs args) { if (args.KeyCode == 27) { dialog.Hide(); options.SetResult(ContentDialogResult.None.ToString()); } }; Window.Current.CoreWindow.CharacterReceived += onEscapeButtonPressed; _actionSheetOptions = options; if (options.Cancel != null) dialog.SecondaryButtonText = options.Cancel; if (options.Destruction != null) dialog.PrimaryButtonText = options.Destruction; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) options.SetResult(options.Cancel); else if (result == ContentDialogResult.Primary) options.SetResult(options.Destruction); Window.Current.CoreWindow.CharacterReceived -= onEscapeButtonPressed; }
/// <summary> /// Handles starting of a new game. Shows new game dialogs and creates a new game object. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void NewGameButton_Click(object sender, RoutedEventArgs e) { var content = new ContentDialog() { Title = "New Game", Content = "What kind of game would you like to play?\r\n(Sorry, you actually have no choice as we didn't get to implement networked games)", PrimaryButtonText = "Local", SecondaryButtonText = "Network", IsSecondaryButtonEnabled = false }; //Local game nested ass lambdas content.PrimaryButtonClick += async (dialog, args) => { content.Hide(); var a = new LocalGameDialog(); a.PrimaryButtonClick += async (contentDialog, eventArgs) => { var c = contentDialog as LocalGameDialog; if (c.PlayerNames.Count(p => p.Text == string.Empty) > 4) { a.Hide(); await new MessageDialog("At least 2 players must be added").ShowAsync(); NewGameButton_Click(this, null); } else { var players = new List<Player>(); foreach (var p in c.PlayerNames.Where(p => p.Text != string.Empty)) { System.Diagnostics.Debug.WriteLine("Adding player: " + p.Text); players.Add(new Player() {Name = p.Text}); } InitGame(players); } }; a.SecondaryButtonClick += (sender1, clickEventArgs) => { a.Hide(); NewGameButton_Click(this, null); }; await a.ShowAsync(); }; await content.ShowAsync(); }
public override IDisposable Prompt(PromptConfig config) { var stack = new StackPanel(); if (!String.IsNullOrWhiteSpace(config.Message)) stack.Children.Add(new TextBlock { Text = config.Message, TextWrapping = TextWrapping.WrapWholeWords }); var dialog = new ContentDialog { Title = config.Title ?? String.Empty, Content = stack, PrimaryButtonText = config.OkText }; if (config.InputType == InputType.Password) this.SetPasswordPrompt(dialog, stack, config); else this.SetDefaultPrompt(dialog, stack, config); if (config.IsCancellable) { dialog.SecondaryButtonText = config.CancelText; dialog.SecondaryButtonCommand = new Command(() => { config.OnAction?.Invoke(new PromptResult(false, String.Empty)); dialog.Hide(); }); } return this.DispatchAndDispose( () => dialog.ShowAsync(), dialog.Hide ); }