リビジョン | 1639 (tree) |
---|---|
日時 | 2011-10-24 16:54:26 |
作者 | kiri_feather |
Growl通知を個別発言にばらして通知
Growlにユーザーのアイコンが表示されるように変更
@@ -196,7 +196,7 @@ | ||
196 | 196 | Return True |
197 | 197 | End Function |
198 | 198 | |
199 | - Public Sub Notify(ByVal notificationType As NotifyType, ByVal id As String, ByVal title As String, ByVal text As String) | |
199 | + Public Sub Notify(ByVal notificationType As NotifyType, ByVal id As String, ByVal title As String, ByVal text As String, Optional ByVal icon As Image = Nothing) | |
200 | 200 | If Not _initialized Then Return |
201 | 201 | Dim notificationName As String = "" |
202 | 202 | Select Case notificationType |
@@ -209,9 +209,18 @@ | ||
209 | 209 | Case NotifyType.UserStreamEvent |
210 | 210 | notificationName = "USERSTREAM_EVENT" |
211 | 211 | End Select |
212 | - | |
213 | - Dim n As Object = | |
214 | - _connector.GetType("Growl.Connector.Notification").InvokeMember( | |
212 | + Dim n As Object = Nothing | |
213 | + If icon IsNot Nothing Then | |
214 | + Dim gCore As Type = _core.GetType("Growl.CoreLibrary.Resource") | |
215 | + Dim res As Object = gCore.InvokeMember("op_Implicit", | |
216 | + BindingFlags.Public Or BindingFlags.Static Or BindingFlags.InvokeMethod, | |
217 | + Nothing, | |
218 | + Nothing, | |
219 | + New Object() {icon}) | |
220 | + Dim priority As Object = | |
221 | + _connector.GetType("Growl.Connector.Priority").InvokeMember( | |
222 | + "Normal", BindingFlags.GetField, Nothing, Nothing, Nothing) | |
223 | + n = _connector.GetType("Growl.Connector.Notification").InvokeMember( | |
215 | 224 | "Notification", |
216 | 225 | BindingFlags.CreateInstance, |
217 | 226 | Nothing, |
@@ -220,7 +229,23 @@ | ||
220 | 229 | notificationName, |
221 | 230 | id, |
222 | 231 | title, |
223 | - text}) | |
232 | + text, | |
233 | + res, | |
234 | + False, | |
235 | + priority, | |
236 | + "aaa"}) | |
237 | + Else | |
238 | + n = _connector.GetType("Growl.Connector.Notification").InvokeMember( | |
239 | + "Notification", | |
240 | + BindingFlags.CreateInstance, | |
241 | + Nothing, | |
242 | + _connector, | |
243 | + New Object() {_appName, | |
244 | + notificationName, | |
245 | + id, | |
246 | + title, | |
247 | + text}) | |
248 | + End If | |
224 | 249 | '_targetConnector.GetType.InvokeMember("Notify", BindingFlags.InvokeMethod, Nothing, _targetConnector, New Object() {n}) |
225 | 250 | Dim cc As Object = _connector.GetType("Growl.Connector.CallbackContext").InvokeMember( |
226 | 251 | Nothing, BindingFlags.CreateInstance, Nothing, _connector, |
@@ -1545,69 +1545,131 @@ | ||
1545 | 1545 | '新着通知 |
1546 | 1546 | If BalloonRequired() Then |
1547 | 1547 | If notifyPosts IsNot Nothing AndAlso notifyPosts.Length > 0 Then |
1548 | - Dim sb As New StringBuilder | |
1549 | - Dim reply As Boolean = False | |
1550 | - Dim dm As Boolean = False | |
1551 | - For Each post As PostClass In notifyPosts | |
1552 | - If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True | |
1553 | - If post.IsDm Then dm = True | |
1554 | - If sb.Length > 0 Then sb.Append(System.Environment.NewLine) | |
1555 | - Select Case SettingDialog.NameBalloon | |
1556 | - Case NameBalloonEnum.UserID | |
1557 | - sb.Append(post.ScreenName).Append(" : ") | |
1558 | - Case NameBalloonEnum.NickName | |
1559 | - sb.Append(post.Nickname).Append(" : ") | |
1560 | - End Select | |
1561 | - sb.Append(post.TextFromApi) | |
1562 | - Next | |
1563 | - 'If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = "" | |
1564 | - Dim title As New StringBuilder | |
1565 | - Dim ntIcon As ToolTipIcon | |
1566 | - Dim nt As GrowlHelper.NotifyType | |
1567 | - If SettingDialog.DispUsername Then | |
1568 | - title.Append(tw.Username) | |
1569 | - title.Append(" - ") | |
1570 | - Else | |
1571 | - 'title.Clear() | |
1572 | - End If | |
1573 | - If dm Then | |
1574 | - 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1575 | - 'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2 | |
1576 | - ntIcon = ToolTipIcon.Warning | |
1577 | - title.Append("Tween [DM] ") | |
1578 | - title.Append(My.Resources.RefreshDirectMessageText1) | |
1579 | - title.Append(" ") | |
1580 | - title.Append(addCount) | |
1581 | - title.Append(My.Resources.RefreshDirectMessageText2) | |
1582 | - nt = GrowlHelper.NotifyType.DirectMessage | |
1583 | - ElseIf reply Then | |
1584 | - 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1585 | - 'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1586 | - ntIcon = ToolTipIcon.Warning | |
1587 | - title.Append("Tween [Reply!] ") | |
1588 | - title.Append(My.Resources.RefreshTimelineText1) | |
1589 | - title.Append(" ") | |
1590 | - title.Append(addCount) | |
1591 | - title.Append(My.Resources.RefreshTimelineText2) | |
1592 | - nt = GrowlHelper.NotifyType.Reply | |
1593 | - Else | |
1594 | - 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info | |
1595 | - 'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1596 | - ntIcon = ToolTipIcon.Info | |
1597 | - title.Append("Tween ") | |
1598 | - title.Append(My.Resources.RefreshTimelineText1) | |
1599 | - title.Append(" ") | |
1600 | - title.Append(addCount) | |
1601 | - title.Append(My.Resources.RefreshTimelineText2) | |
1602 | - nt = GrowlHelper.NotifyType.Notify | |
1603 | - End If | |
1604 | - Dim bText As String = sb.ToString | |
1605 | - If String.IsNullOrEmpty(bText) Then Exit Sub | |
1606 | - 'NotifyIcon1.BalloonTipText = sb.ToString() | |
1607 | - 'NotifyIcon1.ShowBalloonTip(500) | |
1548 | + 'Growlは一個ずつばらして通知 | |
1608 | 1549 | If SettingDialog.IsNotifyUseGrowl Then |
1609 | - gh.Notify(nt, DateTime.Now.Ticks.ToString(), title.ToString(), bText) | |
1550 | + For Each post In notifyPosts | |
1551 | + Dim sb As New StringBuilder | |
1552 | + Dim reply As Boolean = False | |
1553 | + Dim dm As Boolean = False | |
1554 | + | |
1555 | + If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True | |
1556 | + If post.IsDm Then dm = True | |
1557 | + If sb.Length > 0 Then sb.Append(System.Environment.NewLine) | |
1558 | + Select Case SettingDialog.NameBalloon | |
1559 | + Case NameBalloonEnum.UserID | |
1560 | + sb.Append(post.ScreenName).Append(" : ") | |
1561 | + Case NameBalloonEnum.NickName | |
1562 | + sb.Append(post.Nickname).Append(" : ") | |
1563 | + End Select | |
1564 | + sb.Append(post.TextFromApi) | |
1565 | + | |
1566 | + Dim title As New StringBuilder | |
1567 | + Dim ntIcon As ToolTipIcon | |
1568 | + Dim nt As GrowlHelper.NotifyType | |
1569 | + If SettingDialog.DispUsername Then | |
1570 | + title.Append(tw.Username) | |
1571 | + title.Append(" - ") | |
1572 | + Else | |
1573 | + 'title.Clear() | |
1574 | + End If | |
1575 | + If dm Then | |
1576 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1577 | + 'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2 | |
1578 | + ntIcon = ToolTipIcon.Warning | |
1579 | + title.Append("Tween [DM] ") | |
1580 | + title.Append(My.Resources.RefreshDirectMessageText1) | |
1581 | + title.Append(" ") | |
1582 | + title.Append(addCount) | |
1583 | + title.Append(My.Resources.RefreshDirectMessageText2) | |
1584 | + nt = GrowlHelper.NotifyType.DirectMessage | |
1585 | + ElseIf reply Then | |
1586 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1587 | + 'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1588 | + ntIcon = ToolTipIcon.Warning | |
1589 | + title.Append("Tween [Reply!] ") | |
1590 | + title.Append(My.Resources.RefreshTimelineText1) | |
1591 | + title.Append(" ") | |
1592 | + title.Append(addCount) | |
1593 | + title.Append(My.Resources.RefreshTimelineText2) | |
1594 | + nt = GrowlHelper.NotifyType.Reply | |
1595 | + Else | |
1596 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info | |
1597 | + 'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1598 | + ntIcon = ToolTipIcon.Info | |
1599 | + title.Append("Tween ") | |
1600 | + title.Append(My.Resources.RefreshTimelineText1) | |
1601 | + title.Append(" ") | |
1602 | + title.Append(addCount) | |
1603 | + title.Append(My.Resources.RefreshTimelineText2) | |
1604 | + nt = GrowlHelper.NotifyType.Notify | |
1605 | + End If | |
1606 | + Dim bText As String = sb.ToString | |
1607 | + If String.IsNullOrEmpty(bText) Then Exit Sub | |
1608 | + | |
1609 | + gh.Notify(nt, DateTime.Now.Ticks.ToString(), title.ToString(), bText, Me.TIconDic(post.ImageUrl)) | |
1610 | + Next | |
1610 | 1611 | Else |
1612 | + Dim sb As New StringBuilder | |
1613 | + Dim reply As Boolean = False | |
1614 | + Dim dm As Boolean = False | |
1615 | + For Each post As PostClass In notifyPosts | |
1616 | + If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True | |
1617 | + If post.IsDm Then dm = True | |
1618 | + If sb.Length > 0 Then sb.Append(System.Environment.NewLine) | |
1619 | + Select Case SettingDialog.NameBalloon | |
1620 | + Case NameBalloonEnum.UserID | |
1621 | + sb.Append(post.ScreenName).Append(" : ") | |
1622 | + Case NameBalloonEnum.NickName | |
1623 | + sb.Append(post.Nickname).Append(" : ") | |
1624 | + End Select | |
1625 | + sb.Append(post.TextFromApi) | |
1626 | + | |
1627 | + Next | |
1628 | + 'If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = "" | |
1629 | + Dim title As New StringBuilder | |
1630 | + Dim ntIcon As ToolTipIcon | |
1631 | + Dim nt As GrowlHelper.NotifyType | |
1632 | + If SettingDialog.DispUsername Then | |
1633 | + title.Append(tw.Username) | |
1634 | + title.Append(" - ") | |
1635 | + Else | |
1636 | + 'title.Clear() | |
1637 | + End If | |
1638 | + If dm Then | |
1639 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1640 | + 'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2 | |
1641 | + ntIcon = ToolTipIcon.Warning | |
1642 | + title.Append("Tween [DM] ") | |
1643 | + title.Append(My.Resources.RefreshDirectMessageText1) | |
1644 | + title.Append(" ") | |
1645 | + title.Append(addCount) | |
1646 | + title.Append(My.Resources.RefreshDirectMessageText2) | |
1647 | + nt = GrowlHelper.NotifyType.DirectMessage | |
1648 | + ElseIf reply Then | |
1649 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning | |
1650 | + 'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1651 | + ntIcon = ToolTipIcon.Warning | |
1652 | + title.Append("Tween [Reply!] ") | |
1653 | + title.Append(My.Resources.RefreshTimelineText1) | |
1654 | + title.Append(" ") | |
1655 | + title.Append(addCount) | |
1656 | + title.Append(My.Resources.RefreshTimelineText2) | |
1657 | + nt = GrowlHelper.NotifyType.Reply | |
1658 | + Else | |
1659 | + 'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info | |
1660 | + 'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2 | |
1661 | + ntIcon = ToolTipIcon.Info | |
1662 | + title.Append("Tween ") | |
1663 | + title.Append(My.Resources.RefreshTimelineText1) | |
1664 | + title.Append(" ") | |
1665 | + title.Append(addCount) | |
1666 | + title.Append(My.Resources.RefreshTimelineText2) | |
1667 | + nt = GrowlHelper.NotifyType.Notify | |
1668 | + End If | |
1669 | + Dim bText As String = sb.ToString | |
1670 | + If String.IsNullOrEmpty(bText) Then Exit Sub | |
1671 | + 'NotifyIcon1.BalloonTipText = sb.ToString() | |
1672 | + 'NotifyIcon1.ShowBalloonTip(500) | |
1611 | 1673 | NotifyIcon1.BalloonTipTitle = title.ToString() |
1612 | 1674 | NotifyIcon1.BalloonTipText = bText |
1613 | 1675 | NotifyIcon1.BalloonTipIcon = ntIcon |