private void NotifyNewPosts(PostClass[] notifyPosts, string soundFile, int addCount, bool newMentions) { if (notifyPosts != null && notifyPosts.Length > 0 && this.SettingDialog.ReadOwnPost && notifyPosts.All((post) => { return post.UserId == tw.UserId || post.ScreenName == tw.Username; })) { return; } //新着通知 if (BalloonRequired()) { if (notifyPosts != null && notifyPosts.Length > 0) { //Growlは一個ずつばらして通知。ただし、3ポスト以上あるときはまとめる if (SettingDialog.IsNotifyUseGrowl) { StringBuilder sb = new StringBuilder(); bool reply = false; bool dm = false; foreach (PostClass post in notifyPosts) { if (!(notifyPosts.Length > 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(System.Environment.NewLine); switch (SettingDialog.NameBalloon) { case MyCommon.NameBalloonEnum.UserID: sb.Append(post.ScreenName).Append(" : "); break; case MyCommon.NameBalloonEnum.NickName: sb.Append(post.Nickname).Append(" : "); break; } sb.Append(post.TextFromApi); if (notifyPosts.Length > 3) { if (notifyPosts.Last() != post) continue; } StringBuilder title = new StringBuilder(); GrowlHelper.NotifyType nt; if (SettingDialog.DispUsername) { title.Append(tw.Username); title.Append(" - "); } else { //title.Clear(); } if (dm) { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " [DM] " + Properties.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + Properties.Resources.RefreshDirectMessageText2; title.Append(Application.ProductName); title.Append(" [DM] "); title.Append(Properties.Resources.RefreshDirectMessageText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshDirectMessageText2); nt = GrowlHelper.NotifyType.DirectMessage; } else if (reply) { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " [Reply!] " + Properties.Resources.RefreshTimelineText1 + " " + addCount.ToString() + Properties.Resources.RefreshTimelineText2; title.Append(Application.ProductName); title.Append(" [Reply!] "); title.Append(Properties.Resources.RefreshTimelineText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshTimelineText2); nt = GrowlHelper.NotifyType.Reply; } else { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " " + Properties.Resources.RefreshTimelineText1 + " " + addCount.ToString() + Properties.Resources.RefreshTimelineText2; title.Append(Application.ProductName); title.Append(" "); title.Append(Properties.Resources.RefreshTimelineText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshTimelineText2); nt = GrowlHelper.NotifyType.Notify; } string bText = sb.ToString(); if (string.IsNullOrEmpty(bText)) return; gh.Notify(nt, post.StatusId.ToString(), title.ToString(), bText, this.TIconDic[post.ImageUrl], post.ImageUrl); } } else { StringBuilder sb = new StringBuilder(); bool reply = false; bool dm = false; foreach (PostClass post in notifyPosts) { if (post.IsReply && !post.IsExcludeReply) reply = true; if (post.IsDm) dm = true; if (sb.Length > 0) sb.Append(System.Environment.NewLine); switch (SettingDialog.NameBalloon) { case MyCommon.NameBalloonEnum.UserID: sb.Append(post.ScreenName).Append(" : "); break; case MyCommon.NameBalloonEnum.NickName: sb.Append(post.Nickname).Append(" : "); break; } sb.Append(post.TextFromApi); } //if (SettingDialog.DispUsername) { NotifyIcon1.BalloonTipTitle = tw.Username + " - "; } else { NotifyIcon1.BalloonTipTitle = ""; } StringBuilder title = new StringBuilder(); ToolTipIcon ntIcon; if (SettingDialog.DispUsername) { title.Append(tw.Username); title.Append(" - "); } else { //title.Clear(); } if (dm) { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " [DM] " + Properties.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + Properties.Resources.RefreshDirectMessageText2; ntIcon = ToolTipIcon.Warning; title.Append(Application.ProductName); title.Append(" [DM] "); title.Append(Properties.Resources.RefreshDirectMessageText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshDirectMessageText2); } else if (reply) { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " [Reply!] " + Properties.Resources.RefreshTimelineText1 + " " + addCount.ToString() + Properties.Resources.RefreshTimelineText2; ntIcon = ToolTipIcon.Warning; title.Append(Application.ProductName); title.Append(" [Reply!] "); title.Append(Properties.Resources.RefreshTimelineText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshTimelineText2); } else { //NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info; //NotifyIcon1.BalloonTipTitle += Application.ProductName + " " + Properties.Resources.RefreshTimelineText1 + " " + addCount.ToString() + Properties.Resources.RefreshTimelineText2; ntIcon = ToolTipIcon.Info; title.Append(Application.ProductName); title.Append(" "); title.Append(Properties.Resources.RefreshTimelineText1); title.Append(" "); title.Append(addCount); title.Append(Properties.Resources.RefreshTimelineText2); } string bText = sb.ToString(); if (string.IsNullOrEmpty(bText)) return; //NotifyIcon1.BalloonTipText = sb.ToString(); //NotifyIcon1.ShowBalloonTip(500); NotifyIcon1.BalloonTipTitle = title.ToString(); NotifyIcon1.BalloonTipText = bText; NotifyIcon1.BalloonTipIcon = ntIcon; NotifyIcon1.ShowBalloonTip(500); } } } //サウンド再生 if (!_initial && SettingDialog.PlaySound && !string.IsNullOrEmpty(soundFile)) { try { string dir = Application.StartupPath; if (Directory.Exists(Path.Combine(dir, "Sounds"))) { dir = Path.Combine(dir, "Sounds"); } using (SoundPlayer player = new SoundPlayer(Path.Combine(dir, soundFile))) { player.Play(); } } catch (Exception) { } } //mentions新着時に画面ブリンク if (!_initial && SettingDialog.BlinkNewMentions && newMentions && Form.ActiveForm == null) { Win32Api.FlashMyWindow(this.Handle, Win32Api.FlashSpecification.FlashTray, 3); } }