public void Render(bool Timer = false) { Stopwatch watch = Stopwatch.StartNew(); // Init & Get List of unique usernames / foreach loop. foreach (var u in Users.OrderBy(u => u.Item1)) { Console.WriteLine(u.Item1); foreach (var t in Tweets.Where(t => t.Item1 == u.Item1 || u.Item2.Contains(t.Item1))) { Console.WriteLine($"\t @{t.Item1}: {t.Item2}"); } } if (Timer) { Console.WriteLine($"\nRender() Time: {watch.ElapsedMilliseconds}ms | t:{watch.ElapsedTicks}"); } }
public List <Tweet> GetTweetByDate(DateTime startDate, DateTime endDate) { return(Tweets.Where(t => t.Stamp >= startDate && t.Stamp <= endDate).ToList()); }
/// <summary> /// ロードしたツイートを追加する /// </summary> /// <param name="newTweets"></param> public void AddTweets(Tweets newTweets) { Debug.WriteLine("AddTweets"); bool ageChanged = false; foreach (var tweet in this.tweets.Where(x => x.Age < 4)) { tweet.Age++; ageChanged = true; } // 重複チェックして、新着だけ取り出す Tweets uniqueTweets = new Tweets(); foreach (var tweet in newTweets.Where(x => tweets.FindId(x.Id) == null)) { tweet.Age = 0; uniqueTweets.Add(tweet); } // 追加するツイートがある? if (uniqueTweets.Count > 0) { if (tweetsPanel.TopItemIndex > 0) { AddNewTweets(uniqueTweets); } else { if (uniqueTweets.Count < tweetsPanel.VisibleTweetCount) { AddNewTweets(uniqueTweets); } else { double stopSec = 1; double divAdd = ((App.Settings.AutoReload - 2) / stopSec); DispatcherTimer dt = new DispatcherTimer(); int addCountPerOne = (int)Math.Ceiling(uniqueTweets.Count / Math.Max(1, divAdd)); if (addCountPerOne < 1) addCountPerOne = 1; dt.Interval = TimeSpan.FromSeconds(0); dt.Tick += (s, e) => { dt.Interval = TimeSpan.FromSeconds(stopSec); int oneIdx = Math.Max(0, uniqueTweets.Count - addCountPerOne); int oneCount = Math.Min(addCountPerOne, uniqueTweets.Count); AddNewTweets(uniqueTweets.GetRange(oneIdx, oneCount)); uniqueTweets.RemoveRange(oneIdx, oneCount); if (uniqueTweets.Count == 0) { dt.Stop(); } }; dt.Start(); } } } else if (ageChanged) { // 追加はないけど、Ageが変更された tweetsPanel.LayoutTweets(TweetsPanelLayoutMode.Relayout); } Debug.WriteLine("/AddTweets"); }