示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GotNewFeedItemEventArgs"/> class.
 /// </summary>
 /// <param name="feedItem">The new feed item.</param>
 internal GotNewFeedItemEventArgs(FeedItem feedItem)
 {
     FeedItem = feedItem;
 }
示例#2
0
 /// <summary>
 /// Called by the river when this item is being hidden because it scrolled out of view.
 /// </summary>
 internal override void Cleanup()
 {
     _feedItem = null;
     DataContext = null;
 }
示例#3
0
        /// <summary>
        /// Called by the river when the item should render some data.
        /// </summary>
        /// <param name="state">A definition which describes the size and position of this item in the river.</param>
        /// <param name="data">The data that the river is requesting to be rendered. The item can override this and return different data if needed.</param>
        /// <returns>
        /// The data that this item will render. If null, the item won't be shown.
        /// </returns>
        internal override object RenderData(RiverItemState state, object data)
        {
            UserControl visualState = null;
            object finalData = data;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                if (state.RowSpan == state.ColumnSpan)
                {
                    visualState = _smallImage;
                }
                else if (App.Random.NextDouble() > .5)
                {
                    visualState = _smallNews;
                }
                else
                {
                    visualState = _smallTweet;
                }
            }
            else if (AppState.Instance.IsInitialized)
            {
                _feedItem = data as FeedItem;

                if (_feedItem != null && _feedItem.BlockReason != BlockReason.None)
                {
                    // This object is being rendered from history, but it got blocked since it was last displayed. Reject this content and get new content.
                    finalData = _feedItem = GetData(state, false) as FeedItem;
                }

                if (_feedItem is ImageFeedItem)
                {
                    // visualState = removed ? _largeImage as UserControl : _smallImage as UserControl;
                    visualState = _smallImage as UserControl;
                }
                else if (_feedItem is NewsFeedItem)
                {
                    // visualState = removed ? _largeNews as UserControl : _smallNews as UserControl;
                    visualState = _smallNews as UserControl;
                }
                else if (_feedItem is StatusFeedItem)
                {
                    // visualState = removed ? _largeTweet as UserControl : _smallTweet as UserControl;
                    visualState = _smallTweet as UserControl;
                }

                DataContext = _feedItem;

                if (Backside != null)
                {
                    TagBack tag = Backside.FindVisualChild<TagBack>();
                    if (tag != null)
                    {
                        tag.DataContext = DataContext;
                        if (_feedItem == null)
                        {
                            tag.TagName = string.Empty;
                        }
                        else
                        {
                            // Force mobile.twitter.com, because twitter doesn't redirect to the mobile site properly on Windows Mobile 6 devices
                            tag.TagName = _feedItem.Uri.OriginalString.Replace("twitter.com", "mobile.twitter.com");
                        }
                    }
                }
            }

            GoToState(visualState);

            return finalData;
        }
示例#4
0
 /// <summary>
 /// Raises the GotNewFeedItem event.
 /// </summary>
 /// <param name="feedItem">The feed item.</param>
 protected void RaiseGotNewFeedItem(FeedItem feedItem)
 {
     if (GotNewFeedItem != null)
     {
         GotNewFeedItem(this, new GotNewFeedItemEventArgs(feedItem));
     }
 }
示例#5
0
 /// <summary>
 /// Called by the river when this item is being hidden because it scrolled out of view.
 /// </summary>
 internal override void Cleanup()
 {
     _feedItem = null;
     _breaking.Stop(this);
     DataContext = null;
 }
示例#6
0
        /// <summary>
        /// Called by the river when the item should render some data.
        /// </summary>
        /// <param name="state">A definition which describes the size and position of this item in the river.</param>
        /// <param name="data">The data that the river is requesting to be rendered. The item can override this and return different data if needed.</param>
        /// <returns>
        /// The data that this item will render. If null, the item won't be shown.
        /// </returns>
        internal override object RenderData(RiverItemState state, object data)
        {
            UserControl visualState = null;
            object finalData = data;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                if (state.RowSpan == state.ColumnSpan)
                {
                    visualState = _smallImage;
                }
                else if (App.Random.NextDouble() > .5)
                {
                    visualState = _smallNews;
                }
                else
                {
                    visualState = _smallTweet;
                }
            }
            else if (AppState.Instance.IsInitialized)
            {
                _feedItem = data as FeedItem;

                if (_feedItem != null && _feedItem.BlockReason != BlockReason.None)
                {
                    // This object is being rendered from history, but it got blocked since it was last displayed. Reject this content and get new content.
                    finalData = _feedItem = GetData(state, false) as FeedItem;
                }

                if (_feedItem is ImageFeedItem)
                {
                    // visualState = removed ? _largeImage as UserControl : _smallImage as UserControl;
                    visualState = _smallImage as UserControl;
                }
                else if (_feedItem is NewsFeedItem)
                {
                    // visualState = removed ? _largeNews as UserControl : _smallNews as UserControl;
                    visualState = _smallNews as UserControl;
                }
                else if (_feedItem is StatusFeedItem)
                {
                    // visualState = removed ? _largeTweet as UserControl : _smallTweet as UserControl;
                    visualState = _smallTweet as UserControl;
                }

                DataContext = _feedItem;

                if (_feedItem is ImageFeedItem && _parentProxy != null)
                {
                    // Disable the item while it's loading.
                    _parentProxy.IsEnabled = _smallImage.Image.BitmapImage != null;
                }

                _banBtn.Visibility = _feedItem != null && !string.IsNullOrEmpty(_feedItem.Author) ? Visibility.Visible : Visibility.Hidden;
            }

            GoToState(visualState);

            if (_feedItem != null && DateTime.Now - _feedItem.Date <= Settings.Default.NewItemAlert)
            {
                // Show the "breaking" animation for new items.
                _breaking.Begin(this, Template, true);
            }

            return finalData;
        }