Exemplo n.º 1
0
        public LoginStepViewModel(IDialogService dialogService, IUserCredentials userCredentials)
        {
            _dialogService   = dialogService;
            _userCredentials = userCredentials;

            UserName = _userCredentials.GetName();
        }
Exemplo n.º 2
0
        public async Task RemoveTokenAsync(string token)
        {
            TcpClient client = null;

            ServiceCommunication.SendNetworkMessage(ref client,
                                                    JsonConvert.SerializeObject(new NetworkMessage(MessageType.Delete)
            {
                Token = token, Username = _userCredentials.GetName()
            }));

            _logger.Trace($"RemoveTokenAsync: {token}");

            RemoveTokenImage(token);

            await Task.Yield();
        }
Exemplo n.º 3
0
        public async Task InitializeAsync()
        {
            _serviceStarted = await Task.Factory.StartNew(() => _tokenService.Ping());

            if (!_serviceStarted)
            {
                _synchronizationService.RunInMainThread(() => RaisePropertyChanged(nameof(AllowAdd)));

                _dialogService.ShowErrorDialog("Service not available");

                return;
            }

            var tokens = await _tokenService.GetTokensAsync(_userCredentials.GetName());

            if (Items.Any())
            {
                _synchronizationService.RunInMainThread(() => Items.Clear());
            }

            foreach (var token in tokens)
            {
                var tokenKey          = token.Key;
                var imageData         = _tokenService.GetTokenImage(tokenKey);
                var ringItemViewModel =
                    new RingItemViewModel {
                    Name = token.Value, Token = tokenKey, Image = imageData.ImageBytes
                };
                ringItemViewModel.SetDefaultName(ringItemViewModel.Name);

                _synchronizationService.RunInMainThread(() => Items.Add(ringItemViewModel));
            }

            _synchronizationService.RunInMainThread(() =>
            {
                RaisePropertyChanged(nameof(AllowAdd));
                AddCommand.RaiseCanExecuteChanged();
            });
        }