コード例 #1
0
        public void Select(ListItem item)
        {
            if (item == null)
            {
                return;
            }

            var feed = item as NewsFeed;

            if (feed != null)
            {
                _selectedFeed = feed;

                ServiceRegistration.Get <IWorkflowManager>().NavigatePush(WORKFLOWSTATEID_NEWSITEMS, new NavigationContextConfig
                {
                    NavigationContextDisplayLabel = feed.Title
                });
            }
            else
            {
                var feedItem = item as NewsItem;
                if (feedItem != null)
                {
                    _selectedItem = feedItem;
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePush(WORKFLOWSTATEID_NEWSITEMDETAIL, new NavigationContextConfig
                    {
                        NavigationContextDisplayLabel = feedItem.PublishDate.ToString("g", ServiceRegistration.Get <ILocalization>().CurrentCulture)
                    });
                }
            }
        }
コード例 #2
0
 public void ChangeModelContext(NavigationContext oldContext, NavigationContext newContext, bool push)
 {
     if (!push)
     {
         if (oldContext.WorkflowState.StateId == WORKFLOWSTATEID_NEWSITEMS)
         {
             _selectedFeed = null;
         }
         else if (oldContext.WorkflowState.StateId == WORKFLOWSTATEID_NEWSITEMDETAIL)
         {
             _selectedItem = null;
         }
     }
 }
コード例 #3
0
    public static NewsFeed ReadFeed(string feedUrl)
    {
      SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create(feedUrl));
      var newFeed = new NewsFeed
        {
          Title = feed.Title != null ? feed.Title.Text : string.Empty,
          Description = feed.Description != null ? feed.Description.Text : string.Empty,
          LastUpdated = feed.LastUpdatedTime.LocalDateTime,
          Icon = GetCachedOrDownloadImage(feed.ImageUrl)
        };

      foreach (var item in feed.Items)
      {
        newFeed.Items.Add(TransformItem(item, newFeed));
      }
      return newFeed;
    }
コード例 #4
0
 static NewsItem TransformItem(SyndicationItem item, NewsFeed targetFeed)
 {
   var newItem = new NewsItem
     {
       Id = GetItemId(item),
       Feed = targetFeed,
       Title = item.Title != null ? item.Title.Text : string.Empty,
       PublishDate = item.PublishDate.LocalDateTime,
       Summary = GetItemSummary(item),
       Thumb = GetItemThumb(item)
     };
   return newItem;
 }
コード例 #5
0
ファイル: NewsModel.cs プロジェクト: HAF-Blade/MediaPortal-2
 public void ChangeModelContext(NavigationContext oldContext, NavigationContext newContext, bool push)
 {
   if (!push)
   {
     if (oldContext.WorkflowState.StateId == WORKFLOWSTATEID_NEWSITEMS)
     {
       _selectedFeed = null;
     }
     else if (oldContext.WorkflowState.StateId == WORKFLOWSTATEID_NEWSITEMDETAIL)
     {
       _selectedItem = null;
     }
   }
 }
コード例 #6
0
ファイル: NewsModel.cs プロジェクト: HAF-Blade/MediaPortal-2
    public void Select(ListItem item)
    {
      if (item == null)
        return;

      var feed = item as NewsFeed;
      if (feed != null)
      {
        _selectedFeed = feed;

        int firstWordEnd = feed.Title.IndexOf(' ');
        string newStateLabel = firstWordEnd > 0 ? feed.Title.Substring(0, firstWordEnd) : feed.Title;
        ServiceRegistration.Get<IWorkflowManager>().NavigatePush(WORKFLOWSTATEID_NEWSITEMS, new NavigationContextConfig
        {
          NavigationContextDisplayLabel = newStateLabel
        });
      }
      else
      {
        var feedItem = item as NewsItem;
        if (feedItem != null)
        {
          _selectedItem = feedItem;
          ServiceRegistration.Get<IWorkflowManager>().NavigatePush(WORKFLOWSTATEID_NEWSITEMDETAIL, new NavigationContextConfig
          {
            NavigationContextDisplayLabel = feedItem.PublishDate.ToString("g", ServiceRegistration.Get<ILocalization>().CurrentCulture)
          });
        }
      }
    }