private void NotifyNewPosts(PostClass[] notifyPosts, string soundFile, int addCount, bool newMentions) { if (notifyPosts != null && notifyPosts.Any() && _configs.ReadOwnPost && notifyPosts.All(post => post.UserId == _tw.UserId || post.ScreenName == _tw.Username)) { return; } // 新着通知 if (IsBalloonRequired() && notifyPosts != null && notifyPosts.Length > 0) { // Growlは一個ずつばらして通知。ただし、3ポスト以上あるときはまとめる if (_configs.IsNotifyUseGrowl) { var sb = new StringBuilder(); bool reply = false; bool dm = false; foreach (var post in notifyPosts) { if (!(notifyPosts.Count() > 3)) { sb.Clear(); reply = false; dm = false; } if (post.IsReply && !post.IsExcludeReply) { reply = true; } if (post.IsDm) { dm = true; } if (sb.Length > 0) { sb.Append(Environment.NewLine); } switch (_configs.NameBalloon) { case NameBalloonEnum.UserID: sb.Append(post.ScreenName).Append(" : "); break; case NameBalloonEnum.NickName: sb.Append(post.Nickname).Append(" : "); break; } sb.Append(post.TextFromApi); if (notifyPosts.Count() > 3) { if (!ReferenceEquals(notifyPosts.Last(), post)) { continue; } } string notifyText = sb.ToString(); if (string.IsNullOrEmpty(notifyText)) { return; } var titleStr = GetNotifyTitlteText(addCount, reply, dm); var nt = dm ? GrowlHelper.NotifyType.DirectMessage : reply ? GrowlHelper.NotifyType.Reply : GrowlHelper.NotifyType.Notify; _growlHelper.Notify(nt, post.StatusId.ToString(), titleStr, notifyText, _iconDict[post.ImageUrl], post.ImageUrl); } } else { var sb = new StringBuilder(); bool reply = false; bool dm = false; foreach (var post in notifyPosts) { if (post.IsReply && !post.IsExcludeReply) { reply = true; } if (post.IsDm) { dm = true; } if (sb.Length > 0) { sb.Append(Environment.NewLine); } switch (_configs.NameBalloon) { case NameBalloonEnum.UserID: sb.Append(post.ScreenName).Append(" : "); break; case NameBalloonEnum.NickName: sb.Append(post.Nickname).Append(" : "); break; } sb.Append(post.TextFromApi); } string notifyText = sb.ToString(); if (string.IsNullOrEmpty(notifyText)) { return; } var titleStr = GetNotifyTitlteText(addCount, reply, dm); var notifyIcon = dm ? ToolTipIcon.Warning : reply ? ToolTipIcon.Warning : ToolTipIcon.Info; NotifyIcon1.BalloonTipTitle = titleStr; NotifyIcon1.BalloonTipText = notifyText; NotifyIcon1.BalloonTipIcon = notifyIcon; NotifyIcon1.ShowBalloonTip(500); } } // サウンド再生 if (!_isInitializing && _configs.PlaySound) { MyCommon.PlaySound(soundFile); } // mentions新着時に画面ブリンク if (!_isInitializing && _configs.BlinkNewMentions && newMentions && ActiveForm == null) { Win32Api.FlashMyWindow(Handle, Win32Api.FlashSpecification.FlashTray, 3); } }