Exemple #1
0
        public void Initialize(Action <RowAction> rowActionCallBack)
        {
            SharedDispatcher.RunAsync(() =>
            {
                switch (NType)
                {
                case NotificationType.System:
                    BarColorBrush = (Application.Current.Resources["SystemNotificationBrush"] as SolidColorBrush).Color;
                    break;

                case NotificationType.Favorite:
                    BarColorBrush = (Application.Current.Resources["FavoriteForegroundBrush"] as SolidColorBrush).Color;
                    break;

                case NotificationType.Retweet:
                    BarColorBrush = (Application.Current.Resources["RetweetForegroundBrush"] as SolidColorBrush).Color;
                    break;

                case NotificationType.DirectMessage:
                    BarColorBrush = (Application.Current.Resources["DirectMessageForegroundBrush"] as SolidColorBrush).Color;
                    break;

                case NotificationType.Follow:
                    BarColorBrush = (Application.Current.Resources["DirectMessageForegroundBrush"] as SolidColorBrush).Color;
                    break;
                }
            });

            CommandInitialize();
        }
Exemple #2
0
        public virtual async Task GetStreamDelete(TweetDelete delete)
        {
            RowBase row = null;
            await Task.Run(() =>
            {
                foreach (var t in TimeLine)
                {
                    if (t is TimelineRow)
                    {
                        TimelineRow tr = (t as TimelineRow);
                        if (tr.Tweet.id_str == delete.status.id_str)
                        {
                            row = tr;
                        }
                    }
                    else if (t is DirectMessageRow)
                    {
                        DirectMessageRow tr = (t as DirectMessageRow);
                        if (tr.DirectMessage.id_str == delete.status.id_str)
                        {
                            row = tr;
                        }
                    }
                }
            });

            await SharedDispatcher.RunAsync(() =>
            {
                if (row != null)
                {
                    TimeLine.Remove(row);
                }
            });
        }
Exemple #3
0
        protected async Task InsertStreamInTimeLineAsync(RowBase row)
        {
            if (await IsAllFilterClearAsync(row.Tweet))
            {
                if (IsNewNotification == true)
                {
                    if (row is NotificationRow)
                    {
                        var r = row as NotificationRow;
                        timelineActionCallback(new TimelineAction(TimelineActionType.NewNotification, new NotificationMessage
                        {
                            Message      = r.Message,
                            TweetMessage = row.Tweet
                        }));
                    }
                    else
                    {
                        timelineActionCallback(new TimelineAction(TimelineActionType.NewNotification, new NotificationMessage
                        {
                            Message      = "Notification",
                            TweetMessage = row.Tweet
                        }));
                    }
                }
                await SharedDispatcher.RunAsync(() =>
                {
                    TimeLine.Insert(0, row);
                });

                await LiveTileImageUpdateAsync(row.Tweet);
            }
        }
Exemple #4
0
        private async Task LiveTileImageUpdateAsync(Tweet tweet)
        {
            if (tweet.entities != null && tweet.entities.media != null && tweet.entities.media.Count > 0)
            {
                await SharedDispatcher.RunAsync(() =>
                {
                    //テンプレートを取得してXMLを編集
                    XmlDocument doc = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage05);
                    doc.GetElementsByTagName("text")[0].InnerText = "@" + tweet.user.screen_name;
                    doc.GetElementsByTagName("text")[1].InnerText = tweet.text;
                    doc.GetElementsByTagName("image")[0].Attributes.GetNamedItem("src").NodeValue = tweet.entities.media.First().media_url;
                    doc.GetElementsByTagName("image")[1].Attributes.GetNamedItem("src").NodeValue = tweet.user.profile_image_url;

                    TileNotification notification = new TileNotification(doc);


                    notification.ExpirationTime = DateTimeOffset.UtcNow.AddDays(2);
                    //一意のタグを指定
                    notification.Tag = "wide" + liveTileCounter.ToString();
                    //通知を送信
                    TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();
                    updater.EnableNotificationQueueForWide310x150(true);

                    updater.Update(notification);


                    XmlDocument docLarge = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndTextOverlay03);
                    docLarge.GetElementsByTagName("text")[0].InnerText = "@" + tweet.user.screen_name;
                    docLarge.GetElementsByTagName("text")[1].InnerText = tweet.text;
                    docLarge.GetElementsByTagName("image")[0].Attributes.GetNamedItem("src").NodeValue = tweet.entities.media.First().media_url;

                    TileNotification notificationLarge = new TileNotification(docLarge);


                    notificationLarge.ExpirationTime = DateTimeOffset.UtcNow.AddDays(2);
                    //一意のタグを指定
                    notificationLarge.Tag = "large" + liveTileCounter.ToString();

                    //通知を送信
                    TileUpdater updaterLarge = TileUpdateManager.CreateTileUpdaterForApplication();

                    updaterLarge.EnableNotificationQueueForSquare310x310(true);

                    updaterLarge.Update(notificationLarge);
                    if (liveTileCounter > 6)
                    {
                        liveTileCounter = 0;
                    }
                    liveTileCounter++;
                });
            }
        }
Exemple #5
0
 public TimelineRow(Tweet tweet, string ownerScreenName, SettingData setting, Action <RowAction> actionCallback)
     : base(tweet, ownerScreenName, setting, actionCallback, RowType.Tweet)
 {
     if (tweet.retweeted_status == null)
     {
         this.RowType = RowType.Tweet;
         if (Tweet.text.Contains("@" + ownerScreenName))
         {
             SharedDispatcher.RunAsync(() =>
             {
                 BarColorBrush = (Application.Current.Resources["MentionForegroundBrush"] as SolidColorBrush).Color;
             });
         }
     }
     else
     {
         this.RowType = RowType.Retweet;
         SharedDispatcher.RunAsync(() =>
         {
             BarColorBrush = (Application.Current.Resources["RetweetForegroundBrush"] as SolidColorBrush).Color;
         });
     }
     Initialize(rowActionCallback);
 }
Exemple #6
0
        protected async Task InsertRestInTimeLineAsync(List <RowBase> tweetList)
        {
            if (tweetList != null)
            {
                List <RowBase> tempTweetList = new List <RowBase>();
                RowBase[]      tweetListCopy = null;
                await Task.Run(async() =>
                {
                    tweetList.Reverse();
                    tweetListCopy = new RowBase[TimeLine.Count];
                    TimeLine.CopyTo(tweetListCopy, 0);


                    foreach (var tweet in tweetList)
                    {
                        if (await IsAllFilterClearAsync(tweet.Tweet))
                        {
                            if (await isCompetition(tweetListCopy.ToList(), tweet.Tweet) == false)
                            {
                                tempTweetList.Add(tweet);
                            }
                        }
                    }
                });

                await SharedDispatcher.RunAsync(() =>
                {
                    foreach (var tweet in tempTweetList)
                    {
                        TimeLine.Insert(0, tweet);
                    }
                });

                //TimeLine.OrderBy(q => q.Tweet.created_at_time).Select(q => q);
            }
        }