/// <summary> /// Asynchronously deletes all saved passwords before closing the dialog. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral deferral = args.GetDeferral(); await ViewModel.DeleteAllAsyncCommand.ExecuteAsync(null); deferral.Complete(); }
/// <summary> /// Delete current selected Device. /// </summary> private async void DeleteDeviceButton_ClickAsync(object sender, RoutedEventArgs e) { string deviceIdString = (string)DeviceCombobox.SelectedItem; if (!String.IsNullOrEmpty(deviceIdString)) { ContentDialog deletePromptDialog = new ContentDialog { Title = "Delete Device: " + deviceIdString, Content = "Are you sure you want to delete device: " + deviceIdString + "?", CloseButtonText = "Cancel", PrimaryButtonText = "Delete" }; deletePromptDialog.PrimaryButtonClick += async(s, args) => { ContentDialogButtonClickDeferral deferral = args.GetDeferral(); // Delete device bool ifDeleted = await DeleteDeviceAsync(deviceIdString); ListDevices(); deferral.Complete(); }; ContentDialogResult result = await deletePromptDialog.ShowAsync(); } }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { // Ensure the user name and password fields aren't empty. If a required field // is empty, set args.Cancel = true to keep the dialog open. if (string.IsNullOrEmpty(userNameTextBox.Text)) { args.Cancel = true; errorTextBlock.Text = "User name is required."; } else if (string.IsNullOrEmpty(passwordTextBox.Password)) { args.Cancel = true; errorTextBlock.Text = "Password is required."; } // If you're performing async operations in the button click handler, // get a deferral before you await the operation. Then, complete the // deferral when the async operation is complete. ContentDialogButtonClickDeferral deferral = args.GetDeferral(); //if (await SomeAsyncSignInOperation()) //{ this.Result = SignInResult.SignInOK; //} //else //{ // this.Result = SignInResult.SignInFail; //} deferral.Complete(); }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { MedicineInventory newItem = new MedicineInventory() { GenericName = tbx_gen.Text, BrandName = tbx_brd.Text, Dosage = tbx_dsg.Text, StocksLeft = int.Parse(tbx_amt.Text), TimeLastAdded = DateTime.Now }; ContentDialogButtonClickDeferral deferral = args.GetDeferral(); try { var result = await AddMedicineViaDataServiceAsync(newItem); NewMedicine = result; Result = AddMedicineResult.Success; } catch (Exception) { Result = AddMedicineResult.AddFailed; } deferral.Complete(); }
private async void QueueContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral Deferral = args.GetDeferral(); try { if (CurrentUseProgramList.SelectedItem is ProgramPickerItem CurrentItem) { SelectedProgram = CurrentItem; } else if (OtherProgramList.SelectedItem is ProgramPickerItem OtherItem) { SelectedProgram = OtherItem; if (UseAsAdmin.IsChecked.GetValueOrDefault()) { await SQLite.Current.SetDefaultProgramPickerRecordAsync(OpenFile.Type, OtherItem.Path).ConfigureAwait(true); } } else { args.Cancel = true; } } catch (Exception ex) { LogTracer.Log(ex); } finally { Deferral.Complete(); } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var addedItem = new Prescription() { Medicine = cb_medicine.SelectedItem as MedicineInventory, Amount = it_amount.Value, AddedBy = App.LoggedUser.Username, AddedOn = DateTime.Now }; addedItem.Schedule = ConvertFromDateTimeOffset(cdp_startDate.Date.Value.Add(tp_startTime.Time)); int uploadMode = pv_options.SelectedIndex; ImsDataService imsSvc = new ImsDataService(App.ApiSettings); ContentDialogButtonClickDeferral def = args.GetDeferral(); if (uploadMode == 0) { var item = await imsSvc.AddNewPrescriptionAsync(Patient.ID, addedItem); AddedItem = item; } else { var items = await imsSvc.SetRecurringPrescriptionsAsync(Patient.ID, addedItem, it_times.Value, it_days.Value); AddedItems = items; IsRecurring = true; } def.Complete(); }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (ViewModel.IsBusy) { args.Cancel = true; } else { deferral = args.GetDeferral(); ViewModel.LoginCommand.Execute(null); } }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (string.IsNullOrEmpty(labelNameTextBox.Text)) { this.Label = ""; args.Cancel = true; } else { this.Label = labelNameTextBox.Text; } ContentDialogButtonClickDeferral deferral = args.GetDeferral(); deferral.Complete(); }
private async void QueueContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral Deferral = args.GetDeferral(); try { if (CurrentUseProgramList.SelectedItem is ProgramPickerItem CurrentItem) { SelectedProgram = CurrentItem; } else if (OtherProgramList.SelectedItem is ProgramPickerItem OtherItem) { SelectedProgram = OtherItem; } else { args.Cancel = true; } if (SelectedProgram != null && UseAsAdmin.IsChecked.GetValueOrDefault() || OpenFromPropertiesWindow) { string ExecutablePath = SelectedProgram.Path; if (Path.IsPathRooted(ExecutablePath) && Path.GetExtension(ExecutablePath).Equals(".lnk", StringComparison.OrdinalIgnoreCase)) { if (await FileSystemStorageItemBase.OpenAsync(ExecutablePath) is LinkStorageFile LinkFile) { if (await LinkFile.GetRawDataAsync() is LinkDataPackage Package && !string.IsNullOrEmpty(Package.LinkTargetPath)) { ExecutablePath = Package.LinkTargetPath; } } } SQLite.Current.SetDefaultProgramPickerRecord(OpenFile.Type, ExecutablePath); } } catch (Exception ex) { LogTracer.Log(ex); } finally { Deferral.Complete(); } }
// 用户点击了第二个按钮 private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { // 通过 GetDeferral() 来等待长时任务,否则即使 await 了也不会等 ContentDialogButtonClickDeferral deferral = args.GetDeferral(); try { await Task.Delay(1); } finally { // 完成异步操作 deferral.Complete(); } // 使此事件可以冒泡(当然 args.Cancel 默认就是 false) args.Cancel = false; }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { // Ensure the user name and password fields aren't empty. If a required field // is empty, set args.Cancel = true to keep the dialog open. if (string.IsNullOrEmpty(NameTextx.Text)) { args.Cancel = true; errorTextBlock.Text = "Name is required."; } else if (string.IsNullOrEmpty(DescriptioText.Text)) { args.Cancel = true; errorTextBlock.Text = "Description is required."; } ContentDialogButtonClickDeferral deferral = args.GetDeferral(); bool isSaved = false; if (IsForProvider) { Provider provider = new Provider() { Name = NameTextx.Text, Description = DescriptioText.Text }; isSaved = await new ProviderService().SaveProviderAsync(provider); } else { Category = new Category() { Name = NameTextx.Text, Description = DescriptioText.Text }; isSaved = await new CategoryService().SaveCategoryAsync(Category); } if (isSaved) { this.Result = CreateResult.SignInOK; } else { this.Result = CreateResult.SignInFail; } deferral.Complete(); }
private async Task LoginAsync(ContentDialogButtonClickDeferral deferral = null) { ContentDialogButtonClickDeferral _deferral; pbx_pw.IsEnabled = false; tbx_username.IsEnabled = false; progress.Visibility = Visibility.Visible; IsPrimaryButtonEnabled = false; _deferral = deferral; try { Personnel authenticatedUser = await Personnel.AuthenticateAsync(App.ApiSettings, tbx_username.Text, pbx_pw.Password); AuthenticatedUser = authenticatedUser; Result = LoginDialogResult.LoginSuccess; if (_deferral != null) { _deferral.Complete(); } CanClose = true; Hide(); } catch (ApiException ex) { MessageDialog md = new MessageDialog(ex.Message); await md.ShowAsync(); if (_deferral != null) { _deferral.Complete(); } throw ex; } }
private async void QueueContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral Deferral = args.GetDeferral(); try { if ((Type == QuickStartType.Application && CommonAccessCollection.QuickStartList.Any((Item) => Item.DisplayName == DisplayName.Text)) || (Type == QuickStartType.WebSite && CommonAccessCollection.WebLinkList.Any((Item) => Item.DisplayName == DisplayName.Text))) { ExistTip.IsOpen = true; args.Cancel = true; } else if (Icon.Source == null || (Icon.Source as BitmapImage)?.UriSource?.OriginalString == "ms-appx:///Assets/AddImage.png") { EmptyTip.Target = Icon; EmptyTip.IsOpen = true; args.Cancel = true; } else if (string.IsNullOrWhiteSpace(Protocol.Text)) { EmptyTip.Target = Protocol; EmptyTip.IsOpen = true; args.Cancel = true; } else if (string.IsNullOrWhiteSpace(DisplayName.Text)) { EmptyTip.Target = DisplayName; EmptyTip.IsOpen = true; args.Cancel = true; } else { switch (Type) { case QuickStartType.Application: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out _)) { if (!FileSystemItemNameChecker.IsValid(DisplayName.Text)) { args.Cancel = true; InvalidCharTip.IsOpen = true; Deferral.Complete(); return; } if (IsUpdate) { if (ImageFile == null) { SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, null, Protocol.Text, QuickStartType.Application); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, null, DisplayName.Text); } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text); } } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); CommonAccessCollection.QuickStartList.Insert(CommonAccessCollection.QuickStartList.Count - 1, new QuickStartItem(QuickStartType.Application, Icon.Source as BitmapImage, Protocol.Text, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text)); SQLite.Current.SetQuickStartItem(DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application); } } else { using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController()) { if (await Exclusive.Controller.CheckIfPackageFamilyNameExist(Protocol.Text)) { if (IsUpdate) { if (ImageFile == null) { SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, null, Protocol.Text, QuickStartType.Application); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, null, DisplayName.Text); } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text); } } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); CommonAccessCollection.QuickStartList.Insert(CommonAccessCollection.QuickStartList.Count - 1, new QuickStartItem(QuickStartType.Application, Icon.Source as BitmapImage, Protocol.Text, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text)); SQLite.Current.SetQuickStartItem(DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application); } } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } } } break; } case QuickStartType.WebSite: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out Uri Result) && !Result.IsFile) { if (!FileSystemItemNameChecker.IsValid(DisplayName.Text)) { args.Cancel = true; InvalidCharTip.IsOpen = true; Deferral.Complete(); return; } if (IsUpdate) { if (ImageFile == null) { SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, null, Protocol.Text, QuickStartType.WebSite); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, null, DisplayName.Text); } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("HotWebImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); SQLite.Current.UpdateQuickStartItem(QuickItem.DisplayName, DisplayName.Text, $"HotWebImage\\{NewFile.Name}", Protocol.Text, QuickStartType.WebSite); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, $"HotWebImage\\{NewFile.Name}", DisplayName.Text); } } else { StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("HotWebImage", CreationCollisionOption.OpenIfExists), DisplayName.Text + Path.GetExtension(ImageFile.Path), NameCollisionOption.GenerateUniqueName); CommonAccessCollection.WebLinkList.Insert(CommonAccessCollection.WebLinkList.Count - 1, new QuickStartItem(QuickStartType.WebSite, Icon.Source as BitmapImage, Protocol.Text, $"HotWebImage\\{NewFile.Name}", DisplayName.Text)); SQLite.Current.SetQuickStartItem(DisplayName.Text, $"HotWebImage\\{NewFile.Name}", Protocol.Text, QuickStartType.WebSite); } } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } break; } } } } catch (Exception ex) { LogTracer.Log(ex); } finally { Deferral.Complete(); } }
private void OnPrimaryClick( object sender, ContentDialogButtonClickEventArgs e ) { Contract.Requires( e != null ); if ( primary == null ) return; var parameter = dialog.PrimaryButtonCommandParameter; deferral = e.GetDeferral(); if ( secondary != null ) secondary.RaiseCanExecuteChanged(); primary.RaiseCanExecuteChanged(); if ( primary.CanExecute( parameter ) ) primary.Execute( parameter ); }
/// <summary> /// Notifies the system that the app has finished processing the closing event. /// </summary> /// <param name="deferral">The requested <see cref="ContentDialogButtonClickDeferral"/>.</param> public static void CompleteWrapped(this ContentDialogButtonClickDeferral deferral) => Resolver.Complete(deferral);
/// <summary> /// Gets a ContentDialogButtonClickDeferral the app can use to respond /// asyncronously to a button click event /// </summary> public ContentDialogButtonClickDeferral GetDeferral() { _deferral = new ContentDialogButtonClickDeferral(_owner); return(_deferral); }
private async void QueueContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral Deferral = args.GetDeferral(); if ((Type == QuickStartType.Application && CommonAccessCollection.QuickStartList.Any((Item) => Item.DisplayName == DisplayName.Text)) || (Type == QuickStartType.WebSite && CommonAccessCollection.HotWebList.Any((Item) => Item.DisplayName == DisplayName.Text))) { ExistTip.IsOpen = true; args.Cancel = true; } else if (Icon.Source == null) { EmptyTip.Target = Icon; EmptyTip.IsOpen = true; args.Cancel = true; } else if (string.IsNullOrWhiteSpace(Protocol.Text)) { EmptyTip.Target = Protocol; EmptyTip.IsOpen = true; args.Cancel = true; } else if (string.IsNullOrWhiteSpace(DisplayName.Text)) { EmptyTip.Target = DisplayName; EmptyTip.IsOpen = true; args.Cancel = true; } else { switch (Type) { case QuickStartType.Application: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out Uri _)) { string ImageName = DisplayName.Text + Path.GetExtension(ImageFile.Path); StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), ImageName, NameCollisionOption.GenerateUniqueName); CommonAccessCollection.QuickStartList.Insert(CommonAccessCollection.QuickStartList.Count - 1, new QuickStartItem(Icon.Source as BitmapImage, Protocol.Text, QuickStartType.Application, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text)); await SQLite.Current.SetQuickStartItemAsync(DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application).ConfigureAwait(true); } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } break; } case QuickStartType.WebSite: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out Uri _)) { string ImageName = DisplayName.Text + Path.GetExtension(ImageFile.Path); StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("HotWebImage", CreationCollisionOption.OpenIfExists), ImageName, NameCollisionOption.GenerateUniqueName); CommonAccessCollection.HotWebList.Insert(CommonAccessCollection.HotWebList.Count - 1, new QuickStartItem(Icon.Source as BitmapImage, Protocol.Text, QuickStartType.WebSite, $"HotWebImage\\{NewFile.Name}", DisplayName.Text)); await SQLite.Current.SetQuickStartItemAsync(DisplayName.Text, $"HotWebImage\\{NewFile.Name}", Protocol.Text, QuickStartType.WebSite).ConfigureAwait(true); } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } break; } case QuickStartType.UpdateApp: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out Uri _)) { if (!FileSystemItemNameChecker.IsValid(DisplayName.Text)) { args.Cancel = true; InvalidCharTip.IsOpen = true; Deferral.Complete(); return; } if (ImageFile != null) { string ImageName = DisplayName.Text + Path.GetExtension(ImageFile.Path); StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("QuickStartImage", CreationCollisionOption.OpenIfExists), ImageName, NameCollisionOption.GenerateUniqueName); await SQLite.Current.UpdateQuickStartItemAsync(QuickItem.DisplayName, DisplayName.Text, $"QuickStartImage\\{NewFile.Name}", Protocol.Text, QuickStartType.Application).ConfigureAwait(true); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, $"QuickStartImage\\{NewFile.Name}", DisplayName.Text); } else { await SQLite.Current.UpdateQuickStartItemAsync(QuickItem.DisplayName, DisplayName.Text, null, Protocol.Text, QuickStartType.Application).ConfigureAwait(true); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, null, DisplayName.Text); } } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } break; } case QuickStartType.UpdateWeb: { if (Uri.TryCreate(Protocol.Text, UriKind.Absolute, out Uri _)) { if (!FileSystemItemNameChecker.IsValid(DisplayName.Text)) { args.Cancel = true; InvalidCharTip.IsOpen = true; Deferral.Complete(); return; } if (ImageFile != null) { string ImageName = DisplayName.Text + Path.GetExtension(ImageFile.Path); StorageFile NewFile = await ImageFile.CopyAsync(await ApplicationData.Current.LocalFolder.CreateFolderAsync("HotWebImage", CreationCollisionOption.OpenIfExists), ImageName, NameCollisionOption.GenerateUniqueName); await SQLite.Current.UpdateQuickStartItemAsync(QuickItem.DisplayName, DisplayName.Text, $"HotWebImage\\{NewFile.Name}", Protocol.Text, QuickStartType.WebSite).ConfigureAwait(true); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, $"HotWebImage\\{NewFile.Name}", DisplayName.Text); } else { await SQLite.Current.UpdateQuickStartItemAsync(QuickItem.DisplayName, DisplayName.Text, null, Protocol.Text, QuickStartType.WebSite).ConfigureAwait(true); QuickItem.Update(Icon.Source as BitmapImage, Protocol.Text, null, DisplayName.Text); } } else { FormatErrorTip.IsOpen = true; args.Cancel = true; } break; } default: { break; } } } Deferral.Complete(); }
void IContentDialogButtonClickDeferralResolver.Complete(ContentDialogButtonClickDeferral deferral) => deferral.Complete();
//Dialog login private async void PageLogin(object sender, RoutedEventArgs e) { var stackPanel = new StackPanel(); // Tạo input tài khoản var textBoxName = new TextBox { Header = "Email", Name = "Email", Margin = new Thickness(0, 5, 0, 10), }; // Tạo input pass var textBoxPass = new PasswordBox { Header = "Mật khẩu", Name = "Password", }; // tạo mới link sang page đăng ký var linkSignUp = new HyperlinkButton { Content = "Đăng ký", FontSize = 13, HorizontalAlignment = HorizontalAlignment.Left, }; // add sự kiện Click vào hyperlink linkSignUp.Click += LinkSignUp_Click; stackPanel.Children.Add(textBoxName); stackPanel.Children.Add(textBoxPass); stackPanel.Children.Add(linkSignUp); Style btnPrimaryStyle = (Style)App.Current.Resources["myButtonPrimary"]; Style btnCloseStyle = (Style)App.Current.Resources["myButtonClose"]; dialogLogin.Title = "Đăng nhập"; dialogLogin.Content = stackPanel; dialogLogin.PrimaryButtonText = "Đăng nhập"; dialogLogin.CloseButtonText = "Đóng"; dialogLogin.PrimaryButtonStyle = btnPrimaryStyle; dialogLogin.CloseButtonStyle = btnCloseStyle; dialogLogin.PrimaryButtonClick += async(s, args) => { currentLogin = new Member(); ContentDialogButtonClickDeferral deferral = args.GetDeferral(); var httpResponseMessage = APIHandle.Sign_In(textBoxName.Text, textBoxPass.Password).Result; var responseContent = await httpResponseMessage.Content.ReadAsStringAsync(); if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.Created) { // save file... Debug.WriteLine(responseContent); // Doc token TokenResponse token = JsonConvert.DeserializeObject <TokenResponse>(responseContent); // Luu token StorageFolder folder = ApplicationData.Current.LocalFolder; StorageFile file = await folder.CreateFileAsync("token.txt", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, responseContent); await DoLogin(); //Đi thẳng vào MainPage và thích móc gì thì móc var frame = Window.Current.Content as Frame; var currentPage = frame.Content as Page; var appbarlogin = currentPage.FindName("ShowLoginButton"); var appbarinfo = currentPage.FindName("ShowUserInfo"); AppBarButton app1 = appbarlogin as AppBarButton; AppBarButton app2 = appbarinfo as AppBarButton; app1.Visibility = Visibility.Collapsed; app2.Visibility = Visibility.Visible; GlobalFlySong._isLogin = true; } else { // Xu ly loi. ErrorResponse errorObject = JsonConvert.DeserializeObject <ErrorResponse>(responseContent); //if (errorObject != null && errorObject.error.Count > 0) //{ // foreach (var key in errorObject.error.Keys) // { // var textMessage = FindName(key); // if (textMessage == null) // { // continue; // } // TextBlock textBlock = textMessage as TextBlock; // textBlock.Text = errorObject.error[key]; // textBlock.Visibility = Visibility.Visible; // } //} Debug.WriteLine(errorObject); } deferral.Complete(); }; await dialogLogin.ShowAsync(); }
public void Dispose() { if ( deferral != null ) { deferral.Complete(); deferral = null; } UnwireCommands(); if ( dialog != null ) dialog.Hide(); GC.SuppressFinalize( this ); }
/// <summary> /// 移動するボタン押下処理 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { ContentDialogButtonClickDeferral deferral = args.GetDeferral(); deferral.Complete(); }