public AboutViewModel(IExtendedDeviceInfoService extendedDeviceInfoService, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _extendedDeviceInfoService = extendedDeviceInfoService; var datePicker = new DatePicker(); }
public SignInViewModel( IExtendedDeviceInfoService extendedDeviceInfoService, #if PRIVATE_BETA LogViewModel log, #endif ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _extendedDeviceInfoService = extendedDeviceInfoService; #if DEBUG HelpVisibility = Visibility.Visible; #endif EventAggregator.Subscribe(this); SuppressUpdateStatus = true; #if PRIVATE_BETA Log = log; #endif if (StateService.ChangePhoneNumber) { _changePhoneNumber = true; StateService.ChangePhoneNumber = false; } _showHelpTimer.Tick += (sender, args) => { if (!_startTime.HasValue) { _showHelpTimer.Stop(); return; } _timeCounter = (int)(Constants.ShowHelpTimeInSeconds - (DateTime.Now - _startTime.Value).TotalSeconds); if (_timeCounter <= 0) { _timeCounter = 0; HelpVisibility = Visibility.Visible; _showHelpTimer.Stop(); } }; if (!string.IsNullOrEmpty(MTProtoService.Country)) { OnGotUserCountry(this, new CountryEventArgs { Country = MTProtoService.Country }); } PropertyChanged += (sender, args) => { if (Property.NameEquals(args.PropertyName, () => PhoneNumber) || Property.NameEquals(args.PropertyName, () => PhoneCode)) { NotifyOfPropertyChange(() => CanSignIn); } else if (Property.NameEquals(args.PropertyName, () => IsLoadingCountryInfo) || Property.NameEquals(args.PropertyName, () => IsWorking)) { NotifyOfPropertyChange(() => IsInProgress); } }; }
public ConfirmViewModel(IExtendedDeviceInfoService extendedDeviceInfoService, DebugViewModel debug, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _extendedDeviceInfoService = extendedDeviceInfoService; #if DEBUG HelpVisibility = Visibility.Visible; #endif BeginOnThreadPool(() => { Subtitle = StateService.PhoneNumberString; BeginOnUIThread(() => NotifyOfPropertyChange(() => Subtitle)); }); SendCallTimeout = stateService.SendCallTimeout != null ? StateService.SendCallTimeout.Value : Constants.SendCallDefaultTimeout; EventAggregator.Subscribe(this); SuppressUpdateStatus = true; Debug = debug; if (StateService.ChangePhoneNumber) { _changePhoneNumber = true; StateService.ChangePhoneNumber = false; } //_updatesService = updatesService; PropertyChanged += (sender, args) => { if (Property.NameEquals(args.PropertyName, () => Code)) { NotifyOfPropertyChange(() => CanConfirm); if (!string.IsNullOrEmpty(Code) && Code.Length == Constants.PhoneCodeLength) { Confirm(); } } }; _callTimer.Tick += (sender, args) => { _timeCounter = (int)(SendCallTimeout - (DateTime.Now - _startTime).TotalSeconds); TimeCounterString = string.Format(AppResources.WeWillCallYou, TimeSpan.FromSeconds(TimeCounter).ToString(@"m\:ss")); if (_timeCounter <= 0) { _timeCounter = 0; TimeCounterString = AppResources.TelegramDialedYourNumber; HelpVisibility = Visibility.Visible; _callTimer.Stop(); MTProtoService.SendCallAsync( StateService.PhoneNumber, StateService.PhoneCodeHash, result => BeginOnUIThread(() => { }), error => BeginOnUIThread(() => { #if DEBUG MessageBox.Show(error.ToString()); #endif })); } NotifyOfPropertyChange(() => TimeCounter); }; }
public ConfirmViewModel(IExtendedDeviceInfoService extendedDeviceInfoService, DebugViewModel debug, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { _extendedDeviceInfoService = extendedDeviceInfoService; #if DEBUG HelpVisibility = Visibility.Visible; #endif _type = stateService.Type; stateService.Type = null; _nextType = stateService.NextType; stateService.NextType = null; Subtitle = GetSubtitle(); var length = _type as ILength; CodeLength = length != null ? length.Length.Value : Constants.DefaultCodeLength; Timeout = stateService.SendCallTimeout; ResendCodeVisibility = stateService.SendCallTimeout != null && stateService.SendCallTimeout.Value > 0 ? Visibility.Collapsed : Visibility.Visible; UpdateDebugString(); EventAggregator.Subscribe(this); SuppressUpdateStatus = true; Debug = debug; if (StateService.ChangePhoneNumber) { _changePhoneNumber = true; StateService.ChangePhoneNumber = false; } _sentCode = StateService.SentCode; StateService.SentCode = null; //_updatesService = updatesService; PropertyChanged += (sender, args) => { if (Property.NameEquals(args.PropertyName, () => Code)) { NotifyOfPropertyChange(() => CanConfirm); if (!string.IsNullOrEmpty(Code) && Code.Length == CodeLength) { Confirm(); } } }; _callTimer.Tick += (sender, args) => { _timeCounter = Timeout == null ? 0 : (int)(Timeout.Value - (DateTime.Now - _startTime).TotalSeconds); if (_timeCounter > 0) { #if DEBUG TimeCounterString = _timeCounter.ToString(CultureInfo.InvariantCulture); #endif if (_nextType is TLCodeTypeCall) { TimeCounterString = string.Format(AppResources.WeWillCallYou, TimeSpan.FromSeconds(TimeCounter).ToString(@"m\:ss")); } } else { _timeCounter = 0; if (_nextType is TLCodeTypeCall) { TimeCounterString = AppResources.TelegramDialedYourNumber; } HelpVisibility = Visibility.Visible; ResendCodeVisibility = Visibility.Visible; _callTimer.Stop(); } NotifyOfPropertyChange(() => TimeCounter); }; }