コード例 #1
0
        public void Edit(TLSecureValue value)
        {
            if (value == null)
            {
                return;
            }

            if (PhoneNumberViewModel.IsValidType(value.Type))
            {
                ShellViewModel.ShowCustomMessageBox(AppResources.PassportDeletePhoneNumberAlert, AppResources.AppName,
                                                    AppResources.Done.ToLowerInvariant(), AppResources.Cancel.ToLowerInvariant(),
                                                    dismissed =>
                {
                    if (dismissed == CustomMessageBoxResult.RightButton)
                    {
                        IsWorking = true;
                        MTProtoService.DeleteSecureValueAsync(new TLVector <TLSecureValueTypeBase> {
                            new TLSecureValueTypePhone()
                        },
                                                              result => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;

                            for (var i = 0; i < Items.Count; i++)
                            {
                                if (PhoneNumberViewModel.IsValidType(Items[i].Type))
                                {
                                    Items.RemoveAt(i--);
                                }
                            }
                        }),
                                                              error => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;
                        }));
                    }
                });
            }
            else if (EmailViewModel.IsValidType(value.Type))
            {
                ShellViewModel.ShowCustomMessageBox(AppResources.PassportDeleteEmailAlert, AppResources.AppName,
                                                    AppResources.Done.ToLowerInvariant(), AppResources.Cancel.ToLowerInvariant(),
                                                    dismissed =>
                {
                    if (dismissed == CustomMessageBoxResult.RightButton)
                    {
                        IsWorking = true;
                        MTProtoService.DeleteSecureValueAsync(new TLVector <TLSecureValueTypeBase> {
                            new TLSecureValueTypeEmail()
                        },
                                                              result => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;

                            for (var i = 0; i < Items.Count; i++)
                            {
                                if (EmailViewModel.IsValidType(Items[i].Type))
                                {
                                    Items.RemoveAt(i--);
                                }
                            }
                        }),
                                                              error => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;
                        }));
                    }
                });
            }
            else if (ResidentialAddressViewModel.IsValidType(value.Type))
            {
                StateService.SecureValue = value;
                StateService.Password    = _passwordBase;
                NavigationService.UriFor <ResidentialAddressViewModel>().Navigate();
            }
            else if (PersonalDetailsViewModel.IsValidType(value.Type))
            {
                StateService.SecureValue = value;
                StateService.Password    = _passwordBase;
                NavigationService.UriFor <PersonalDetailsViewModel>().Navigate();
            }
        }
コード例 #2
0
        public void AddDocument()
        {
            var items = new List <TLSecureValueTypeBase>
            {
                new TLSecureValueTypePhone(),
                new TLSecureValueTypeEmail(),
                new TLSecureValueTypePersonalDetails(),
                new TLSecureValueTypePassport(),
                new TLSecureValueTypeDriverLicense(),
                new TLSecureValueTypeIdentityCard(),
                new TLSecureValueTypeInternalPassport(),
                new TLSecureValueTypeAddress(),
                new TLSecureValueTypePassportRegistration(),
                new TLSecureValueTypeUtilityBill(),
                new TLSecureValueTypeBankStatement(),
                new TLSecureValueTypeRentalAgreement(),
                new TLSecureValueTypeTemporaryRegistration(),
            };

            var dict = new Dictionary <Type, Type>();

            foreach (var item in Items)
            {
                dict[item.Type.GetType()] = item.Type.GetType();
            }

            var panel = new StackPanel {
                Margin = new Thickness(0.0, 12.0, 0.0, 0.0)
            };
            var messageBox = ShellViewModel.ShowCustomMessageBox(
                null, AppResources.PassportNoDocumentsAdd,
                null, null,
                dismissed =>
            {
            },
                items.Count > 10 ?
                (object)new ScrollViewer {
                MaxHeight = 650.0, Content = panel, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
            } :
                panel);

            for (var i = 0; i < items.Count; i++)
            {
                if (!dict.ContainsKey(items[i].GetType()))
                {
                    var listBoxItem = new ListBoxItem
                    {
                        Content =
                            new TextBlock
                        {
                            Text     = SecureRequiredTypeToCaptionConverter.Convert(items[i]),
                            FontSize = 27,
                            Margin   = new Thickness(12.0)
                        },
                        DataContext = items[i]
                    };
                    TiltEffect.SetIsTiltEnabled(listBoxItem, true);
                    listBoxItem.Tap += (sender, args) =>
                    {
                        messageBox.Dismiss();
                        var item = sender as ListBoxItem;
                        if (item != null)
                        {
                            var secureValueType = item.DataContext as TLSecureValueTypeBase;
                            if (secureValueType != null)
                            {
                                if (PhoneNumberViewModel.IsValidType(secureValueType))
                                {
                                    StateService.SecureType = secureValueType;
                                    StateService.Password   = _passwordBase;
                                    NavigationService.UriFor <PhoneNumberViewModel>().Navigate();
                                }
                                else if (EmailViewModel.IsValidType(secureValueType))
                                {
                                    StateService.SecureType = secureValueType;
                                    StateService.Password   = _passwordBase;
                                    NavigationService.UriFor <EmailViewModel>().Navigate();
                                }
                                else if (ResidentialAddressViewModel.IsValidType(secureValueType))
                                {
                                    StateService.SecureType = secureValueType;
                                    StateService.Password   = _passwordBase;
                                    NavigationService.UriFor <ResidentialAddressViewModel>().Navigate();
                                }
                                else if (PersonalDetailsViewModel.IsValidType(secureValueType))
                                {
                                    StateService.SecureType = secureValueType;
                                    StateService.Password   = _passwordBase;
                                    NavigationService.UriFor <PersonalDetailsViewModel>().Navigate();
                                }
                            }
                        }
                    };

                    panel.Children.Add(listBoxItem);
                }
            }
        }