コード例 #1
0
        public ContactInfoViewModel(IMTProtoService mtProtoService, ICacheService cacheService, IStateService stateService, ITelegramEventAggregator eventAggregator, INavigationService navigationService)
        {
            Spans = new List <TimerSpan>
            {
                new TimerSpan(AppResources.Enabled, string.Empty, 0, AppResources.Enabled),
                new TimerSpan(AppResources.HourNominativeSingular, "1", (int)TimeSpan.FromHours(1.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "1", AppResources.HourNominativeSingular).ToLowerInvariant())),
                new TimerSpan(AppResources.HourGenitivePlural, "8", (int)TimeSpan.FromHours(8.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "8", AppResources.HourGenitivePlural).ToLowerInvariant())),
                new TimerSpan(AppResources.DayNominativePlural, "2", (int)TimeSpan.FromDays(2.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "2", AppResources.DayNominativePlural).ToLowerInvariant())),
                new TimerSpan(AppResources.Disabled, string.Empty, int.MaxValue, AppResources.Disabled),
            };
            _selectedSpan = Spans[0];


            if (stateService.CurrentContact == null)
            {
                stateService.ClearNavigationStack = true;
                navigationService.UriFor <ShellViewModel>().Navigate();
                return;
            }

            CurrentItem = stateService.CurrentContact;
            stateService.CurrentContact = null;

            ContactPhone = stateService.CurrentContactPhone;
            stateService.CurrentContactPhone = null;

            _cacheService      = cacheService;
            _eventAggregator   = eventAggregator;
            _mtProtoService    = mtProtoService;
            _stateService      = stateService;
            _navigationService = navigationService;
        }
コード例 #2
0
        public ContactDetailsViewModel(IVoIPService voipService, IFileManager fileManager, ICacheService cacheService, ICommonErrorHandler errorHandler,
                                       IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService,
                                       ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _voipService = voipService;
            Spans        = new List <TimerSpan>
            {
                new TimerSpan(AppResources.Enabled, string.Empty, 0, AppResources.Enabled),
                new TimerSpan(AppResources.HourNominativeSingular, "1", (int)TimeSpan.FromHours(1.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "1", AppResources.HourNominativeSingular).ToLowerInvariant())),
                new TimerSpan(AppResources.HourGenitivePlural, "8", (int)TimeSpan.FromHours(8.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "8", AppResources.HourGenitivePlural).ToLowerInvariant())),
                new TimerSpan(AppResources.DayNominativePlural, "2", (int)TimeSpan.FromDays(2.0).TotalSeconds, string.Format(AppResources.MuteFor, string.Format("{0} {1}", "2", AppResources.DayNominativePlural).ToLowerInvariant())),
                new TimerSpan(AppResources.Disabled, string.Empty, int.MaxValue, AppResources.Disabled),
            };
            _selectedSpan = Spans[0];

            _notificationTimer          = new DispatcherTimer();
            _notificationTimer.Interval = TimeSpan.FromSeconds(Constants.NotificationTimerInterval);
            _notificationTimer.Tick    += OnNotificationTimerTick;

            _fileManager = fileManager;

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

            Sounds = new List <string>();

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => MuteUntil) &&
                    !_suppressUpdating)
                {
                    UpdateNotifySettingsAsync();
                }

                if (Property.NameEquals(args.PropertyName, () => SelectedSound) &&
                    !_suppressUpdating)
                {
                    NotificationsViewModel.PlaySound(SelectedSound);

                    UpdateNotifySettingsAsync();
                }
            };

            CalculateSecretChatParamsAsync();
        }
コード例 #3
0
 private void SetChatTTL(TLEncryptedChatBase chat)
 {
     if (chat != null && chat.MessageTTL != null)
     {
         var selectedSpan = TimerSpans.FirstOrDefault(x => x.Seconds == Chat.MessageTTL.Value);
         if (selectedSpan != null)
         {
             _selectedSpan = selectedSpan;
         }
         else
         {
             _selectedSpan = TimerSpans.First();
         }
     }
     else
     {
         _selectedSpan = TimerSpans.First();
     }
 }
コード例 #4
0
        public SecretContactDetailsViewModel(IMTProtoService mtProtoService, IStateService stateService, INavigationService navigationService, ITelegramEventAggregator eventAggregator, ICacheService cacheService)
        {
            _stateService      = stateService;
            _navigationService = navigationService;
            _eventAggregator   = eventAggregator;
            _mtProtoService    = mtProtoService;
            _cacheService      = cacheService;

            TimerSpans = new List <TimerSpan>
            {
                new TimerSpan(AppResources.OffMasculine, string.Empty, 0),
                new TimerSpan(AppResources.SecondNominativeSingular, "1", 1),
                new TimerSpan(AppResources.SecondNominativePlural, "2", 2),
                new TimerSpan(AppResources.SecondNominativePlural, "3", 3),
                new TimerSpan(AppResources.SecondNominativePlural, "4", 4),
                new TimerSpan(AppResources.SecondGenitivePlural, "5", 5),
                new TimerSpan(AppResources.SecondGenitivePlural, "6", 6),
                new TimerSpan(AppResources.SecondGenitivePlural, "7", 7),
                new TimerSpan(AppResources.SecondGenitivePlural, "8", 8),
                new TimerSpan(AppResources.SecondGenitivePlural, "9", 9),
                new TimerSpan(AppResources.SecondGenitivePlural, "10", 10),
                new TimerSpan(AppResources.SecondGenitivePlural, "11", 11),
                new TimerSpan(AppResources.SecondGenitivePlural, "12", 12),
                new TimerSpan(AppResources.SecondGenitivePlural, "13", 13),
                new TimerSpan(AppResources.SecondGenitivePlural, "14", 14),
                new TimerSpan(AppResources.SecondGenitivePlural, "15", 15),
                new TimerSpan(AppResources.SecondGenitivePlural, "30", 30),
                new TimerSpan(AppResources.MinuteNominativeSingular, "1", 60),
                new TimerSpan(AppResources.HourNominativeSingular, "1", (int)TimeSpan.FromHours(1.0).TotalSeconds),
                new TimerSpan(AppResources.DayNominativeSingular, "1", (int)TimeSpan.FromDays(1.0).TotalSeconds),
                new TimerSpan(AppResources.WeekNominativeSingular, "1", (int)TimeSpan.FromDays(7.0).TotalSeconds),
            };

            _selectedSpan = TimerSpans.First();

            _eventAggregator.Subscribe(this);
        }
コード例 #5
0
        private void SetTimerSpan(TimerSpan selectedSpan)
        {
            var chat = Chat as TLEncryptedChat;

            if (chat == null)
            {
                return;
            }

            var action = new TLDecryptedMessageActionSetMessageTTL();

            action.TTLSeconds = new TLInt(selectedSpan.Seconds);

            var decryptedTuple = SecretDialogDetailsViewModel.GetDecryptedServiceMessageAndObject(action, chat, _mtProtoService.CurrentUserId, _cacheService);

            SecretDialogDetailsViewModel.SendEncryptedService(chat, decryptedTuple.Item2, _mtProtoService, _cacheService,
                                                              result =>
            {
                _eventAggregator.Publish(new SetMessagesTTLEventArgs {
                    Chat = Chat, Message = decryptedTuple.Item1
                });
                Chat.MessageTTL = new TLInt(selectedSpan.Seconds);
            });
        }
コード例 #6
0
 public void SelectSpan(TimerSpan selectedSpan)
 {
     SelectedSpan = selectedSpan;
 }