public static User UserWithActivityEventJObject(JObject json) { User user = null; string userId = json["user"].ToString(); if (Cinderella.CinderellaCore.UserCache.ContainsKey(userId)) user = Cinderella.CinderellaCore.UserCache[userId]; else { user = new User(); user.ResourceId = userId; Cinderella.CinderellaCore.UserCache[user.ResourceId] = user; } JToken nameValue; if (json.TryGetValue("username", out nameValue)) { user.Name = json["username"].ToString(); } JToken farmValue; if (json.TryGetValue("iconfarm", out farmValue)) { user.Farm = json["iconfarm"].ToString(); } JToken serverValue; if (json.TryGetValue("iconserver", out serverValue)) { user.Server = json["iconserver"].ToString(); } return user; }
private void UpdateInfoView() { LoadingView.Visibility = Visibility.Collapsed; ContentView.Visibility = Visibility.Visible; currentUser = Cinderella.CinderellaCore.CurrentUser; AvatarView.UserSource = currentUser; NameLabel.Text = currentUser.UserName; ProLabel.Visibility = currentUser.IsProUser ? Visibility.Visible : Visibility.Collapsed; // Description label if (currentUser.Description != null && currentUser.Description.Length > 0) { formatUserInfoText(currentUser.Description); } else { if (currentUser.hasFirstDate) formatUserInfoText(AppResources.SummersaltUserInfoMemberSinceText + currentUser.FirstDate.ToShortDateString()); else if (currentUser.PhotoCount > 0) formatUserInfoText(AppResources.SummersaltUserInfoPhotoUploadedText + currentUser.PhotoCount.ToString()); else formatUserInfoText(AppResources.SummersaltNoInfoFoundText); } }
public User RetrieveCurrentUserInfo() { bool result = true; var settings = IsolatedStorageSettings.ApplicationSettings; User _currentUser = new User(); if (settings.Contains("currentUserId")) { _currentUser.ResourceId = settings["currentUserId"] as string; Debug.WriteLine("current user id retrieved: " + _currentUser.ResourceId); } else { Debug.WriteLine("current user id is not stored"); result = false; } if (settings.Contains("currentUserName")) { _currentUser.Name = settings["currentUserName"] as string; Debug.WriteLine("current user name retrieved: " + _currentUser.Name); } else { Debug.WriteLine("current user name is not stored"); result = false; } if (settings.Contains("currentUserUserName")) { _currentUser.UserName = settings["currentUserUserName"] as string; Debug.WriteLine("current user username retrieved: " + _currentUser.UserName); } else { Debug.WriteLine("current user username is not stored"); result = false; } if (result) { CurrentUser = _currentUser; UserCache[CurrentUser.ResourceId] = CurrentUser; // Dispatch event if(CurrentUserReturned != null) CurrentUserReturned(this, null); return CurrentUser; } else { return null; } }
public void RemoveEventListeners() { if (eventListenersRemoved) return; eventListenersRemoved = true; Cinderella.CinderellaCore.UserInfoUpdated -= OnUserProfileUpdated; UserSource = null; }
public static User UserWithUserInfoJObject(JObject rootJson) { JObject json = (JObject)rootJson["person"]; User user = null; string userId = json["id"].ToString(); if (Cinderella.CinderellaCore.UserCache.ContainsKey(userId)) user = Cinderella.CinderellaCore.UserCache[userId]; else { user = new User(); user.ResourceId = userId; Cinderella.CinderellaCore.UserCache[user.ResourceId] = user; } user.IsFullInfoLoaded = true; // Is pro user user.IsProUser = (json["ispro"].ToString() == "1"); // User name JToken nameValue; if (json.TryGetValue("username", out nameValue)) { user.Name = json["username"]["_content"].ToString(); } JToken realNameValue; if (json.TryGetValue("realname", out realNameValue)) { user.RealName = json["realname"]["_content"].ToString(); } // Location JToken locationValue; if (json.TryGetValue("location", out locationValue)) { user.Location = json["location"]["_content"].ToString(); } // Description JToken descValue; if (json.TryGetValue("description", out descValue)) { user.Description = json["description"]["_content"].ToString(); } JToken farmValue; if (json.TryGetValue("iconfarm", out farmValue)) { user.Farm = json["iconfarm"].ToString(); } JToken serverValue; if (json.TryGetValue("iconserver", out serverValue)) { user.Server = json["iconserver"].ToString(); } // Profile url JToken profileUrlValue; if (json.TryGetValue("profileurl", out profileUrlValue)) { user.ProfileUrl = json["profileurl"]["_content"].ToString(); } // Photos section JObject photoJson = (JObject)json["photos"]; JToken photoCountValue; if (photoJson.TryGetValue("count", out photoCountValue)) { user.PhotoCount = int.Parse(photoJson["count"]["_content"].ToString()); } JToken firstDateValue; if (photoJson.TryGetValue("firstdate", out firstDateValue)) { string dateString = photoJson["firstdate"]["_content"].ToString(); if (dateString.Length > 0) { user.FirstDate = dateString.ToDateTime(); user.hasFirstDate = true; } else user.hasFirstDate = false; } return user; }
public async void GetAccessTokenAsync() { string timestamp = DateTimeUtils.GetTimestamp(); string nonce = Guid.NewGuid().ToString().Replace("-", null); // Encode the request string string paramString = "oauth_consumer_key=" + consumerKey; paramString += "&oauth_nonce=" + nonce; paramString += "&oauth_signature_method=HMAC-SHA1"; paramString += "&oauth_timestamp=" + timestamp; paramString += "&oauth_token=" + RequestToken; paramString += "&oauth_verifier=" + RequestTokenVerifier; paramString += "&oauth_version=1.0"; string signature = GenerateSignature("GET", RequestTokenSecret, "http://www.flickr.com/services/oauth/access_token", paramString); // Create the http request string requestUrl = "http://www.flickr.com/services/oauth/access_token?" + paramString + "&oauth_signature=" + signature; HttpWebResponse response = await DispatchRequest("GET", requestUrl, null).ConfigureAwait(false); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { string jsonString = await reader.ReadToEndAsync().ConfigureAwait(false); System.Diagnostics.Debug.WriteLine(jsonString); // Dispatch an event if (response.StatusCode == HttpStatusCode.OK) { if (jsonString.StartsWith("fullname=")) { var dict = jsonString.ParseQueryString(); AccessToken = dict["oauth_token"]; AccessTokenSecret = dict["oauth_token_secret"]; // Store access token this.SaveAccessCredentials(); // Construct current user object User currentUser = new User(); currentUser.ResourceId = Uri.UnescapeDataString(dict["user_nsid"]); currentUser.Name = dict["fullname"]; currentUser.UserName = dict["username"]; Cinderella.Cinderella.CinderellaCore.UserCache[currentUser.ResourceId] = currentUser; Cinderella.Cinderella.CinderellaCore.CurrentUser = currentUser; Cinderella.Cinderella.CinderellaCore.SaveCurrentUserInfo(); // Dispatch a login-success event AccessTokenGranted(this, null); } } else { AccessTokenFailed(this, null); } } }
public void RemoveEventListeners() { if (eventListenersRemoved) return; eventListenersRemoved = true; Cinderella.CinderellaCore.PhotoStreamUpdated -= OnPhotoStreamUpdated; Anaconda.AnacondaCore.PhotoStreamException -= OnPhotoStreamException; UserSource = null; }
protected override void OnRemovedFromJournal(JournalEntryRemovedEventArgs e) { PhotoPageView.RemoveEventListeners(); InfoPageView.RemoveEventListeners(); UserSource = null; this.DataContext = null; base.OnRemovedFromJournal(e); }
private void PerformAppearanceAnimation() { double h = System.Windows.Application.Current.Host.Content.ActualHeight; CompositeTransform ct = (CompositeTransform)LayoutRoot.RenderTransform; ct.TranslateY = h; LayoutRoot.Visibility = Visibility.Visible; Storyboard animation = new Storyboard(); animation.Duration = new Duration(TimeSpan.FromSeconds(0.3)); // Y animation DoubleAnimation galleryAnimation = new DoubleAnimation(); galleryAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3)); galleryAnimation.To = 0.0; galleryAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; Storyboard.SetTarget(galleryAnimation, LayoutRoot); Storyboard.SetTargetProperty(galleryAnimation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)")); animation.Children.Add(galleryAnimation); animation.Begin(); animation.Completed += (sender, e) => { string userId = NavigationContext.QueryString["user_id"]; if (!Cinderella.CinderellaCore.UserCache.ContainsKey(userId)) return; UserSource = Cinderella.CinderellaCore.UserCache[userId]; // Title this.DataContext = UserSource; }; }