private void FetchReply(TwitterMessage message, StatusView statusView) { if (message.InReplyToId > 0) { TwitterClient client = new TwitterClient(); client.GetStatusCompleted += (o, e) => { if (e.Error == null) { TwitterMessage newMessage = new TwitterMessage(XElement.Parse(e.Result)); // Create a new var animatee = new AnimatableMessage() { TwitterMessage = newMessage }; var timelines = animatee.GetAnimations(); var parentMessage = animatemessages.First(a => a.TwitterMessage == message); int index = animatemessages.IndexOf(parentMessage); animatemessages.Insert(index, animatee); mainBoard.Stop(); foreach (var timeline in timelines) { mainBoard.Children.Add(timeline); } animatee.AnimateTo(parentMessage.X, parentMessage.Y + 300, parentMessage.Z); MoveToMessage(index); } }; client.GetStatusAsync(message.InReplyToId); } }
/// <summary> /// CommandProperty property changed handler. /// </summary> /// <param name="d">StatusView that changed its Command.</param> /// <param name="e">DependencyPropertyChangedEventArgs.</param> private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { StatusView _StatusView = d as StatusView; if (_StatusView != null) { //TODO: Handle new value. } }
private void FetchReply(TwitterMessage message, StatusView statusView) { MessageViewModel.LoadingMessage = "Fetching previous message"; if (message.InReplyToId > 0) { WebClient client = new WebClient(); //TwitterClient client = new TwitterClient(); client.DownloadStringCompleted += (o, e) => { if (e.Error == null) { TwitterMessage newMessage = new TwitterMessage(XElement.Parse(e.Result)); // Create a new var animatee = new AnimatableMessage() { TwitterMessage = newMessage }; var parentMessage = messages.First(a => a.TwitterMessage == message); int index = messages.IndexOf(parentMessage); messages.Insert(index, animatee); animatee.X = parentMessage.X; animatee.Y = parentMessage.Y + 300; animatee.Z = parentMessage.Z; MessageViewModel.LoadedMessage = "Reply loaded"; //MoveToItem(index); items.SelectedItem = animatee; items.InvalidateMeasure(); } else { MessageViewModel.ErrorMessage = "Failed to load reply"; } }; client.DownloadStringAsync(new Uri(string.Format("http://api.twitter.com/1/statuses/show/{0}.xml", message.InReplyToId), UriKind.Absolute)); //client.Credentials = new NetworkCredential("jimlynn", "xxxxxxxxxxxxxxxxx"); //string result = client.DownloadString(string.Format("http://api.twitter.com/1/statuses/show/{0}.xml", statusID)); //return result; } }