Inheritance: INotifyPropertyChanged
        public async Task<PhotosResponse> GetPhotosAsync(string methodName, User user, Preferences preferences, int page,
            IProgress<ProgressUpdate> progress)
        {
            var progressUpdate = new ProgressUpdate
            {
                OperationText = "Getting list of photos...",
                ShowPercent = false
            };
            progress.Report(progressUpdate);

            var extraParams = new Dictionary<string, string>
            {
                {ParameterNames.UserId, user.UserNsId},
                {ParameterNames.SafeSearch, SafeSearch.GetValue(preferences.SafetyLevel)},
                {
                    ParameterNames.PerPage,
                    preferences.PhotosPerPage.ToString(CultureInfo.InvariantCulture)
                },
                {ParameterNames.Page, page.ToString(CultureInfo.InvariantCulture)}
            };

            var photosResponse = (Dictionary<string, object>)
                await _oAuthManager.MakeAuthenticatedRequestAsync(methodName, extraParams);

            return photosResponse.GetPhotosResponseFromDictionary();
        }
 private async void CallApplyUser(User authenticatedUser)
 {
     var exraParams = new Dictionary<string, string>
     {
         {ParameterNames.UserId, authenticatedUser.UserNsId}
     };
     var userInfo = (Dictionary<string, object>)
         (await _oAuthManager.MakeAuthenticatedRequestAsync(Methods.PeopleGetInfo, exraParams))[
             "person"];
     authenticatedUser.Info = new UserInfo
     {
         Id = authenticatedUser.UserNsId,
         IsPro = Convert.ToBoolean(userInfo["ispro"]),
         IconServer = userInfo["iconserver"].ToString(),
         IconFarm = Convert.ToInt32(userInfo["iconfarm"]),
         PathAlias =
             userInfo["path_alias"] == null
                 ? string.Empty
                 : userInfo["path_alias"].ToString(),
         Description = userInfo.GetSubValue("description").ToString(),
         PhotosUrl = userInfo.GetSubValue("photosurl").ToString(),
         ProfileUrl = userInfo.GetSubValue("profileurl").ToString(),
         MobileUrl = userInfo.GetSubValue("mobileurl").ToString(),
         PhotosCount =
             Convert.ToInt32(
                 ((Dictionary<string, object>) userInfo["photos"]).GetSubValue(
                     "count"))
     };
     _applyUser(authenticatedUser);
 }
 public void WillConvertUserInstanceToJson()
 {
     var user = new User("name", "username", "usernsid");
     string userAsJson =
         "{\"Name\":\"name\",\"Username\":\"username\",\"UserNsId\":\"usernsid\",\"WelcomeMessage\":\"Welcome, name!\"}";
     Assert.AreEqual(userAsJson, user.ToJson());
 }
        public BrowserWindow(User user, Preferences preferences)
        {
            InitializeComponent();
            Title += VersionHelper.GetVersionString();
            Preferences = preferences;
            User = user;
            AllSelectedPhotos = new Dictionary<string, Dictionary<string, Photo>>();

            PagePhotoList.SelectionChanged += (sender, args) =>
            {
                if (_doNotSyncSelectedItems) return;
                AllSelectedPhotos[Page] = PagePhotoList.SelectedItems.Cast<Photo>().
                    ToDictionary(p => p.Id, p => p);
                PropertyChanged.Notify(() => SelectedPhotosExist);
                PropertyChanged.Notify(() => SelectedPhotosCountText);
                PropertyChanged.Notify(() => AreAnyPagePhotosSelected);
                PropertyChanged.Notify(() => AreAllPagePhotosSelected);
            };

            SpinnerInner.SpinnerCanceled += (sender, args) => _presenter.CancelDownload();

            FileCache.AppCacheDirectory = Preferences.CacheLocation;

            _presenter = Bootstrapper.GetPresenter<IBrowserView, IBrowserPresenter>(this);
            _presenter.InitializePhotoset();
        }
        public LoginWindow(User user)
        {
            InitializeComponent();
            Title += VersionHelper.GetVersionString();
            User = user;

            _presenter = Bootstrapper.GetPresenter<ILoginView, ILoginPresenter>(this);
            _presenter.InitializeScreen();
        }
        public PreferencesWindow(User user, Preferences preferences)
        {
            InitializeComponent();
            Title += VersionHelper.GetVersionString();
            Preferences = preferences;
            User = user;

            _presenter = Bootstrapper.GetPresenter<IPreferencesView, IPreferencesPresenter>(this);

            SetCacheSize();
        }
 private void ApplyLoggedInUser(User user)
 {
     _user = user;
     _asynchronouslyLoggedIn = true;
 }
 private void SetWelcomeLabel(User user)
 {
     WelcomeUserLabel.Dispatch(
         l => l.Content = string.IsNullOrEmpty(user.UserNsId) ? string.Empty : user.WelcomeMessage);
     if (user.Info == null) return;
     BuddyIcon.Dispatch(i => i.ImageUrl = user.Info.BuddyIconUrl);
 }
        private string CompleteAuthorization(string verifier)
        {
            AuthorizedTokenResponse response = _consumer.ProcessUserAuthorization(_requestToken, verifier);
            AccessToken = response.AccessToken;

            IDictionary<string, string> extraData = response.ExtraData;
            var authenticatedUser = new User(extraData["fullname"], extraData["username"], extraData["user_nsid"]);
            Authenticated(this, new AuthenticatedEventArgs(authenticatedUser));

            return response.AccessToken;
        }
 public AuthenticatedEventArgs(User user)
 {
     AuthenticatedUser = user;
 }
 private void ApplyUser(User user)
 {
     _view.ShowLoggedInControl(_preferences);
     _view.User = user;
     _view.ShowSpinner(false);
 }
Esempio n. 12
0
 public Session(User user, Preferences preferences, Photoset photoset = null) {
     User = user;
     Preferences = preferences;
     SelectedPhotoset = photoset;
 }