Exemple #1
0
        public AllowUsersViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            if (StateService.UsersRule is TLPrivacyValueAllowUsers)
            {
                Title = AppResources.AlwaysShare.ToLowerInvariant();
            }
            else
            {
                Title = AppResources.NeverShare.ToLowerInvariant();
            }

            BeginOnThreadPool(() =>
            {
                _usersRule             = StateService.UsersRule;
                StateService.UsersRule = null;

                if (_usersRule != null)
                {
                    foreach (var userId in _usersRule.Users)
                    {
                        var user = CacheService.GetUser(userId);
                        if (user != null)
                        {
                            Items.Add(user);
                        }
                    }

                    Status = Items.Count > 0 || LazyItems.Count > 0 ? string.Empty : string.Format("{0}", AppResources.NoUsersHere);
                }
            });
        }
Exemple #2
0
        public ContactsSecurityViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _suggestFrequentContacts = StateService.GetTopPeers() is TLTopPeers;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => SuggestFrequentContacts))
                {
                    if (!SuggestFrequentContacts)
                    {
                        ShellViewModel.ShowCustomMessageBox(
                            AppResources.SuggestFrequentContactsNotification,
                            AppResources.AppName,
                            AppResources.Ok, null,
                            dismissed =>
                        {
                        });
                    }

                    MTProtoService.ToggleTopPeersAsync(
                        new TLBool(SuggestFrequentContacts),
                        result => Execute.BeginOnUIThread(() =>
                    {
                        if (!SuggestFrequentContacts)
                        {
                            StateService.SaveTopPeers(new TLTopPeersDisabled());
                            EventAggregator.Publish(new ClearTopPeersEventArgs());
                        }
                    }));
                }
            };
        }
Exemple #3
0
 public CallsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     DisplayName = LowercaseConverter.Convert(AppResources.Calls);
     Status      = AppResources.Loading;
     FirstRun    = true;
 }
        public CardInfoViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _checkPasswordSettingsTimer.Tick    += OnCheckPasswordSettings;
            _checkPasswordSettingsTimer.Interval = TimeSpan.FromSeconds(5.0);

            EventAggregator.Subscribe(this);

            if (PaymentInfo != null && PaymentInfo.Form != null && PaymentInfo.Form.IsNativeProvider)
            {
                try
                {
                    var jsonObject = JsonObject.Parse(PaymentInfo.Form.NativeParams.Data.ToString());

                    NeedCountry        = jsonObject.GetNamedBoolean("need_country", false);
                    NeedZip            = jsonObject.GetNamedBoolean("need_zip", false);
                    NeedCardholderName = jsonObject.GetNamedBoolean("need_cardholder_name", false);

                    _publishableKey = jsonObject.GetNamedString("publishable_key", string.Empty);
                }
                catch (Exception ex)
                {
                    Telegram.Logs.Log.Write(string.Format("Can't read Form.NativeParams ex={0}\nparams={1}", ex, PaymentInfo.Form.NativeParams.Data));
                }

                SavePaymentInformation           = PaymentInfo.Form.CanSaveCredentials;
                SavePaymentInformationVisibility = PaymentInfo.Form.PasswordMissing ||
                                                   PaymentInfo.Form.CanSaveCredentials ? Visibility.Visible : Visibility.Collapsed;
            }

            _removeCheckoutView = StateService.RemoveCheckoutAndCardView;
            StateService.RemoveCheckoutAndCardView = false;
        }
        public AddChatParticipantViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            if (StateService.CurrentRole != null)
            {
                _currentRole             = StateService.CurrentRole;
                StateService.CurrentRole = null;
            }

            if (StateService.CurrentChat != null)
            {
                _currentChat             = StateService.CurrentChat;
                StateService.CurrentChat = null;
            }

            if (StateService.RemovedUsers != null)
            {
                foreach (var user in StateService.RemovedUsers)
                {
                    _removedUsers[user.Index] = user;
                }
                StateService.RemovedUsers = null;
            }

            if (StateService.RequestForwardingCount)
            {
                _requestForwardingCount             = true;
                StateService.RequestForwardingCount = false;
            }

            _inviteVisibility            = StateService.IsInviteVisible ? Visibility.Visible : Visibility.Collapsed;
            StateService.IsInviteVisible = false;

            BeginOnThreadPool(() =>
            {
                var isAuthorized = SettingsHelper.GetValue <bool>(Constants.IsAuthorizedKey);
                if (isAuthorized)
                {
                    var contacts = CacheService.GetContacts();
                    Status       = string.Empty;
                    Items.Clear();
                    foreach (var contact in contacts.OrderBy(x => x.FullName))
                    {
                        if (!(contact is TLUserEmpty) && contact.Index != StateService.CurrentUserId && !_removedUsers.ContainsKey(contact.Index))
                        {
                            Items.Add(contact);
                        }
                    }
                }

                BeginOnUIThread(() =>
                {
                    if (StateService.RemoveBackEntry)
                    {
                        NavigationService.RemoveBackEntry();
                        StateService.RemoveBackEntry = false;
                    }
                });
            });
        }
Exemple #6
0
        public SearchSharedContactsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Items  = new ObservableCollection <TLUserBase>();
            Status = AppResources.NoResults;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Text))
                {
                    if (string.IsNullOrEmpty(Text))
                    {
                        Search();
                    }
                    else
                    {
                        var text = Text;
                        BeginOnUIThread(TimeSpan.FromSeconds(0.2), () =>
                        {
                            if (!string.Equals(Text, text))
                            {
                                return;
                            }

                            Search();
                        });
                    }
                }
            };
        }
Exemple #7
0
        public EditUsernameViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            var currentUser = CacheService.GetUser(new TLInt(StateService.CurrentUserId)) as IUserName;

            if (currentUser != null &&
                currentUser.UserName != null)
            {
                _username = currentUser.UserName.ToString();
            }

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Username))
                {
                    var userName = Username;
                    BeginOnUIThread(TimeSpan.FromSeconds(0.3), () =>
                    {
                        if (string.Equals(userName, Username))
                        {
                            Check();
                        }
                    });
                }
            };
        }
Exemple #8
0
        public CacheViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            Spans = new List <TimerSpan>
            {
                new TimerSpan(AppResources.WeekNominativeSingular, "1", (int)TimeSpan.FromDays(7.0).TotalSeconds, string.Format("{0} {1}", "1", AppResources.WeekNominativeSingular).ToLowerInvariant()),
                new TimerSpan(AppResources.MonthNominativeSingular, "1", (int)TimeSpan.FromDays(30.0).TotalSeconds, string.Format("{0} {1}", "1", AppResources.MonthNominativeSingular).ToLowerInvariant()),
                new TimerSpan(AppResources.Forever, string.Empty, int.MaxValue, AppResources.Forever),
            };
            _selectedSpan = Spans[2];


            Files = new ObservableCollection <TelegramFileInfo>();

            _timer.Interval = TimeSpan.FromSeconds(30.0);
            _timer.Tick    += OnTimerTick;

            CalculateCacheSizeAsync((size1, size2) => BeginOnUIThread(() =>
            {
                Status = FileSizeConverter.Convert(size1);
                LocalDatabaseStatus = FileSizeConverter.Convert(size2);
                _settings.NotifyOfPropertyChange(() => _settings.Self);
            }));

            PropertyChanged += (sender, e) =>
            {
                if (Property.NameEquals(e.PropertyName, () => IsWorking))
                {
                    NotifyOfPropertyChange(() => CanClearCache);
                }
            };
        }
 public DebugViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     App.Log("DebugViewModel sstart .ctor");
     DisplayName = "debug";
     App.Log("DebugViewModel end .ctor");
 }
        //public ObservableCollection<TLUserBase> Items { get; set; }

        public EditChatViewModel(IUploadFileManager uploadManager, ICacheService cacheService,
                                 ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService,
                                 IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            _uploadManager = uploadManager;

            CurrentItem = StateService.CurrentChat;
            StateService.CurrentChat = null;
            var chat = CurrentItem as TLChat;

            if (chat != null)
            {
                Title = chat.Title.ToString();
            }
            var broadcastChat = CurrentItem as TLBroadcastChat;

            if (broadcastChat != null)
            {
                Title = broadcastChat.Title.ToString();
            }
            var channel = CurrentItem as TLChannel;

            if (channel != null)
            {
                Title = channel.Title.ToString();
                About = channel.About != null?channel.About.ToString() : string.Empty;
            }

            //Items = new ObservableCollection<TLUserBase>();
        }
Exemple #11
0
        public ChooseParticipantsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Items  = new ObservableCollection <TLUserBase>();
            Status = AppResources.Loading;
            BeginOnThreadPool(() =>
            {
                _source = _source ??
                          CacheService.GetContacts()
                          .Where(x => !(x is TLUserEmpty) && x.Index != StateService.CurrentUserId)
                          .OrderBy(x => x.FullName)
                          .ToList();

                Status = string.Empty;
                foreach (var contact in _source)
                {
                    LazyItems.Add(contact);
                }

                if (Items.Count == 0 && LazyItems.Count == 0)
                {
                    Status = AppResources.NoUsersHere;
                }

                BeginOnUIThread(() => PopulateItems(() => { _isFullResults = true; }));
            });
        }
Exemple #12
0
        public PasswordViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _checkPasswordSettingsTimer.Tick    += OnCheckPasswordSettings;
            _checkPasswordSettingsTimer.Interval = TimeSpan.FromSeconds(5.0);

            _password             = StateService.Password;
            StateService.Password = null;
            if (_password != null)
            {
                PasswordEnabled = _password.IsAvailable;
                RecoveryEmailUnconfirmedVisibility = !TLString.IsNullOrEmpty(_password.EmailUnconfirmedPattern) || (_password is TLPassword && ((TLPassword)_password).HasRecovery.Value)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            }

            PropertyChanged += (o, e) =>
            {
                if (Property.NameEquals(e.PropertyName, () => PasswordEnabled) && !_suppressPasswordEnabled)
                {
                    if (PasswordEnabled)
                    {
                        ChangePassword();
                    }
                    else
                    {
                        ClearPassword();
                    }
                }
            };
        }
        public PhoneNumberViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _passwordBase         = stateService.Password;
            stateService.Password = null;

            _authorizationForm             = stateService.AuthorizationForm;
            stateService.AuthorizationForm = null;

            _secureValues             = stateService.SecureValues;
            stateService.SecureValues = null;

            _secureType             = stateService.SecureType;
            stateService.SecureType = null;

            _secureRequiredType             = stateService.SecureRequiredType;
            stateService.SecureRequiredType = null;

            var user = CacheService.GetUser(new TLInt(StateService.CurrentUserId));

            if (user != null && user.HasPhone)
            {
                CurrentPhone = user.Phone.ToString();
            }

            _phoneNumberValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null;
        }
        public InviteLinkViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            if (StateService.CurrentChat != null)
            {
                _chat = StateService.CurrentChat;
                StateService.CurrentChat = null;
            }

            if (_chat == null)
            {
                return;
            }

            var chatInviteExported = _chat.ExportedInvite as TLChatInviteExported;

            if (chatInviteExported != null)
            {
                _link = chatInviteExported.Link.ToString();
            }
            else
            {
                ExportChatInviteAsync();
            }
        }
        public CheckoutViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Prices = new List <TLLabeledPrice>();

            if (PaymentInfo != null)
            {
                if (PaymentInfo.Form != null)
                {
                    Invoice   = PaymentInfo.Form.Invoice;
                    SavedInfo = PaymentInfo.Form.SavedInfo;
                    foreach (var price in PaymentInfo.Form.Invoice.Prices)
                    {
                        price.Currency = PaymentInfo.Form.Invoice.Currency;
                        Prices.Add(price);
                    }

                    if (PaymentInfo.ValidatedInfo != null &&
                        PaymentInfo.ValidatedInfo.ShippingOptions != null)
                    {
                        foreach (var shippingOption in PaymentInfo.ValidatedInfo.ShippingOptions)
                        {
                            if (shippingOption.IsSelected)
                            {
                                ShippingOption = shippingOption;
                                foreach (var price in shippingOption.Prices)
                                {
                                    price.Currency = PaymentInfo.Form.Invoice.Currency;
                                    Prices.Add(price);
                                }
                                break;
                            }
                        }
                    }
                }
                else if (PaymentInfo.Receipt != null)
                {
                    Invoice   = PaymentInfo.Receipt.Invoice;
                    SavedInfo = PaymentInfo.Receipt.SavedInfo;
                    PaymentInfo.CredentialsTitle = PaymentInfo.Receipt.CredentialsTitle.ToString();

                    foreach (var price in PaymentInfo.Receipt.Invoice.Prices)
                    {
                        price.Currency = PaymentInfo.Receipt.Invoice.Currency;
                        Prices.Add(price);
                    }

                    var shippingOption = PaymentInfo.Receipt.Shipping;
                    if (shippingOption != null)
                    {
                        ShippingOption = shippingOption;
                        foreach (var price in shippingOption.Prices)
                        {
                            price.Currency = PaymentInfo.Receipt.Invoice.Currency;
                            Prices.Add(price);
                        }
                    }
                }
            }
        }
Exemple #16
0
        public EmailCodeViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _passwordBase         = stateService.Password;
            stateService.Password = null;

            _authorizationForm             = stateService.AuthorizationForm;
            stateService.AuthorizationForm = null;

            _secureValues             = stateService.SecureValues;
            stateService.SecureValues = null;

            _secureType             = stateService.SecureType;
            stateService.SecureType = null;

            _secureRequiredType             = stateService.SecureRequiredType;
            stateService.SecureRequiredType = null;

            CurrentEmail = stateService.CurrentEmail;
            stateService.CurrentEmail = null;

            _emailValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null;

            _sentCode = stateService.SentEmailCode;
            stateService.SentEmailCode = null;

            Subtitle = GetSubtitle();

            var length = _sentCode as ILength;

            CodeLength = length != null ? length.Length.Value : Constants.DefaultCodeLength;
        }
Exemple #17
0
        public EmailViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _passwordBase         = stateService.Password;
            stateService.Password = null;

            _authorizationForm             = stateService.AuthorizationForm;
            stateService.AuthorizationForm = null;

            _secureValues             = stateService.SecureValues;
            stateService.SecureValues = null;

            _secureType             = stateService.SecureType;
            stateService.SecureType = null;

            _secureRequiredType             = stateService.SecureRequiredType;
            stateService.SecureRequiredType = null;

            var password = _passwordBase as TLPassword81;

            if (password != null)
            {
                var passwordSettings = password.Settings as TLPasswordSettings83;
                if (passwordSettings != null)
                {
                    CurrentEmail = TLString.IsNullOrEmpty(passwordSettings.Email)? string.Empty : passwordSettings.Email.ToString();
                }
            }

            _emailValue = _secureRequiredType != null ? _secureRequiredType.DataValue : null;
        }
Exemple #18
0
        public AddAdminsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            Status = AppResources.Loading;

            _currentChat             = StateService.CurrentChat;
            StateService.CurrentChat = null;

            var chat = _currentChat as TLChat40;

            _adminsEnabled = chat != null && chat.AdminsEnabled.Value;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => AdminsEnabled))
                {
                    if (!AdminsEnabled)
                    {
                        foreach (var item in Items)
                        {
                            item.IsSelected = !AdminsEnabled;
                        }
                    }
                    else
                    {
                        UpdateAdmins(_currentChat.Participants as IChatParticipants);
                    }

                    NotifyOfPropertyChange(() => AddAdminsDescription);
                }
            };
        }
        public LinksViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Files       = new ObservableCollection <TimeKeyGroup <TLMessageBase> >();
            Status      = AppResources.Loading;
            IsEmptyList = false;
            Items       = new ObservableCollection <TLMessage>();

            DisplayName = LowercaseConverter.Convert(AppResources.SharedLinks);
            EventAggregator.Subscribe(this);

            PropertyChanged += (o, e) =>
            {
                if (Property.NameEquals(e.PropertyName, () => IsSelectionEnabled))
                {
                    if (!IsSelectionEnabled)
                    {
                        foreach (var item in Items)
                        {
                            item.IsSelected = false;
                        }
                    }
                }
            };
        }
        public ShareContactViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Status = AppResources.Loading;
            BeginOnThreadPool(() =>
                              CacheService.GetContactsAsync(
                                  contacts =>
            {
                var currentUser = contacts.FirstOrDefault(x => x.Index == StateService.CurrentUserId);
                if (currentUser == null)
                {
                    currentUser = CacheService.GetUser(new TLInt(StateService.CurrentUserId));
                    if (currentUser != null)
                    {
                        contacts.Add(currentUser);
                    }
                }

                Status = string.Empty;
                Items.Clear();
                foreach (var contact in contacts.OrderBy(x => x.FullName))
                {
                    if (!(contact is TLUserEmpty))
                    {
                        Items.Add(contact);
                    }
                }

                if (Items.Count == 0)
                {
                    Status = string.Format("{0}", AppResources.NoUsersHere);
                }
            }));
        }
        public ChooseCountryViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) 
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            const string Groups = "abcdefghijklmnopqrstuvwxyz";
            Items = new ObservableCollection<CountriesInGroup>();

            var countries = new List<CountriesInGroup>(Groups.Length);
            var groups = new Dictionary<string, CountriesInGroup>();

            foreach (var c in Groups)
            {
                var group = new CountriesInGroup(c.ToString(CultureInfo.InvariantCulture));
                countries.Add(group);
                groups[c.ToString(CultureInfo.InvariantCulture)] = group;
            }

            foreach (var country in CountryUtils.CountriesSource)
            {
                groups[country.GetKey()].Add(country);
            }

            var count = 0;

            for (var i = 0; i < count; i++)
            {
                Items.Add(countries[i]);
            }

            for (var i = count; i < countries.Count; i++)
            {
                LazyItems.Add(countries[i]);
            }

            BeginOnUIThread(PopulateItems);
        }
        public LastSeenViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            _rules = StateService.PrivacyRules;
            StateService.PrivacyRules = null;

            MainRules = new List <TLPrivacyRuleBase>
            {
                new TLPrivacyValueAllowAll {
                    Label = AppResources.Everybody.ToLowerInvariant()
                },
                new TLPrivacyValueAllowContacts {
                    Label = AppResources.MyContacts.ToLowerInvariant()
                },
                new TLPrivacyValueDisallowAll {
                    Label = AppResources.Nobody.ToLowerInvariant()
                }
            };

            _selectedMainRule   = GetSelectedMainRule(MainRules, _rules, MainRules[0], MainRules[2]);
            _selectedAllowUsers = GetSelectedRule <TLPrivacyValueAllowUsers>(_rules) ?? new TLPrivacyValueAllowUsers {
                Users = new TLVector <TLInt>()
            };
            _selectedDisallowUsers = GetSelectedRule <TLPrivacyValueDisallowUsers>(_rules) ?? new TLPrivacyValueDisallowUsers {
                Users = new TLVector <TLInt>()
            };
            SwitchUsersVisibility(true);
            PropertyChanged += OnPropertyChanged;
        }
Exemple #23
0
        public SearchVenuesViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            Items  = new ObservableCollection <TLObject>();
            Status = AppResources.NoResults;

            if (StateService.GeoCoordinate != null)
            {
                _location = StateService.GeoCoordinate;
                StateService.GeoCoordinate = null;
            }

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Text))
                {
                    if (!string.IsNullOrEmpty(Text))
                    {
                        Search(Text);
                    }
                    else
                    {
                        Items.Clear();
                        Status = AppResources.NoResults;
                    }
                }
            };
        }
Exemple #24
0
        public ArchivedStickersViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            Status = AppResources.Loading;
        }
Exemple #25
0
 public EditPhoneNumberViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     if (StateService.CurrentContact != null)
     {
         CurrentItem = StateService.CurrentContact;
         StateService.CurrentContact = null;
     }
 }
        public ChannelBlockedContactsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Channel = StateService.CurrentChat as TLChannel;
            StateService.CurrentChat = null;

            eventAggregator.Subscribe(this);
        }
Exemple #27
0
        public SearchMessagesViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Items       = new ObservableCollection <TLDialog>();
            DisplayName = LowercaseConverter.Convert(AppResources.Messages);

            EventAggregator.Subscribe(this);
        }
Exemple #28
0
        public CreateChannelStep3ViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            GroupedUsers = new ObservableCollection <TLUserBase>();

            _newChannel             = StateService.NewChannel;
            StateService.NewChannel = null;
        }
        public BioViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _currentUser = stateService.CurrentContact as TLUser45;
            stateService.CurrentContact = null;

            About = _currentUser != null && _currentUser.About != null?_currentUser.About.ToString() : string.Empty;
        }
Exemple #30
0
 protected ViewModelBase(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
 {
     CacheService      = cacheService;
     ErrorHandler      = errorHandler;
     StateService      = stateService;
     MTProtoService    = mtProtoService;
     NavigationService = navigationService;
     EventAggregator   = eventAggregator;
 }