protected override void PerformAction(object parameter) { object[] parameterList = parameter as object[]; FacebookContact contact = parameterList[0] as FacebookContact; string comment = parameterList[1] as string; ServiceProvider.FacebookService.WriteOnWall(contact, comment); }
private IEnumerable _GetContactDisplayInfo(FacebookContact contact) { RowMap[] _rowTable = new[] { //new BlockMap("Facebook Page", contact.ProfileUri, _BlockBuildSingleUri), new RowMap("Birthday", contact.Birthday, _RowBuildSingleString), new RowMap("Current Location", contact.CurrentLocation, _RowBuildSingleLocation), new RowMap("Hometown", contact.Hometown, _RowBuildSingleLocation), // Most people already know the sex of their friends. No reason to display it. //new RowMap("Sex", contact.Sex, _RowBuildSingleString), new RowMap("Relationship Status", contact.RelationshipStatus, _RowBuildSingleString), new RowMap("Religion", contact.Religion, _RowBuildSingleString), new RowMap("Website", contact.Website, _RowBuildSingleString), new RowMap("Activities", contact.Activities, _RowBuildSingleString), new RowMap("Interests", contact.Interests, _RowBuildSingleString), new RowMap("Favorite Music", contact.Music, _RowBuildSingleString), new RowMap("Favorite TV Shows", contact.TV, _RowBuildSingleString), new RowMap("Favorite Movies", contact.Movies, _RowBuildSingleString), new RowMap("Favorite Books", contact.Books, _RowBuildSingleString), new RowMap("Favorite Quotes", contact.Quotes, _RowBuildSingleString), new RowMap("About Me", contact.AboutMe, _RowBuildSingleString), // Need to add Education, Highschool, Work History. }; var table = new Table { CellSpacing = 5, Padding = new Thickness(15) }; table.Columns.Add(new TableColumn { Width = new GridLength(150) }); table.Columns.Add(new TableColumn { Width = new GridLength(0, GridUnitType.Auto) }); TableRowGroup rowGroup = new TableRowGroup(); foreach (var rowMap in _rowTable) { TableRow retRow = rowMap.Func(rowMap.Title, rowMap.Value); if (retRow != null) { rowGroup.Rows.Add(retRow); } } table.RowGroups.Add(rowGroup); yield return(table); }
/// <summary> /// Gets content that should be displayed for a given navigator. In most cases, this is just the Navigator.Content object, except for /// PhotoNavigators where is a photo-document wrapper class. /// </summary> /// <param name="navigator">Navigator whose content must be retrieved.</param> /// <returns>The object that forms the content of the Navigator.</returns> private object _GetNavigatorContent(Navigator navigator) { object content = null; if (navigator != null) { var photoNavigator = navigator as PhotoNavigator; var albumNavigator = navigator as PhotoAlbumNavigator; var contactNavigator = navigator as ContactNavigator; if (photoNavigator != null) { var photo = photoNavigator.Content as FacebookPhoto; content = photo; // If photo navigator's parent is a photo album, set active photo album to this value var parent = photoNavigator.Parent as PhotoAlbumNavigator; if (parent != null) { this.ActivePhotoAlbum = parent.Content as FacebookPhotoAlbum; } else { this.ActivePhotoAlbum = null; } this.ActivePhoto = photo; } else if (albumNavigator != null) { FacebookPhotoAlbum album = albumNavigator.Content as FacebookPhotoAlbum; content = album; this.ActivePhotoAlbum = album; this.ActivePhoto = null; } else if (contactNavigator != null) { FacebookContact contact = contactNavigator.Content as FacebookContact; content = contact; } else { // Return navigator's content content = navigator.Content; } } return(content); }
/// <summary> /// Event handler for when checkbox is toggled on or off. /// </summary> /// <param name="sender">Event source.</param> /// <param name="e">Event args.</param> private void CheckBox_Checked(object sender, RoutedEventArgs e) { CheckBox cb = sender as CheckBox; if (cb != null) { // Find ListBoxItem parent of CheckBox ListBoxItem item = FindVisualParent(sender as CheckBox); FacebookContact selectedUser = (FacebookContact)item.Content; // TODO : make this an asyn call this.Close(); if (this.TagsUpdatedEvent != null) { this.TagsUpdatedEvent(this, new TagsUpdatedArgs(selectedUser)); } } }
public PhotoExplorerContactNode(FacebookContact contact) : base(contact, contact.Name) { Contact = contact; }
public static FacebookContact Contact(long id, JToken json) { FacebookContact fb; if ((fb = Data.FacebookContacts.FirstOrDefault(x => x.Id == id)) == null) { fb = new FacebookContact { Id = id, Name = json.TryGetValue <string>("name") }; if (fb.Name == default(string)) { return(null); } Data.FacebookContacts.InsertOnSubmit(fb); } if (!json.Any()) { return(fb); } fb.Name = json.TryGetValue <string>("name"); string username; if ((username = json.TryGetValue <string>("username")) != null) { fb.Username = username; } fb.LastUpdated = json.TryGetValue <DateTime>("updated_time"); DateTime birthday; if ((birthday = json.TryGetValue <DateTime>("birthday")) != default(DateTime)) { fb.Birthday = birthday; } string gender; if ((gender = json.TryGetValue <string>("gender")) != null) { fb.Gender = gender.IndexOf("male", StringComparison.InvariantCultureIgnoreCase) > -1 ? "M" : "F"; } try { Data.SubmitChanges(); } catch (Exception ex) { Log.Error(string.Format("There was an error saving the contact: {0} {1}", id, fb.Name), ex); return(null); } var locationId = json["location"].TryGetValue <long?>("id"); if (locationId != null) { var location = Place(locationId.Value, json["location"]); if (location != null) { fb.Location = location.Id; } try { Data.SubmitChanges(); } catch (Exception ex) { Log.Error(string.Format("There was an error saving the contact: {0} {1}", id, fb.Name), ex); } } return(fb); }
public ContactNavigator(FacebookContact contact, FacebookObjectId guid, Navigator parent) : base(contact, guid, parent) { }
public ContactNavigator(FacebookContact contact, Navigator parent) : this(contact, contact.UserId, parent) { }
private void _GenerateInlines() { // This all could probably be simplified... Inlines.Clear(); if (ActivityPost == null) { return; } if (ActivityPost.LikedCount == 0) { // Inlines.Add(new Run("No one has liked this.")); // We shouldn't add this text. It looks like an undigg... return; } if (ActivityPost.PeopleWhoLikeThis.Count == 0) { if (ActivityPost.LikedCount == 1) { if (ActivityPost.HasLiked) { Inlines.Add(new Run("You like this.")); } else { Inlines.Add(new Run("1 person likes this.")); } } else { if (ActivityPost.HasLiked) { if (ActivityPost.LikedCount == 2) { Inlines.Add(new Run("You and 1 other person like this")); } else { Inlines.Add(new Run(string.Format("You and {0} other people like this", ActivityPost.LikedCount - 1))); } } else { Inlines.Add(new Run(string.Format("{0} people like this.", ActivityPost.LikedCount))); } } return; } // Scenarios: // A likes this. // A and 3 others like this. // A and B like this // A, B, and 1 other person like this. // A, B, and 3 others like this. // A and you like this. // A, B, and C like this. int peopleLeft = ActivityPost.LikedCount - ActivityPost.PeopleWhoLikeThis.Count; Assert.IsTrue(peopleLeft >= 0); int namedCount = ActivityPost.PeopleWhoLikeThis.Count; int youIndex = -1; if (ActivityPost.HasLiked) { youIndex = namedCount; ++namedCount; --peopleLeft; } else if (namedCount == 1 && peopleLeft == 0) { Inlines.Add(new Run(string.Format("{0} likes this.", ActivityPost.PeopleWhoLikeThis[0]))); return; } for (int i = 0; i < namedCount; ++i) { if (i == namedCount - 1 && peopleLeft == 0) { if (i != 1) { Inlines.Add(new Run(", and ")); } else { Inlines.Add(new Run(" and ")); } } else if (i != 0) { Inlines.Add(new Run(", ")); } if (i == youIndex) { Inlines.Add("you"); } else { FacebookContact contact = ActivityPost.PeopleWhoLikeThis[i]; var hyperlink = new Hyperlink { NavigateUri = new Uri("http://facebook.com/profile.php?id=" + contact.UserId.ToString()) }; hyperlink.RequestNavigate += _OnRequestNavigate; if (string.IsNullOrEmpty(contact.Name)) { hyperlink.Inlines.Add("Someone"); } else { hyperlink.Inlines.Add(contact.Name); } Inlines.Add(hyperlink); } } if (namedCount != 1 && peopleLeft != 0) { Inlines.Add(","); } if (peopleLeft == 1) { Inlines.Add(" and 1 other person like this."); } else if (peopleLeft != 0) { Inlines.Add(string.Format(" and {0} others like this.", peopleLeft)); } else { Inlines.Add(" like this."); } }
public void AddUser(FacebookContact user) { _userCache.SetValue(user.UserId, user); }
public void AddTagToPhoto(FacebookPhoto photo, FacebookContact contact, Point offset) { ServiceProvider.FacebookService.AddPhotoTag(photo, contact, offset); }
private static void _BuildFriendsListsAndUpdateSplashImages(object friendsObj) { var friends = (FacebookContactCollection)friendsObj; try { IEnumerable <FacebookContact> lessInterestingFriendsEnum; List <FacebookContact> interestingFriends = friends.SplitWhere(f => f.InterestLevel >= 0.8, out lessInterestingFriendsEnum).ToList(); List <FacebookContact> lessInterestingFriends = lessInterestingFriendsEnum.ToList(); int friendCount = Math.Min((interestingFriends.Count + lessInterestingFriends.Count), 5); var chosenFriends = new List <FacebookContact>(friendCount); var rand = new Random(DateTime.Now.Millisecond); int selectedFriendCount = 0; if (lessInterestingFriends.Count > 0) { FacebookContact lessInterest = lessInterestingFriends[rand.Next(lessInterestingFriends.Count - 1)]; lessInterestingFriends.Remove(lessInterest); chosenFriends.Add(lessInterest); selectedFriendCount++; } while ((selectedFriendCount < 5) && (interestingFriends.Count > 0 || lessInterestingFriends.Count > 0)) { if (interestingFriends.Count > 0) { FacebookContact interest = interestingFriends[rand.Next(interestingFriends.Count - 1)]; interestingFriends.Remove(interest); chosenFriends.Add(interest); selectedFriendCount++; } else if (lessInterestingFriends.Count > 0) { FacebookContact lessInterest = lessInterestingFriends[rand.Next(lessInterestingFriends.Count - 1)]; lessInterestingFriends.Remove(lessInterest); chosenFriends.Add(lessInterest); selectedFriendCount++; } } var friendImages = new List <ImageSource>(friendCount); foreach (var friend in chosenFriends) { friend.Image.GetImageAsync( FacebookImageDimensions.Normal, (sender, e) => { if (e.Cancelled || e.Error != null) { return; } friendImages.Add(e.ImageSource); if (friendImages.Count == friendCount) { try { _FriendImageDownloadCompleted(friendImages); } catch (Exception ex) { Assert.Fail(ex.Message); } } }); } } catch (Exception e) { Assert.Fail(e.Message); } }
public TagsUpdatedArgs(FacebookContact contact) { this.SelectedContact = contact; }