Exemplo n.º 1
0
        public async void Handle(UpdateTermsOfService update)
        {
            var terms = update.TermsOfService;

            if (terms == null)
            {
                return;
            }

            async void DeleteAccount()
            {
                var decline = await TLMessageDialog.ShowAsync(Strings.Resources.TosUpdateDecline, Strings.Resources.TermsOfService, Strings.Resources.DeclineDeactivate, Strings.Resources.Back);

                if (decline != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                var delete = await TLMessageDialog.ShowAsync(Strings.Resources.TosDeclineDeleteAccount, Strings.Resources.AppName, Strings.Resources.Deactivate, Strings.Resources.Cancel);

                if (delete != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                _protoService.Send(new DeleteAccount("Decline ToS update"));
            }

            if (terms.ShowPopup)
            {
                await Task.Delay(2000);

                await WindowWrapper.Default().Dispatcher.Dispatch(async() =>
                {
                    var confirm = await TLMessageDialog.ShowAsync(terms.Text, Strings.Resources.PrivacyPolicyAndTerms, Strings.Resources.Agree, Strings.Resources.Cancel);
                    if (confirm != ContentDialogResult.Primary)
                    {
                        DeleteAccount();
                        return;
                    }

                    if (terms.MinUserAge > 0)
                    {
                        var age = await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.TosAgeText, terms.MinUserAge), Strings.Resources.TosAgeTitle, Strings.Resources.Agree, Strings.Resources.Cancel);
                        if (age != ContentDialogResult.Primary)
                        {
                            DeleteAccount();
                            return;
                        }
                    }

                    _protoService.Send(new AcceptTermsOfService(update.TermsOfServiceId));
                });
            }
        }
        private async void CloseAndWait()
        {
            SendMessage("Start closing");
            var task = Task.Delay(10000);
            await
            ApplicationViewSwitcher.SwitchAsync(WindowWrapper.Default().ApplicationView().Id, view.Id,
                                                ApplicationViewSwitchingOptions.ConsolidateViews);

            SendMessage("Hid view");
            SendMessage("Waiting for task to end...");
            await task;

            SendMessage("Async task ended");
        }
Exemplo n.º 3
0
        public void Handle(UpdateServiceNotification update)
        {
            var caption = update.Content.GetCaption();

            if (caption == null)
            {
                return;
            }

            var text = caption.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            WindowWrapper.Default().Dispatcher.Dispatch(async() =>
            {
                await TLMessageDialog.ShowAsync(text, Strings.Resources.AppName, Strings.Resources.OK);
            });
        }