Exemplo n.º 1
0
 public LoginPanelViewModel(GoogleReaderService googleReaderService)
 {
     LoginCommand = new RelayCommand(() =>
     {
         googleReaderService.Authenticate(Username, Password);
     });
 }
Exemplo n.º 2
0
        static ViewModelLocator()
        {
            if (!ViewModelBase.IsInDesignModeStatic)
            {
                GoogleReaderService = new GoogleReaderService();
                NavigationService = new NavigationService();

                GoogleReaderService.Authenticated += (s,e) => {
                    if(e.IsAuthenticated == false && !NavigationService.CurrentUri().Contains(MainViewUrl)){
                        NavigationService.NavigateTo(ViewModelLocator.MainViewUrl);
                    }
                };
                GoogleReaderService.ConnectionError += (s,e) => MessageBox.Show("Server unreachable.");
                GoogleReaderService.Unauthorized += (s,e) => MessageBox.Show("Wrong credentials.");
                GoogleReaderService.Loading += (s, e) => GlobalLoading.Instance.IsLoading = e.IsLoading;
            }
        }
Exemplo n.º 3
0
        protected override void OnInvoke(ScheduledTask task)
        {
            var service = new GoogleReaderService();

            if (service.IsAuthenticated)
            {
                service.GetUnreadCount(count =>
                {
                    ShellTile.ActiveTiles.First().Update(new StandardTileData()
                    {
                        Count = count
                    });
                    NotifyComplete();
                });
            }
            else
            {
                NotifyComplete();
            }
        }
Exemplo n.º 4
0
        public MainViewModel(GoogleReaderService googleReaderService, INavigationService navigationService, ConfigViewModel config)
        {
            // init
            _googleReaderService = googleReaderService;
            _config = config;

            // commands
            FeedSelectedCommand = new RelayCommand<Item>(i =>
            {
                if (i != null)
                {
                    _read(i);
                    new WebBrowserTask()
                    {
                        Uri = new Uri(i.Url)
                    }.Show();
                }
            });
            BottomReached = new RelayCommand(() =>
            {
                Feed.Items.ForEach(item => _read(item));
            });
            ReadCommand = new RelayCommand<Item>(i => _read(i));
            UnreadCommand = new RelayCommand<Item>(i => _read(i, false));
            StarredCommand = new RelayCommand<Item>(i => _starred(i));
            UnstarredCommand = new RelayCommand<Item>(i => _starred(i, false));
            NavigateCommand = new RelayCommand<string>(s =>
            {
                new WebBrowserTask()
                {
                    Uri = new Uri(s)
                }.Show();
            });

            // listen to view messenger events
            Messenger.Default.Register<bool>(this, "logout", b => googleReaderService.Logout());
            Messenger.Default.Register<bool>(this, "refresh", b => _refresh());
            Messenger.Default.Register<bool>(this, "config", b => navigationService.NavigateTo(ViewModelLocator.ConfigUrl));
            Messenger.Default.Register<bool>(this, "about", b => navigationService.NavigateTo(ViewModelLocator.AboutUrl));

            // init display
            googleReaderService.Authenticated += (s, e) =>
            {
                if (e.IsAuthenticated)
                {
                    _logIn();
                }
                else
                {
                    _logOut();
                }
            };
            if (googleReaderService.IsAuthenticated)
            {
                _logIn();
            }
            else
            {
                _logOut();
            }
        }
Exemplo n.º 5
0
 public ConfigViewModel(GoogleReaderService googleReaderService)
 {
     _googleReaderService = googleReaderService;
 }