Esempio n. 1
0
        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(txtUsername.Text))
            {
                args.Cancel = true;
                txtError.Text = "User name is required";
                return;
            }
            else if (string.IsNullOrEmpty(txtPassword.Password))
            {
                args.Cancel = true;
                txtError.Text = "Password is required";
                return;
            }

            // 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();

            var rememberMe = chkRememberMe.IsChecked.Value;
            if( !await dataAccess.Login(txtUsername.Text, txtPassword.Password, rememberMe) )
            {
                args.Cancel = true;
                txtError.Text = "Login Failed";
            }

            deferral.Complete();
        }
Esempio n. 2
0
        private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            PostingProgressBar.Visibility = Visibility.Visible;
            IsSecondaryButtonEnabled      = false;

            var deferral = args.GetDeferral();

            SettingsService.Instance.Publisher = who;

            var res = await GankService.PostGank(url, desc, who, type
#if DEBUG
                                                 , debug : true
#endif
                                                 );

            PostingProgressBar.Visibility = Visibility.Collapsed;
            if (res.error)
            {
                args.Cancel  = true;
                MsgText.Text = res.msg;
            }
            else
            {
                MsgText.Text = "提交成功";
                await Task.Delay(1500);
            }
            IsSecondaryButtonEnabled = true;
            deferral.Complete();
        }
Esempio n. 3
0
        /// <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();
        }
Esempio n. 4
0
    private async void SaveAnswersButton_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args)
    {
        var deferral = args.GetDeferral();

        try
        {
            var answers = new List <AwardConsiderationAnswerModel>();

            if (answers.Count == 0)
            {
                return;
            }

            foreach (var item in Items)
            {
                answers.Add(item.AnswerItem);
            }

            await apiService.SaveAwardConsiderationAnswerAsync(answers);
        }
        finally
        {
            deferral.Complete();
        }

        this.Hide();
    }
Esempio n. 5
0
        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 ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var Deferral = args.GetDeferral();

            try
            {
                if (CurrentEncoding == null)
                {
                    args.Cancel       = true;
                    InvalidTip.IsOpen = true;
                }
                else if (await FileSystemStorageItemBase.OpenAsync(ExtractLocation) is not FileSystemStorageFolder)
                {
                    args.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex);
            }
            finally
            {
                Deferral.Complete();
            }
        }
        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 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();
            }
        }
        //Sign in button
        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();
        }
Esempio n. 10
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var _deferral = args.GetDeferral();

            if (kd_name.Text == "" || kd_num.Text == "" || kd_com.SelectedIndex == -1)
            {
                //var asd = args.GetDeferral();
                await new Windows.UI.Popups.MessageDialog("请将快递信息填写完整").ShowAsync();
                args.Cancel = true;
            }
            else
            {
                var kd = new Class.KD_Class.KD_Model(kd_name.Text, kd_num.Text, Class.KD_Class.comDir.Values.ToArray()[kd_com.SelectedIndex]);
                if (await Class.KD_Class.CanAdd(kd))
                {
                    await Class.KD_Class.Add(kd);
                }
                else
                {
                    await new Windows.UI.Popups.MessageDialog("不要重复添加该快递").ShowAsync();
                    args.Cancel = true;
                }
            }
            _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();
        }
Esempio n. 12
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (podcast.Subscribed)
            {
                if (podcast.Count < 1)
                {
                    MainPage.Current.PopMessage("No enough podcast");
                    return;
                }

                var def = args.GetDeferral();

                var i = 0;
                var s = podcast[i];
                if (s.IsVideo)
                {
                    var videoWindowID = 0;
                    await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var frame     = new Frame();
                        videoWindowID = ApplicationView.GetForCurrentView().Id;
                        frame.Navigate(typeof(VideoPodcast), s.FilePath);
                        Window.Current.Content = frame;
                        Window.Current.Activate();
                        ApplicationView.GetForCurrentView().Title = s.Title;
                        CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                        var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                        titleBar.ButtonBackgroundColor         = Colors.Transparent;
                        titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                        titleBar.ButtonHoverBackgroundColor    = Color.FromArgb(0x33, 0x00, 0x00, 0x00);
                        titleBar.ButtonForegroundColor         = Colors.Black;
                        titleBar.ButtonHoverForegroundColor    = Colors.White;
                        titleBar.ButtonInactiveForegroundColor = Colors.Gray;
                    });

                    bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(videoWindowID);

                    return;
                }
                if (podcast.Count < i + 20)
                {
                    var k = podcast.Count < 20 ? podcast.ToList() : podcast.GetRange(podcast.Count - 20, 20);
                    await MainPageViewModel.Current.InstantPlayAsync(k, k.IndexOf(s));
                }
                else
                {
                    await MainPageViewModel.Current.InstantPlayAsync(podcast.GetRange(i, 20), 0);
                }

                def.Complete();
            }
            else
            {
                podcast.Subscribed = true;
                await podcast.SaveAsync();

                MainPage.Current.PopMessage(string.Format(podcast.Subscribed ? Consts.Localizer.GetString("PodcastSubscribe") : Consts.Localizer.GetString("PodcastUnSubscribe"), podcast.Title));
            }
        }
Esempio n. 13
0
        private async void ContentDialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // resize the dialog.
            var d = args.GetDeferral();
            await Task.Delay(33);

            d.Complete();
        }
Esempio n. 14
0
        private async void ContentPopup_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();
            var confirm  = await ViewModel.SendAsync();

            args.Cancel = !confirm;
            deferral.Complete();
        }
        private async void RequestReviewOk_Click(ContentDialog dialog, ContentDialogButtonClickEventArgs args)
        {
            //this.Hide();
            var deferral = args.GetDeferral();
            await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=" + Windows.ApplicationModel.Package.Current.Id.Name));

            deferral.Complete();
        }
Esempio n. 16
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            args.Cancel = await ValidateForm();

            deferral.Complete();
        }
Esempio n. 17
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            args.Cancel = !await UserViewModel.RegisterAsync();

            deferral.Complete();
        }
Esempio n. 18
0
        private async void QueueContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var Deferral = args.GetDeferral();

            try
            {
                if (BluetoothControl.SelectedIndex == -1 || !BluetoothDeviceCollection[BluetoothControl.SelectedIndex].DeviceInfo.Pairing.IsPaired)
                {
                    Tips.Text       = Globalization.GetString("BluetoothUI_Tips_Text_1");
                    Tips.Visibility = Visibility.Visible;
                    args.Cancel     = true;
                }
                else
                {
                    //首先连接到RFComm服务,获取到设备的规范名称
                    string CanonicalName = await ConnectToRfcommServiceAsync(BluetoothDeviceCollection[BluetoothControl.SelectedIndex]).ConfigureAwait(true);

                    BluetoothService BTService = BluetoothService.GetDefault();
                    BTService.SearchForPairedDevicesSucceeded += BTService_SearchForPairedDevicesSucceeded;

                    void BTService_SearchForPairedDevicesSucceeded(object sender, SearchForPairedDevicesSucceededEventArgs e)
                    {
                        BTService.SearchForPairedDevicesSucceeded -= BTService_SearchForPairedDevicesSucceeded;

                        if (e.PairedDevices.FirstOrDefault((Device) => Device.DeviceHost.CanonicalName == CanonicalName) is BluetoothDevice BTDevice)
                        {
                            ObexServiceProvider.SetObexInstance(BTDevice, BluetoothDeviceCollection[BluetoothControl.SelectedIndex].Name);

                            if (ObexServiceProvider.GetObexInstance() == null)
                            {
                                throw new Exception(Globalization.GetString("BluetoothUI_Tips_Text_2"));
                            }
                        }
                        else
                        {
                            throw new Exception(Globalization.GetString("BluetoothUI_Tips_Text_2"));
                        }
                    }

                    //能到这里说明该设备已经配对,启动搜索,完成后PairedBluetoothDeviceCollection被填充
                    await BTService.SearchForPairedDevicesAsync().ConfigureAwait(true);
                }
            }
            catch (Exception e)
            {
                args.Cancel = true;

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    Tips.Text       = e.Message;
                    Tips.Visibility = Visibility.Visible;
                });
            }
            finally
            {
                Deferral.Complete();
            }
        }
        private async void DatabaseConnectionDialog_ConnectClickAsync(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            PageBusy("Connecting to CASAS Database...");
            args.Cancel = !(await ConnectToDatabase());
            PageReady();
            deferral.Complete();
        }
Esempio n. 20
0
        //Actually there are two ways of doing stuff, content dialog can do the logic itself,
        //bc we have singletone provider, right? Or we can just pass the parameters to the InputWindow, hmm,
        //If we go with pass on tactics, then the separation will not be that clear, we will not be able to do clear DI, bc
        //The page would be responsible for too much things. Yep I think we just go an create the view model for this thing?
        //Seems ok. Well, do the ViewModel, but not ssure how the navigate to will be invoked

        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var what = args.GetDeferral();
            //Do the checkings
            //if (ItemsRequiredTextBox)
            //Make use of it, for long things
            //But at first we need to da it at least somehow.
            //When done, first thing is to separate ViewModel, and start doing the Search thing
        }
Esempio n. 21
0
        private async void OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral  = args.GetDeferral();
            var validated = await ViewModel.ValidateAsync();

            ValidatedInfo = validated;

            args.Cancel = validated == null;
            deferral.Complete();
        }
        private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var Deferral = args.GetDeferral();

            if (SecondaryButtonText == "中止")
            {
                args.Cancel   = true;
                AbortFromHere = true;

                try
                {
                    await ObexClient.AbortAsync();
                }
                catch (Exception) { }
            }
            else if (SecondaryButtonText == "重试")
            {
                args.Cancel       = true;
                ProgressText.Text = "0%";

                ObexClient.DataTransferFailed     -= ObexClient_DataTransferFailed;
                ObexClient.DataTransferProgressed -= ObexClient_DataTransferProgressed;
                ObexClient.DataTransferSucceeded  -= ObexClient_DataTransferSucceeded;
                ObexClient.ConnectionFailed       -= ObexClient_ConnectionFailed;
                ObexClient.Aborted         -= ObexClient_Aborted;
                ObexClient.Disconnected    -= ObexClient_Disconnected;
                ObexClient.DeviceConnected -= ObexClient_DeviceConnected;

                ObexClient = ObexServiceProvider.GetObexNewInstance();

                ObexClient.DataTransferFailed     += ObexClient_DataTransferFailed;
                ObexClient.DataTransferProgressed += ObexClient_DataTransferProgressed;
                ObexClient.DataTransferSucceeded  += ObexClient_DataTransferSucceeded;
                ObexClient.ConnectionFailed       += ObexClient_ConnectionFailed;
                ObexClient.Aborted         += ObexClient_Aborted;
                ObexClient.Disconnected    += ObexClient_Disconnected;
                ObexClient.DeviceConnected += ObexClient_DeviceConnected;

                try
                {
                    ProgressControl.Value = 0;
                    CloseButtonText       = "";
                    SecondaryButtonText   = "中止";
                    await ObexClient.ConnectAsync();

                    await ObexClient.SendFileAsync(ToDeleteFile);
                }
                catch (Exception)
                {
                    ProgressText.Text = "尝试重新连接失败";
                }
            }

            Deferral.Complete();
        }
Esempio n. 23
0
 private async void OnLoginButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     try
     {
         await LoginAsync(args.GetDeferral());
     }
     catch (Exception)
     {
         ResetForm();
     }
 }
Esempio n. 24
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            // If the user entered a passphrase, return it and hide the dialog
            if (!await ValidateInput())
            {
                args.Cancel = true;
            }

            deferral.Complete();
        }
        /// <summary>
        /// The correct way of using an async handler here: a deferral.
        /// </summary>
        /// <remarks>
        /// Because the handler needs a void return type, we need another way to signal completion.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void ContentDialog_ButtonClick_Correct(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var defer = args.GetDeferral();

            this.Result = "Still Getting";
            var res = await GetSomethingAsync();

            this.Result = res;

            // finally mark the action as Complete
            defer.Complete();
        }
Esempio n. 26
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            ProcessingBarrier.Visibility = Visibility.Visible;
            LoginProgressRing.IsActive   = true;

            var defer = args.GetDeferral();

            bool isTwoFactorLogin = false;

            try
            {
                var hohoemaApp = HohoemaCommnadHelper.GetHohoemaApp();

                var mail     = Mail.Text;
                var password = Password.Password;
                var result   = await hohoemaApp.SignIn(mail, password, twoFactorAuth : async() =>
                {
                    isTwoFactorLogin = true;

                    defer.Complete();

                    await Task.Delay(200);
                });

                if (IsRememberPassword.IsOn)
                {
                    await AccountManager.AddOrUpdateAccount(mail, password);

                    AccountManager.SetPrimaryAccountId(mail);
                }
                else
                {
                    AccountManager.SetPrimaryAccountId("");
                    AccountManager.RemoveAccount(mail);
                }

                if (!isTwoFactorLogin &&
                    (result == Mntone.Nico2.NiconicoSignInStatus.Failed || result == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable))
                {
                    args.Cancel = true;
                }
            }
            finally
            {
                if (!isTwoFactorLogin)
                {
                    defer.Complete();
                }

                ProcessingBarrier.Visibility = Visibility.Collapsed;
                LoginProgressRing.IsActive   = false;
            }
        }
Esempio n. 27
0
 private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     if (ViewModel.IsBusy)
     {
         args.Cancel = true;
     }
     else
     {
         deferral = args.GetDeferral();
         ViewModel.LoginCommand.Execute(null);
     }
 }
Esempio n. 28
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var def = args.GetDeferral();

            if (await Login(Account.Text, Password.Password))
            {
            }
            else
            {
                args.Cancel = true;
            }
            def.Complete();
        }
Esempio n. 29
0
        private async void LogInDialog_PrimaryButtonClick(ContentDialog dialog, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            dialog.IsEnabled = dialog.IsPrimaryButtonEnabled = dialog.IsSecondaryButtonEnabled = false;

            await ViewModel.LogInAsync(_logInDialog.Username, _logInDialog.Password);

            _logInDialog.Password = String.Empty;             // clear the password field in case of a failed login

            dialog.IsEnabled = dialog.IsPrimaryButtonEnabled = dialog.IsSecondaryButtonEnabled = true;
            deferral.Complete();
        }
Esempio n. 30
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var Deferral = args.GetDeferral();

            if (BluetoothControl.SelectedIndex == -1 || !BluetoothDeviceCollection[BluetoothControl.SelectedIndex].DeviceInfo.Pairing.IsPaired)
            {
                Tips.Text       = "请先选择一个已配对的设备";
                Tips.Visibility = Visibility.Visible;
                args.Cancel     = true;
                Deferral.Complete();
                return;
            }


            try
            {
                //首先连接到RFComm服务,获取到设备的规范名称
                string CanonicalName = await ConnectToRfcommServiceAsync(BluetoothDeviceCollection[BluetoothControl.SelectedIndex]);

                BluetoothService BTService = BluetoothService.GetDefault();
                BTService.SearchForPairedDevicesSucceeded += (s, e) =>
                {
                    PairedBluetoothDeviceCollection = e.PairedDevices;
                };

                //能到这里说明该设备已经配对,启动搜索,完成后PairedBluetoothDeviceCollection被填充
                await BTService.SearchForPairedDevicesAsync();

                foreach (var BTDevice in from BTDevice in PairedBluetoothDeviceCollection
                         //找到符合刚刚RFComm服务获取到的规范名称的蓝牙设备
                         where BTDevice.DeviceHost.CanonicalName == CanonicalName
                         select BTDevice)
                {
                    //从该设备的BluetoothDevice对象获取到Obex服务的实例
                    ObexServiceProvider.SetObexInstance(BTDevice);
                    break;
                }

                if (ObexServiceProvider.GetObexNewInstance() == null)
                {
                    throw new Exception("未能找到已配对的设备,请打开该设备的蓝牙开关");
                }
            }
            catch (Exception e)
            {
                Tips.Text       = e.Message;
                Tips.Visibility = Visibility.Visible;
            }

            Deferral.Complete();
        }
        private async void OkButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // Get the deferral because we need to await the
            // category creation.
            var deferral = args.GetDeferral();

            // Get creation status and if failed, let's
            // keep the dialog opened.
            var success = await ViewModel.CreateCategory();
            args.Cancel = !success;

            // Complete deferral to close the dialog.
            deferral.Complete();
        }
Esempio n. 32
0
        private async void MyContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var d = args.GetDeferral();

            try
            {
                args.Cancel = true;
                await Launcher.LaunchUriAsync(new Uri(this.release.html_url));
            }
            finally
            {
                d.Complete();
            }
        }
		private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
		{
			var deferral = args.GetDeferral();
			var command = TemperatureEditViewModel.SaveTemperatureSettingCommand;
			if (command.CanExecute(null))
			{
				await command.ExecuteAsync(null);
			}
			if (TemperatureEditViewModel.HasErrors)
			{
				args.Cancel = true;
			}
			deferral.Complete();
		}
Esempio n. 34
0
        private async void OkButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // Get the deferral because we need to await the
            // category creation.
            var deferral = args.GetDeferral();

            // Get creation status and if failed, let's
            // keep the dialog opened.
            var success = await ViewModel.CreateCategory();

            args.Cancel = !success;

            // Complete deferral to close the dialog.
            deferral.Complete();
        }
        private async void GiveGoldDialog_OnPrimaryButtonClick(ContentDialog sender,
            ContentDialogButtonClickEventArgs args)
        {
            // Get the deferral because we need to await the
            // annotation to post.
            var deferral = args.GetDeferral();

            // Get creation status and if failed, let's
            // keep the dialog opened.
            var success = await ViewModel.PostAnnotationToService();
            args.Cancel = !success;

            // Complete deferral to close the dialog.
            deferral.Complete();
        }
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();

            try
            {
                if (ViewModel.SaveCommand.CanExecute(null))
                    await ViewModel.SaveCommand.Execute();
                else
                    args.Cancel = true;
            }
            finally
            {
                deferral.Complete();
            }
        }
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var deferral = args.GetDeferral();
             args.Cancel = false;
             NewEntry = new PasswordEntry
             {
            Id = -1,
            Domain = Domain.Text,
            Username = Username.Text,
            PasswordLength = SettingsProvider.DefaultPasswordLength,
            UseCapitalLetters = SettingsProvider.IncludeCapitalsByDefault,
            UseDigits = SettingsProvider.IncludeDigitsByDefault,
            UseSpecialCharacters = SettingsProvider.IncludeSpecialsByDefault,
             };
             PasswordStorage.Entries.Add(NewEntry);

             deferral.Complete();
        }
        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.";
                return;
            }
            else if (string.IsNullOrEmpty(PasswordTextBox.Password))
            {
                args.Cancel = true;
                ErrorTextBlock.Text = "Password is required.";
                return;
            }

            // 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.

            var deferral = args.GetDeferral();

            var mobileCredentials = new MobileCredentials(UserNameTextBox.Text, PasswordTextBox.Password);
            var resultTask = Task.Run(async () => await PorabaViewModel.TryLogin(mobileCredentials));
            var result = resultTask.Result;

            if (result == LoginResult.Success)
            {
                this.Result = LoginResult.Success;
                Credentials.SaveCredentialToLocker(mobileCredentials);
            }
            else
            {
                Result = result;
                args.Cancel = true;
            }
            deferral.Complete();
        }
Esempio n. 39
0
            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 );
            }