Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
        private void MoveToMessageId(Int64 id)
        {
            AnimatableMessage message = animatemessages.FirstOrDefault(m => m.TwitterMessage.Id == id);
            int index = animatemessages.IndexOf(message);

            MoveToMessage(index);
        }
Esempio n. 3
0
        private void SetCurrentItem(AnimatableMessage message)
        {
            var store = IsolatedStorageSettings.ApplicationSettings;

            store["CurrentMessage"] = message.TwitterMessage.Id;
            IsolatedStorageSettings.ApplicationSettings.Save();
        }
Esempio n. 4
0
        /// <summary>
        /// ZOrderProperty property changed handler.
        /// </summary>
        /// <param name="d">AnimatableMessage that changed its ZOrder.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnZOrderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AnimatableMessage _AnimatableMessage = d as AnimatableMessage;

            if (_AnimatableMessage != null)
            {
                //TODO: Handle new value.
            }
        }
Esempio n. 5
0
        private void GetTimeline_Click(object sender, RoutedEventArgs e)
        {
            animatemessages = new ObservableCollection <AnimatableMessage>();
            mainBoard.Stop();
            mainBoard.Children.Clear();
            var currentID = 12345L;

            if (IsolatedStorageSettings.ApplicationSettings.Contains("CurrentMessage"))
            {
                currentID = (Int64)IsolatedStorageSettings.ApplicationSettings["CurrentMessage"];
            }
            TwitterClient twitter = new TwitterClient();

            twitter.GetTimelineSinceCompleted += (o, a) =>
            {
                if (a.Error == null)
                {
                    XElement        element  = XElement.Parse(a.Result);
                    TwitterTimeline timeline = new TwitterTimeline(element);
                    int             zorder   = timeline.Count;
                    foreach (var tmess in timeline)
                    {
                        var mess = new AnimatableMessage {
                            TwitterMessage = tmess
                        };
                        animatemessages.Insert(0, mess);
                        //animatemessages.Add(mess);
                    }
                    listbox.ItemsSource = null;
                    listbox.ItemsSource = animatemessages;

                    frontmost = animatemessages.Count - 1;
                    //CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
                    BuildStoryboards(animatemessages);
                    currentItem = animatemessages.Count - 1;
                    var curmess = animatemessages.FirstOrDefault(m => m.TwitterMessage.Id == currentID);
                    if (curmess != null)
                    {
                        currentItem = animatemessages.IndexOf(curmess);
                    }
                    MoveToMessage(currentItem);
                }
            };
            twitter.GetTimelineSinceAsync(12345L);
        }
Esempio n. 6
0
        /// <summary>
        /// ZProperty property changed handler.
        /// </summary>
        /// <param name="d">AnimatableMessage that changed its Z.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnZPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AnimatableMessage _AnimatableMessage = d as AnimatableMessage;

            if (_AnimatableMessage != null)
            {
                double v = (double)e.NewValue;
                if (v > 0 && v < 200)
                {
                    _AnimatableMessage.Opacity = (200.0 - v) / 200.0;
                }
                else if (v >= 200)
                {
                    _AnimatableMessage.Opacity = 0;
                }
                else
                {
                    _AnimatableMessage.Opacity = 1;
                }
            }
        }
Esempio n. 7
0
 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;
     }
 }
Esempio n. 8
0
 private void SetCurrentItem(AnimatableMessage message)
 {
     var store = IsolatedStorageSettings.ApplicationSettings;
     store["CurrentMessage"] = message.TwitterMessage.Id;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }
Esempio n. 9
0
        private void GetTimeline_Click(object sender, RoutedEventArgs e)
        {
            animatemessages = new ObservableCollection<AnimatableMessage>();
            mainBoard.Stop();
            mainBoard.Children.Clear();
            var currentID = 12345L;
            if (IsolatedStorageSettings.ApplicationSettings.Contains("CurrentMessage"))
            {
                currentID = (Int64)IsolatedStorageSettings.ApplicationSettings["CurrentMessage"];
            }
            TwitterClient twitter = new TwitterClient();
            twitter.GetTimelineSinceCompleted += (o, a) =>
                {
                    if (a.Error == null)
                    {
                        XElement element = XElement.Parse(a.Result);
                        TwitterTimeline timeline = new TwitterTimeline(element);
                        int zorder = timeline.Count;
                        foreach (var tmess in timeline)
                        {
                            var mess = new AnimatableMessage { TwitterMessage = tmess };
                            animatemessages.Insert(0, mess);
                            //animatemessages.Add(mess);
                        }
                        listbox.ItemsSource = null;
                        listbox.ItemsSource = animatemessages;

                        frontmost = animatemessages.Count - 1;
                        //CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
                        BuildStoryboards(animatemessages);
                        currentItem = animatemessages.Count - 1;
                        var curmess = animatemessages.FirstOrDefault(m => m.TwitterMessage.Id == currentID);
                        if (curmess != null)
                        {
                            currentItem = animatemessages.IndexOf(curmess);
                        }
                        MoveToMessage(currentItem);
                    }
                };
            twitter.GetTimelineSinceAsync(12345L);
        }
Esempio n. 10
0
 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);
     }
 }