1 ' Tween - Client of Twitter
2 ' Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 ' (c) 2008-2011 Moz (@syo68k)
4 ' (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 ' (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 ' (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
9 ' This file is part of Tween.
11 ' This program is free software; you can redistribute it and/or modify it
12 ' under the terms of the GNU General Public License as published by the Free
13 ' Software Foundation; either version 3 of the License, or (at your option)
16 ' This program is distributed in the hope that it will be useful, but
17 ' WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 ' or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 ' You should have received a copy of the GNU General Public License along
22 ' with this program. If not, see <http://www.gnu.org/licenses/>, or write to
23 ' the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
24 ' Boston, MA 02110-1301, USA.
26 Imports System.Collections.Generic
27 Imports System.Collections.ObjectModel
28 Imports System.Linq.Expressions
29 Imports Tween.TweenCustomControl
30 Imports System.Text.RegularExpressions
31 Imports System.Web.HttpUtility
34 Imports System.Linq.Expressions.DynamicExpression
36 Public NotInheritable Class PostClass
38 Private _Nick As String
39 Private _textFromApi As String
40 Private _ImageUrl As String
41 Private _screenName As String
42 Private _createdAt As Date
43 Private _statusId As Long
44 Private _IsFav As Boolean
45 Private _text As String
46 Private _IsRead As Boolean
47 Private _IsReply As Boolean
48 Private _IsExcludeReply As Boolean
49 Private _IsProtect As Boolean
50 Private _IsOWL As Boolean
51 Private _IsMark As Boolean
52 Private _InReplyToUser As String
53 Private _InReplyToStatusId As Long
54 Private _Source As String
55 Private _SourceHtml As String
56 Private _ReplyToList As New List(Of String)
57 Private _IsMe As Boolean
58 Private _IsDm As Boolean
59 Private _statuses As Statuses = Statuses.None
60 Private _UserId As Long
61 Private _FilterHit As Boolean
62 Private _RetweetedBy As String = ""
63 Private _RetweetedId As Long = 0
64 Private _SearchTabName As String = ""
65 Private _IsDeleted As Boolean = False
66 Private _InReplyToUserId As Long = 0
67 Private _langauge As String = ""
78 Public Sub New(ByVal Nickname As String, _
79 ByVal textFromApi As String, _
80 ByVal text As String, _
81 ByVal ImageUrl As String, _
82 ByVal screenName As String, _
83 ByVal createdAt As Date, _
84 ByVal statusId As Long, _
85 ByVal IsFav As Boolean, _
86 ByVal IsRead As Boolean, _
87 ByVal IsReply As Boolean, _
88 ByVal IsExcludeReply As Boolean, _
89 ByVal IsProtect As Boolean, _
90 ByVal IsOwl As Boolean, _
91 ByVal IsMark As Boolean, _
92 ByVal InReplyToUser As String, _
93 ByVal InReplyToStatusId As Long, _
94 ByVal Source As String, _
95 ByVal SourceHtml As String, _
96 ByVal ReplyToList As List(Of String), _
97 ByVal IsMe As Boolean, _
98 ByVal IsDm As Boolean, _
99 ByVal userId As Long, _
100 ByVal FilterHit As Boolean, _
101 ByVal RetweetedBy As String, _
102 ByVal RetweetedId As Long)
104 _textFromApi = textFromApi
106 _screenName = screenName
107 _createdAt = createdAt
113 _IsExcludeReply = IsExcludeReply
114 _IsProtect = IsProtect
117 _InReplyToUser = InReplyToUser
118 _InReplyToStatusId = InReplyToStatusId
120 _SourceHtml = SourceHtml
121 _ReplyToList = ReplyToList
125 _FilterHit = FilterHit
126 _RetweetedBy = RetweetedBy
127 _RetweetedId = RetweetedId
133 Public Property Nickname() As String
137 Set(ByVal value As String)
141 Public Property TextFromApi() As String
145 Set(ByVal value As String)
149 Public Property ImageUrl() As String
153 Set(ByVal value As String)
157 Public Property ScreenName() As String
161 Set(ByVal value As String)
165 Public Property CreatedAt() As Date
169 Set(ByVal value As Date)
173 Public Property StatusId() As Long
177 Set(ByVal value As Long)
181 Public Property IsFav() As Boolean
183 If Me.RetweetedId > 0 AndAlso TabInformations.GetInstance.RetweetSource(Me.RetweetedId) IsNot Nothing Then
184 Return TabInformations.GetInstance.RetweetSource(Me.RetweetedId).IsFav
189 Set(ByVal value As Boolean)
191 If Me.RetweetedId > 0 AndAlso TabInformations.GetInstance.RetweetSource(Me.RetweetedId) IsNot Nothing Then
192 TabInformations.GetInstance.RetweetSource(Me.RetweetedId).IsFav = value
196 Public Property Text() As String
200 Set(ByVal value As String)
204 Public Property IsRead() As Boolean
208 Set(ByVal value As Boolean)
210 _statuses = _statuses Or Statuses.Read
212 _statuses = _statuses And Not Statuses.Read
217 Public Property IsReply() As Boolean
221 Set(ByVal value As Boolean)
225 Public Property IsExcludeReply() As Boolean
227 Return _IsExcludeReply
229 Set(ByVal value As Boolean)
230 _IsExcludeReply = value
233 Public Property IsProtect() As Boolean
237 Set(ByVal value As Boolean)
239 _statuses = _statuses Or Statuses.Protect
241 _statuses = _statuses And Not Statuses.Protect
246 Public Property IsOwl() As Boolean
250 Set(ByVal value As Boolean)
254 Public Property IsMark() As Boolean
258 Set(ByVal value As Boolean)
260 _statuses = _statuses Or Statuses.Mark
262 _statuses = _statuses And Not Statuses.Mark
267 Public Property InReplyToUser() As String
269 Return _InReplyToUser
271 Set(ByVal value As String)
272 _InReplyToUser = value
275 Public Property InReplyToStatusId() As Long
277 Return _InReplyToStatusId
279 Set(ByVal value As Long)
280 _InReplyToStatusId = value
284 Public Property InReplyToUserId() As Long
286 Return _InReplyToUserId
288 Set(ByVal value As Long)
289 _InReplyToUserId = value
292 Public Property Source() As String
296 Set(ByVal value As String)
300 Public Property SourceHtml() As String
304 Set(ByVal value As String)
308 Public Property ReplyToList() As List(Of String)
312 Set(ByVal value As List(Of String))
316 Public Property IsMe() As Boolean
320 Set(ByVal value As Boolean)
324 Public Property IsDm() As Boolean
328 Set(ByVal value As Boolean)
332 'Public ReadOnly Property StatusIndex() As Integer
337 Public Property UserId() As Long
341 Set(ByVal value As Long)
345 Public Property FilterHit() As Boolean
349 Set(ByVal value As Boolean)
353 Public Property RetweetedBy() As String
357 Set(ByVal value As String)
361 Public Property RetweetedId() As Long
365 Set(ByVal value As Long)
369 Public Property RelTabName() As String
371 Return _SearchTabName
373 Set(ByVal value As String)
374 _SearchTabName = value
377 Public Property IsDeleted As Boolean
381 Set(ByVal value As Boolean)
383 Me.InReplyToStatusId = 0
384 Me.InReplyToUser = ""
385 Me.InReplyToUserId = 0
387 Me.ReplyToList = New List(Of String)
393 Public Property Language As String
397 Set(ByVal value As String)
402 Public Property FavoritedCount As Integer
404 Public Function Copy() As PostClass
405 Dim post As PostClass = DirectCast(Me.Clone, PostClass)
406 post.ReplyToList = New List(Of String)(Me.ReplyToList)
410 Public Overrides Function Equals(ByVal obj As Object) As Boolean
411 If (obj Is Nothing) OrElse Not (Me.GetType() Is obj.GetType()) Then Return False
412 Return Me.Equals(CType(obj, PostClass))
415 Public Overloads Function Equals(ByVal other As PostClass) As Boolean
416 If other Is Nothing Then Return False
417 Return (Me.Nickname = other.Nickname) AndAlso
418 (Me.TextFromApi = other.TextFromApi) AndAlso
419 (Me.ImageUrl = other.ImageUrl) AndAlso
420 (Me.ScreenName = other.ScreenName) AndAlso
421 (Me.CreatedAt = other.CreatedAt) AndAlso
422 (Me.StatusId = other.StatusId) AndAlso
423 (Me.IsFav = other.IsFav) AndAlso
424 (Me.Text = other.Text) AndAlso
425 (Me.IsRead = other.IsRead) AndAlso
426 (Me.IsReply = other.IsReply) AndAlso
427 (Me.IsExcludeReply = other.IsExcludeReply) AndAlso
428 (Me.IsProtect = other.IsProtect) AndAlso
429 (Me.IsOwl = other.IsOwl) AndAlso
430 (Me.IsMark = other.IsMark) AndAlso
431 (Me.InReplyToUser = other.InReplyToUser) AndAlso
432 (Me.InReplyToStatusId = other.InReplyToStatusId) AndAlso
433 (Me.Source = other.Source) AndAlso
434 (Me.SourceHtml = other.SourceHtml) AndAlso
435 (Me.ReplyToList.Equals(other.ReplyToList)) AndAlso
436 (Me.IsMe = other.IsMe) AndAlso
437 (Me.IsDm = other.IsDm) AndAlso
438 (Me.UserId = other.UserId) AndAlso
439 (Me.FilterHit = other.FilterHit) AndAlso
440 (Me.RetweetedBy = other.RetweetedBy) AndAlso
441 (Me.RetweetedId = other.RetweetedId) AndAlso
442 (Me.RelTabName = other.RelTabName) AndAlso
443 (Me.IsDeleted = other.IsDeleted) AndAlso
444 (Me.InReplyToUserId = other.InReplyToUserId) AndAlso
445 (Me.Language = other.Language)
448 #Region "IClonable.Clone"
449 Private Function Clone() As Object Implements ICloneable.Clone
450 Return Me.MemberwiseClone()
455 Public NotInheritable Class TabInformations
456 '個別タブの情報をDictionaryで保持
457 Private _sorter As IdComparerClass
458 Private _tabs As New Dictionary(Of String, TabClass)
459 Private _statuses As New Dictionary(Of Long, PostClass)
460 Private _addedIds As List(Of Long)
461 Private _deletedIds As New List(Of Long)
462 Private _retweets As New Dictionary(Of Long, PostClass)
463 Private _removedTab As TabClass = Nothing
466 'AddPost(複数回) -> DistributePosts -> SubmitUpdate
469 Private _addCount As Integer
470 Private _soundFile As String
471 Private _notifyPosts As List(Of PostClass)
472 Private ReadOnly LockObj As New Object
473 Private ReadOnly LockUnread As New Object
475 Private Shared _instance As TabInformations = New TabInformations
478 Private _lists As New List(Of ListElement)
481 _sorter = New IdComparerClass()
484 Public Shared Function GetInstance() As TabInformations
485 Return _instance 'singleton
488 Public Property SubscribableLists() As List(Of ListElement)
492 Set(ByVal value As List(Of ListElement))
493 If value IsNot Nothing AndAlso value.Count > 0 Then
494 For Each tb As TabClass In Me.GetTabsByType(TabUsageType.Lists)
495 For Each list As ListElement In value
496 If tb.ListInfo.Id = list.Id Then
507 Public Sub AddTab(ByVal TabName As String, ByVal TabType As TabUsageType, ByVal List As ListElement)
508 _tabs.Add(TabName, New TabClass(TabName, TabType, List))
509 _tabs(TabName).Sorter.Mode = _sorter.Mode
510 _tabs(TabName).Sorter.Order = _sorter.Order
513 'Public Sub AddTab(ByVal TabName As String, ByVal Tab As TabClass)
514 ' _tabs.Add(TabName, Tab)
517 Public Sub RemoveTab(ByVal TabName As String)
519 If IsDefaultTab(TabName) Then Exit Sub '念のため
520 If Not _tabs(TabName).IsInnerStorageTabType Then
521 Dim homeTab As TabClass = GetTabByType(TabUsageType.Home)
522 Dim dmName As String = GetTabByType(TabUsageType.DirectMessage).TabName
524 For idx As Integer = 0 To _tabs(TabName).AllCount - 1
525 Dim exist As Boolean = False
526 Dim Id As Long = _tabs(TabName).GetId(idx)
527 If Id < 0 Then Continue For
528 For Each key As String In _tabs.Keys
529 If Not key = TabName AndAlso key <> dmName Then
530 If _tabs(key).Contains(Id) Then
536 If Not exist Then homeTab.Add(Id, _statuses(Id).IsRead, False)
539 If _removedTab IsNot Nothing Then _removedTab = Nothing
540 _removedTab = _tabs(TabName)
541 _tabs.Remove(TabName)
545 Public Property RemovedTab() As TabClass
549 Set(ByVal value As TabClass)
554 Public Function ContainsTab(ByVal TabText As String) As Boolean
555 Return _tabs.ContainsKey(TabText)
558 Public Function ContainsTab(ByVal ts As TabClass) As Boolean
559 Return _tabs.ContainsValue(ts)
562 Public Property Tabs() As Dictionary(Of String, TabClass)
566 Set(ByVal value As Dictionary(Of String, TabClass))
571 Public ReadOnly Property KeysTab() As Collections.Generic.Dictionary(Of String, TabClass).KeyCollection
577 Public Sub SortPosts()
578 For Each key As String In _tabs.Keys
583 Public Property SortOrder() As SortOrder
587 Set(ByVal value As SortOrder)
588 _sorter.Order = value
589 For Each key As String In _tabs.Keys
590 _tabs(key).Sorter.Order = value
595 Public Property SortMode() As IdComparerClass.ComparerMode
599 Set(ByVal value As IdComparerClass.ComparerMode)
601 For Each key As String In _tabs.Keys
602 _tabs(key).Sorter.Mode = value
607 Public Function ToggleSortOrder(ByVal SortMode As IdComparerClass.ComparerMode) As Windows.Forms.SortOrder
608 If _sorter.Mode = SortMode Then
609 If _sorter.Order = Windows.Forms.SortOrder.Ascending Then
610 _sorter.Order = Windows.Forms.SortOrder.Descending
612 _sorter.Order = Windows.Forms.SortOrder.Ascending
614 For Each key As String In _tabs.Keys
615 _tabs(key).Sorter.Order = _sorter.Order
618 _sorter.Mode = SortMode
619 _sorter.Order = Windows.Forms.SortOrder.Ascending
620 For Each key As String In _tabs.Keys
621 _tabs(key).Sorter.Mode = SortMode
622 _tabs(key).Sorter.Order = Windows.Forms.SortOrder.Ascending
629 Public ReadOnly Property RetweetSource(ByVal Id As Long) As PostClass
631 If _retweets.ContainsKey(Id) Then
639 Public Sub RemoveFavPost(ByVal Id As Long)
641 Dim post As PostClass = Nothing
642 Dim tab As TabClass = Me.GetTabByType(TabUsageType.Favorites)
643 Dim tn As String = tab.TabName
644 If _statuses.ContainsKey(Id) Then
647 Dim tType As TabUsageType = tab.TabType
648 If tab.Contains(Id) Then
649 If tab.UnreadManage AndAlso Not post.IsRead Then '未読管理
652 Me.SetNextUnreadId(Id, tab)
657 'FavタブからRetweet発言を削除する場合は、他の同一参照Retweetも削除
658 If tType = TabUsageType.Favorites AndAlso post.RetweetedId > 0 Then
659 For i As Integer = 0 To tab.AllCount - 1
660 Dim rPost As PostClass = Nothing
662 rPost = Me.Item(tn, i)
663 Catch ex As ArgumentOutOfRangeException
666 If rPost.RetweetedId > 0 AndAlso rPost.RetweetedId = post.RetweetedId Then
667 If tab.UnreadManage AndAlso Not rPost.IsRead Then '未読管理
670 Me.SetNextUnreadId(rPost.StatusId, tab)
673 tab.Remove(rPost.StatusId)
678 ''TabType=PublicSearchの場合(Postの保存先がTabClass内)
679 'If tab.Contains(StatusId) AndAlso _
680 ' (tab.TabType = TabUsageType.PublicSearch OrElse tab.TabType = TabUsageType.DirectMessage) Then
681 ' post = tab.Posts(StatusId)
682 ' If tab.UnreadManage AndAlso Not post.IsRead Then '未読管理
683 ' SyncLock LockUnread
684 ' tab.UnreadCount -= 1
685 ' Me.SetNextUnreadId(StatusId, tab)
688 ' tab.Remove(StatusId)
693 Public Sub RemovePostReserve(ByVal id As Long, ByRef post As PostClass)
696 Dim tmp As PostClass = Me.Item(id)
697 If tmp IsNot Nothing Then post = tmp.Copy
698 Me._deletedIds.Add(id)
703 Public Sub RemovePost(ByVal Id As Long)
705 Dim post As PostClass = Nothing
706 If _statuses.ContainsKey(Id) Then
709 For Each key As String In _tabs.Keys
710 Dim tab As TabClass = _tabs(key)
711 If tab.Contains(Id) Then
712 If tab.UnreadManage AndAlso Not post.IsRead Then '未読管理
715 Me.SetNextUnreadId(Id, tab)
723 For Each tb As TabClass In _tabs.Values
724 If tb.IsInnerStorageTabType AndAlso tb.Contains(Id) Then
726 If tb.UnreadManage AndAlso Not post.IsRead Then
729 Me.SetNextUnreadId(Id, tb)
738 Private Sub DeletePost(ByVal Id As Long)
740 Dim post As PostClass = Nothing
741 If _statuses.ContainsKey(Id) Then
743 post.IsDeleted = True
745 For Each tb As TabClass In Me.GetTabsInnerStorageType
746 If tb.Contains(Id) Then
748 post.IsDeleted = True
754 Public Function GetOldestUnreadIndex(ByVal TabName As String) As Integer
755 Dim tb As TabClass = _tabs(TabName)
756 If tb.OldestUnreadId > -1 AndAlso _
757 tb.Contains(tb.OldestUnreadId) AndAlso _
758 tb.UnreadCount > 0 Then
760 Dim isRead As Boolean
761 If Not tb.IsInnerStorageTabType Then
762 isRead = _statuses(tb.OldestUnreadId).IsRead
764 isRead = tb.Posts(tb.OldestUnreadId).IsRead
769 Me.SetNextUnreadId(-1, tb) '頭から探索
771 If tb.OldestUnreadId = -1 Then
774 Return tb.IndexOf(tb.OldestUnreadId)
777 Return tb.IndexOf(tb.OldestUnreadId) '最短経路
780 '一見未読なさそうだが、未読カウントはあるので探索
781 'If tb.UnreadCount > 0 Then
782 If Not (tb.UnreadManage AndAlso AppendSettingDialog.Instance.UnreadManage) Then Return -1
784 Me.SetNextUnreadId(-1, tb)
786 If tb.OldestUnreadId = -1 Then
789 Return tb.IndexOf(tb.OldestUnreadId)
797 Private Sub SetNextUnreadId(ByVal CurrentId As Long, ByVal Tab As TabClass)
798 'CurrentID:今既読にしたID(OldestIDの可能性あり)
799 '最古未読が設定されていて、既読の場合(1発言以上存在)
801 Dim posts As Dictionary(Of Long, PostClass)
802 If Not Tab.IsInnerStorageTabType Then
807 If Tab.OldestUnreadId > -1 AndAlso _
808 posts.ContainsKey(Tab.OldestUnreadId) AndAlso _
809 posts.Item(Tab.OldestUnreadId).IsRead AndAlso _
810 _sorter.Mode = IdComparerClass.ComparerMode.Id Then '次の未読探索
811 If Tab.UnreadCount = 0 Then
813 Tab.OldestUnreadId = -1
814 ElseIf Tab.OldestUnreadId = CurrentId AndAlso CurrentId > -1 Then
815 '最古IDを既読にしたタイミング→次のIDから続けて探索
816 Dim idx As Integer = Tab.IndexOf(CurrentId)
819 FindUnreadId(idx, Tab)
822 FindUnreadId(-1, Tab)
826 FindUnreadId(-1, Tab)
830 FindUnreadId(-1, Tab)
832 Catch ex As Generic.KeyNotFoundException
834 FindUnreadId(-1, Tab)
838 Private Sub FindUnreadId(ByVal StartIdx As Integer, ByVal Tab As TabClass)
839 If Tab.AllCount = 0 Then
840 Tab.OldestUnreadId = -1
844 Dim toIdx As Integer = 0
845 Dim stp As Integer = 1
846 Tab.OldestUnreadId = -1
847 If _sorter.Order = Windows.Forms.SortOrder.Ascending Then
848 If StartIdx = -1 Then
852 If StartIdx > Tab.AllCount - 1 Then StartIdx = Tab.AllCount - 1 '念のため
854 toIdx = Tab.AllCount - 1
855 If toIdx < 0 Then toIdx = 0 '念のため
858 If StartIdx = -1 Then
859 StartIdx = Tab.AllCount - 1
863 If StartIdx < 0 Then StartIdx = 0 '念のため
867 If Not Tab.IsInnerStorageTabType Then
868 For i As Integer = StartIdx To toIdx Step stp
869 If Not _statuses(Tab.GetId(i)).IsRead Then
870 Tab.OldestUnreadId = Tab.GetId(i)
875 For i As Integer = StartIdx To toIdx Step stp
876 If Not Tab.Posts(Tab.GetId(i)).IsRead Then
877 Tab.OldestUnreadId = Tab.GetId(i)
884 Public Function DistributePosts() As Integer
887 'If _addedIds Is Nothing Then Return 0
888 'If _addedIds.Count = 0 Then Return 0
890 If _addedIds Is Nothing Then _addedIds = New List(Of Long)
891 If _notifyPosts Is Nothing Then _notifyPosts = New List(Of PostClass)
892 Me.Distribute() 'タブに仮振分
893 Dim retCnt As Integer = _addedIds.Count
896 _addedIds = Nothing '後始末
901 Public Function SubmitUpdate(ByRef soundFile As String, ByRef notifyPosts As PostClass(), ByRef isMentionIncluded As Boolean, ByVal isUserStream As Boolean) As Integer
904 If _notifyPosts Is Nothing Then
906 notifyPosts = Nothing
910 For Each tb As TabClass In _tabs.Values
911 If tb.IsInnerStorageTabType Then
912 _addCount += tb.GetTemporaryCount
914 tb.AddSubmit(isMentionIncluded) '振分確定(各タブに反映)
916 If Not isUserStream OrElse Me.SortMode <> IdComparerClass.ComparerMode.Id Then
920 For Each id As Long In Me._deletedIds
921 'Me.DeletePost(StatusId)
924 Me._deletedIds.Clear()
927 soundFile = _soundFile
929 notifyPosts = _notifyPosts.ToArray()
931 _notifyPosts = Nothing
932 Dim retCnt As Integer = _addCount
934 Return retCnt '件数(EndUpdateの戻り値と同じ)
938 Private Sub Distribute()
939 '各タブのフィルターと照合。合致したらタブにID追加
940 '通知メッセージ用に、表示必要な発言リストと再生サウンドを返す
941 'notifyPosts = New List(Of PostClass)
942 Dim homeTab As TabClass = GetTabByType(TabUsageType.Home)
943 Dim replyTab As TabClass = GetTabByType(TabUsageType.Mentions)
944 Dim dmTab As TabClass = GetTabByType(TabUsageType.DirectMessage)
945 Dim favTab As TabClass = GetTabByType(TabUsageType.Favorites)
946 For Each id As Long In _addedIds
947 Dim post As PostClass = _statuses(id)
948 Dim add As Boolean = False '通知リスト追加フラグ
949 Dim mv As Boolean = False '移動フラグ(Recent追加有無)
950 Dim rslt As HITRESULT = HITRESULT.None
951 post.IsExcludeReply = False
952 For Each tn As String In _tabs.Keys
953 rslt = _tabs(tn).AddFiltered(post)
954 If rslt <> HITRESULT.None AndAlso rslt <> HITRESULT.Exclude Then
955 If rslt = HITRESULT.CopyAndMark Then post.IsMark = True 'マークあり
956 If rslt = HITRESULT.Move Then
960 If _tabs(tn).Notify Then add = True '通知あり
961 If Not _tabs(tn).SoundFile = "" AndAlso _soundFile = "" Then
962 _soundFile = _tabs(tn).SoundFile 'wavファイル(未設定の場合のみ)
964 post.FilterHit = True
966 If rslt = HITRESULT.Exclude AndAlso _tabs(tn).TabType = TabUsageType.Mentions Then
967 post.IsExcludeReply = True
969 post.FilterHit = False
972 If Not mv Then '移動されなかったらRecentに追加
973 homeTab.Add(post.StatusId, post.IsRead, True)
974 If Not homeTab.SoundFile = "" AndAlso _soundFile = "" Then _soundFile = homeTab.SoundFile
975 If homeTab.Notify Then add = True
977 If post.IsReply AndAlso Not post.IsExcludeReply Then '除外ルール適用のないReplyならReplyタブに追加
978 replyTab.Add(post.StatusId, post.IsRead, True)
979 If Not replyTab.SoundFile = "" Then _soundFile = replyTab.SoundFile
980 If replyTab.Notify Then add = True
982 If post.IsFav Then 'Fav済み発言だったらFavoritesタブに追加
983 If favTab.Contains(post.StatusId) Then
988 favTab.Add(post.StatusId, post.IsRead, True)
989 If Not String.IsNullOrEmpty(favTab.SoundFile) AndAlso String.IsNullOrEmpty(_soundFile) Then _soundFile = favTab.SoundFile
990 If favTab.Notify Then add = True
993 If add Then _notifyPosts.Add(post)
995 For Each tb As TabClass In _tabs.Values
996 If tb.IsInnerStorageTabType Then
998 If tb.GetTemporaryCount > 0 Then
999 For Each post As PostClass In tb.GetTemporaryPosts
1000 Dim exist As Boolean = False
1001 For Each npost As PostClass In _notifyPosts
1002 If npost.StatusId = post.StatusId Then
1007 If Not exist Then _notifyPosts.Add(post)
1009 If tb.SoundFile <> "" Then
1010 If tb.TabType = TabUsageType.DirectMessage OrElse _soundFile = "" Then
1011 _soundFile = tb.SoundFile
1020 Public Sub AddPost(ByVal Item As PostClass)
1022 If Item.RelTabName = "" Then
1023 If Not Item.IsDm Then
1024 If _statuses.ContainsKey(Item.StatusId) Then
1026 If Item.RetweetedId = 0 Then
1027 _statuses.Item(Item.StatusId).IsFav = True
1032 Exit Sub '追加済みなら何もしない
1035 If Item.IsFav AndAlso Item.RetweetedId > 0 Then Item.IsFav = False
1036 _statuses.Add(Item.StatusId, Item)
1038 If Item.RetweetedId > 0 Then
1041 If Item.IsFav AndAlso _retweets.ContainsKey(Item.StatusId) Then
1042 Exit Sub 'Fav済みのRetweet元発言は追加しない
1044 If _addedIds Is Nothing Then _addedIds = New List(Of Long) 'タブ追加用IDコレクション準備
1045 _addedIds.Add(Item.StatusId)
1048 Dim tb As TabClass = Me.GetTabByType(TabUsageType.DirectMessage)
1049 If tb.Contains(Item.StatusId) Then Exit Sub
1050 tb.AddPostToInnerStorage(Item)
1055 If Me.Tabs.ContainsKey(Item.RelTabName) Then
1056 tb = Me.Tabs(Item.RelTabName)
1060 If tb Is Nothing Then Exit Sub
1061 If tb.Contains(Item.StatusId) Then Exit Sub
1062 'tb.Add(Item.StatusId, Item.IsRead, True)
1063 tb.AddPostToInnerStorage(Item)
1068 Private Sub AddRetweet(ByVal item As PostClass)
1069 If _retweets.ContainsKey(item.RetweetedId) Then Exit Sub
1084 item.IsExcludeReply, _
1088 item.InReplyToUser, _
1089 item.InReplyToStatusId, _
1103 Public Sub SetReadAllTab(ByVal Read As Boolean, ByVal TabName As String, ByVal Index As Integer)
1104 'Read:True=既読へ False=未読へ
1105 Dim tb As TabClass = _tabs(TabName)
1107 If tb.UnreadManage = False Then Exit Sub '未読管理していなければ終了
1109 Dim Id As Long = tb.GetId(Index)
1110 If Id < 0 Then Exit Sub
1111 Dim post As PostClass
1112 If Not tb.IsInnerStorageTabType Then
1113 post = _statuses(Id)
1118 If post.IsRead = Read Then Exit Sub '状態変更なければ終了
1125 Me.SetNextUnreadId(Id, tb) '次の未読セット
1126 '他タブの最古未読IDはタブ切り替え時に。
1127 If tb.IsInnerStorageTabType Then
1129 If _statuses.ContainsKey(Id) AndAlso Not _statuses(Id).IsRead Then
1130 For Each key As String In _tabs.Keys
1131 If _tabs(key).UnreadManage AndAlso _
1132 _tabs(key).Contains(Id) AndAlso _
1133 Not _tabs(key).IsInnerStorageTabType Then
1134 _tabs(key).UnreadCount -= 1
1135 If _tabs(key).OldestUnreadId = Id Then _tabs(key).OldestUnreadId = -1
1138 _statuses(Id).IsRead = True
1142 For Each key As String In _tabs.Keys
1143 If key <> TabName AndAlso _
1144 _tabs(key).UnreadManage AndAlso _
1145 _tabs(key).Contains(Id) AndAlso _
1146 Not _tabs(key).IsInnerStorageTabType Then
1147 _tabs(key).UnreadCount -= 1
1148 If _tabs(key).OldestUnreadId = Id Then _tabs(key).OldestUnreadId = -1
1153 For Each key As String In _tabs.Keys
1154 If key <> TabName AndAlso
1155 _tabs(key).Contains(Id) AndAlso
1156 _tabs(key).IsInnerStorageTabType AndAlso
1157 Not _tabs(key).Posts(Id).IsRead Then
1158 If _tabs(key).UnreadManage Then
1159 _tabs(key).UnreadCount -= 1
1160 If _tabs(key).OldestUnreadId = Id Then _tabs(key).OldestUnreadId = -1
1162 _tabs(key).Posts(Id).IsRead = True
1167 If tb.OldestUnreadId > Id OrElse tb.OldestUnreadId = -1 Then tb.OldestUnreadId = Id
1168 If tb.IsInnerStorageTabType Then
1170 If _statuses.ContainsKey(Id) AndAlso _statuses(Id).IsRead Then
1171 For Each key As String In _tabs.Keys
1172 If _tabs(key).UnreadManage AndAlso _
1173 _tabs(key).Contains(Id) AndAlso _
1174 Not _tabs(key).IsInnerStorageTabType Then
1175 _tabs(key).UnreadCount += 1
1176 If _tabs(key).OldestUnreadId > Id Then _tabs(key).OldestUnreadId = Id
1179 _statuses(Id).IsRead = False
1183 For Each key As String In _tabs.Keys
1184 If key <> TabName AndAlso _
1185 _tabs(key).UnreadManage AndAlso _
1186 _tabs(key).Contains(Id) AndAlso _
1187 Not _tabs(key).IsInnerStorageTabType Then
1188 _tabs(key).UnreadCount += 1
1189 If _tabs(key).OldestUnreadId > Id Then _tabs(key).OldestUnreadId = Id
1194 For Each key As String In _tabs.Keys
1195 If key <> TabName AndAlso
1196 _tabs(key).Contains(Id) AndAlso
1197 _tabs(key).IsInnerStorageTabType AndAlso
1198 _tabs(key).Posts(Id).IsRead Then
1199 If _tabs(key).UnreadManage Then
1200 _tabs(key).UnreadCount += 1
1201 If _tabs(key).OldestUnreadId > Id Then _tabs(key).OldestUnreadId = Id
1203 _tabs(key).Posts(Id).IsRead = False
1210 ''' TODO: パフォーマンスを勘案して、戻すか決める
1211 Public Sub SetRead(ByVal Read As Boolean, ByVal TabName As String, ByVal Index As Integer)
1212 'Read:True=既読へ False=未読へ
1213 Dim tb As TabClass = _tabs(TabName)
1215 If tb.UnreadManage = False Then Exit Sub '未読管理していなければ終了
1217 Dim Id As Long = tb.GetId(Index)
1218 If Id < 0 Then Exit Sub
1219 Dim post As PostClass
1220 If Not tb.IsInnerStorageTabType Then
1221 post = _statuses(Id)
1226 If post.IsRead = Read Then Exit Sub '状態変更なければ終了
1228 post.IsRead = Read '指定の状態に変更
1233 Me.SetNextUnreadId(Id, tb) '次の未読セット
1234 '他タブの最古未読IDはタブ切り替え時に。
1235 If tb.IsInnerStorageTabType Then Exit Sub
1236 For Each key As String In _tabs.Keys
1237 If key <> TabName AndAlso _
1238 _tabs(key).UnreadManage AndAlso _
1239 _tabs(key).Contains(Id) AndAlso _
1240 Not _tabs(key).IsInnerStorageTabType Then
1241 _tabs(key).UnreadCount -= 1
1242 If _tabs(key).OldestUnreadId = Id Then _tabs(key).OldestUnreadId = -1
1247 If tb.OldestUnreadId > Id OrElse tb.OldestUnreadId = -1 Then tb.OldestUnreadId = Id
1248 If tb.IsInnerStorageTabType Then Exit Sub
1249 For Each key As String In _tabs.Keys
1250 If Not key = TabName AndAlso _
1251 _tabs(key).UnreadManage AndAlso _
1252 _tabs(key).Contains(Id) AndAlso _
1253 Not _tabs(key).IsInnerStorageTabType Then
1254 _tabs(key).UnreadCount += 1
1255 If _tabs(key).OldestUnreadId > Id Then _tabs(key).OldestUnreadId = Id
1262 Public Sub SetRead()
1263 Dim tb As TabClass = GetTabByType(TabUsageType.Home)
1264 If tb.UnreadManage = False Then Exit Sub
1267 For i As Integer = 0 To tb.AllCount - 1
1268 Dim id As Long = tb.GetId(i)
1269 If id < 0 Then Exit Sub
1270 If Not _statuses(id).IsReply AndAlso _
1271 Not _statuses(id).IsRead AndAlso _
1272 Not _statuses(id).FilterHit Then
1273 _statuses(id).IsRead = True
1274 Me.SetNextUnreadId(id, tb) '次の未読セット
1275 For Each key As String In _tabs.Keys
1276 If _tabs(key).UnreadManage AndAlso _
1277 _tabs(key).Contains(id) Then
1278 _tabs(key).UnreadCount -= 1
1279 If _tabs(key).OldestUnreadId = id Then _tabs(key).OldestUnreadId = -1
1287 Public ReadOnly Property Item(ByVal ID As Long) As PostClass
1289 If _statuses.ContainsKey(ID) Then Return _statuses(ID)
1290 For Each tb As TabClass In _tabs.Values
1291 If tb.IsInnerStorageTabType AndAlso _
1292 tb.Contains(ID) Then
1300 Public ReadOnly Property Item(ByVal TabName As String, ByVal Index As Integer) As PostClass
1302 'If Not _tabs.ContainsKey(TabName) Then Return Nothing
1303 If _tabs(TabName).IsInnerStorageTabType Then
1304 Return _tabs(TabName).Posts(_tabs(TabName).GetId(Index))
1306 Return _statuses(_tabs(TabName).GetId(Index))
1311 Public ReadOnly Property Item(ByVal TabName As String, ByVal StartIndex As Integer, ByVal EndIndex As Integer) As PostClass()
1313 Dim length As Integer = EndIndex - StartIndex + 1
1314 Dim posts() As PostClass = New PostClass(length - 1) {}
1315 If _tabs(TabName).IsInnerStorageTabType Then
1316 For i As Integer = 0 To length - 1
1317 posts(i) = _tabs(TabName).Posts(_tabs(TabName).GetId(StartIndex + i))
1320 For i As Integer = 0 To length - 1
1321 posts(i) = _statuses(_tabs(TabName).GetId(StartIndex + i))
1328 'Public ReadOnly Property ItemCount() As Integer
1331 ' Return _statuses.Count 'DM,公式検索は除く
1336 Public Function ContainsKey(ByVal Id As Long) As Boolean
1339 Return _statuses.ContainsKey(Id)
1343 Public Function ContainsKey(ByVal Id As Long, ByVal TabName As String) As Boolean
1346 If _tabs.ContainsKey(TabName) Then
1347 Return _tabs(TabName).Contains(Id)
1354 Public Sub SetUnreadManage(ByVal Manage As Boolean)
1356 For Each key As String In _tabs.Keys
1357 Dim tb As TabClass = _tabs(key)
1358 If tb.UnreadManage Then
1360 Dim cnt As Integer = 0
1361 Dim oldest As Long = Long.MaxValue
1362 Dim posts As Dictionary(Of Long, PostClass)
1363 If Not tb.IsInnerStorageTabType Then
1368 For Each id As Long In tb.BackupIds
1369 If Not posts(id).IsRead Then
1371 If oldest > id Then oldest = id
1374 If oldest = Long.MaxValue Then oldest = -1
1375 tb.OldestUnreadId = oldest
1376 tb.UnreadCount = cnt
1381 For Each key As String In _tabs.Keys
1382 Dim tb As TabClass = _tabs(key)
1383 If tb.UnreadManage AndAlso tb.UnreadCount > 0 Then
1386 tb.OldestUnreadId = -1
1393 Public Sub RenameTab(ByVal Original As String, ByVal NewName As String)
1394 Dim tb As TabClass = _tabs(Original)
1395 _tabs.Remove(Original)
1396 tb.TabName = NewName
1397 _tabs.Add(NewName, tb)
1400 Public Sub FilterAll()
1402 Dim tbr As TabClass = GetTabByType(TabUsageType.Home)
1403 Dim replyTab As TabClass = GetTabByType(TabUsageType.Mentions)
1404 For Each key As String In _tabs.Keys
1405 Dim tb As TabClass = _tabs(key)
1406 If tb.FilterModified Then
1407 tb.FilterModified = False
1408 Dim orgIds() As Long = tb.BackupIds()
1410 ''''''''''''''フィルター前のIDsを退避。どのタブにも含まれないidはrecentへ追加
1411 ''''''''''''''moveフィルターにヒットした際、recentに該当あればrecentから削除
1412 For Each id As Long In _statuses.Keys
1413 Dim post As PostClass = _statuses.Item(id)
1414 If post.IsDm Then Continue For
1415 Dim rslt As HITRESULT = HITRESULT.None
1416 rslt = tb.AddFiltered(post)
1418 Case HITRESULT.CopyAndMark
1419 post.IsMark = True 'マークあり
1420 post.FilterHit = True
1422 tbr.Remove(post.StatusId, post.IsRead)
1424 post.FilterHit = True
1427 post.FilterHit = True
1428 Case HITRESULT.Exclude
1429 If key = replyTab.TabName AndAlso post.IsReply Then post.IsExcludeReply = True
1430 If post.IsFav Then GetTabByType(TabUsageType.Favorites).Add(post.StatusId, post.IsRead, True)
1431 post.FilterHit = False
1433 If key = replyTab.TabName AndAlso post.IsReply Then replyTab.Add(post.StatusId, post.IsRead, True)
1434 If post.IsFav Then GetTabByType(TabUsageType.Favorites).Add(post.StatusId, post.IsRead, True)
1435 post.FilterHit = False
1438 tb.AddSubmit() '振分確定
1439 For Each id As Long In orgIds
1440 Dim hit As Boolean = False
1441 For Each tkey As String In _tabs.Keys
1442 If _tabs(tkey).Contains(id) Then
1447 If Not hit Then tbr.Add(id, _statuses(id).IsRead, False)
1455 Public Function GetId(ByVal TabName As String, ByVal IndexCollection As ListView.SelectedIndexCollection) As Long()
1456 If IndexCollection.Count = 0 Then Return Nothing
1458 Dim tb As TabClass = _tabs(TabName)
1459 Dim Ids(IndexCollection.Count - 1) As Long
1460 For i As Integer = 0 To Ids.Length - 1
1461 Ids(i) = tb.GetId(IndexCollection(i))
1466 Public Function GetId(ByVal TabName As String, ByVal Index As Integer) As Long
1467 Return _tabs(TabName).GetId(Index)
1470 Public Function IndexOf(ByVal TabName As String, ByVal Ids() As Long) As Integer()
1471 If Ids Is Nothing Then Return Nothing
1472 Dim idx(Ids.Length - 1) As Integer
1473 Dim tb As TabClass = _tabs(TabName)
1474 For i As Integer = 0 To Ids.Length - 1
1475 idx(i) = tb.IndexOf(Ids(i))
1480 Public Function IndexOf(ByVal TabName As String, ByVal Id As Long) As Integer
1481 Return _tabs(TabName).IndexOf(Id)
1484 Public Sub ClearTabIds(ByVal TabName As String)
1487 If Not _tabs(TabName).IsInnerStorageTabType Then
1488 For Each Id As Long In _tabs(TabName).BackupIds
1489 Dim Hit As Boolean = False
1490 For Each tb As TabClass In _tabs.Values
1491 If tb.Contains(Id) Then
1496 If Not Hit Then _statuses.Remove(Id)
1501 _tabs(TabName).ClearIDs()
1505 Public Sub SetTabUnreadManage(ByVal TabName As String, ByVal Manage As Boolean)
1506 Dim tb As TabClass = _tabs(TabName)
1509 Dim cnt As Integer = 0
1510 Dim oldest As Long = Long.MaxValue
1511 Dim posts As Dictionary(Of Long, PostClass)
1512 If Not tb.IsInnerStorageTabType Then
1517 For Each id As Long In tb.BackupIds
1518 If Not posts(id).IsRead Then
1520 If oldest > id Then oldest = id
1523 If oldest = Long.MaxValue Then oldest = -1
1524 tb.OldestUnreadId = oldest
1525 tb.UnreadCount = cnt
1527 tb.OldestUnreadId = -1
1531 tb.UnreadManage = Manage
1534 Public Sub RefreshOwl(ByVal follower As List(Of Long))
1536 If follower.Count > 0 Then
1537 For Each post As PostClass In _statuses.Values
1538 'If post.UserId = 0 OrElse post.IsDm Then Continue For
1542 post.IsOwl = Not follower.Contains(post.UserId)
1546 For Each id As Long In _statuses.Keys
1547 _statuses(id).IsOwl = False
1553 Public Function GetTabByType(ByVal tabType As TabUsageType) As TabClass
1554 'Home,Mentions,DM,Favは1つに制限する
1555 'その他のタイプを指定されたら、最初に合致したものを返す
1558 For Each tb As TabClass In _tabs.Values
1559 If tb IsNot Nothing AndAlso tb.TabType = tabType Then Return tb
1565 Public Function GetTabsByType(ByVal tabType As TabUsageType) As List(Of TabClass)
1569 Dim tbs As New List(Of TabClass)
1570 For Each tb As TabClass In _tabs.Values
1571 If (tabType And tb.TabType) = tb.TabType Then tbs.Add(tb)
1577 Public Function GetTabsInnerStorageType() As List(Of TabClass)
1581 Dim tbs As New List(Of TabClass)
1582 For Each tb As TabClass In _tabs.Values
1583 If tb.IsInnerStorageTabType Then tbs.Add(tb)
1589 Public Function GetTabByName(ByVal tabName As String) As TabClass
1591 If _tabs.ContainsKey(tabName) Then Return _tabs(tabName)
1597 Public Function IsDefaultTab(ByVal tabName As String) As Boolean
1598 If tabName IsNot Nothing AndAlso _
1599 _tabs.ContainsKey(tabName) AndAlso _
1600 (_tabs(tabName).TabType = TabUsageType.Home OrElse _
1601 _tabs(tabName).TabType = TabUsageType.Mentions OrElse _
1602 _tabs(tabName).TabType = TabUsageType.DirectMessage OrElse _
1603 _tabs(tabName).TabType = TabUsageType.Favorites) Then
1610 Public Function GetUniqueTabName() As String
1611 Dim tabNameTemp As String = "MyTab" + (_tabs.Count + 1).ToString
1612 For i As Integer = 2 To 100
1613 If _tabs.ContainsKey(tabNameTemp) Then
1614 tabNameTemp = "MyTab" + (_tabs.Count + i).ToString
1622 Public ReadOnly Property Posts() As Dictionary(Of Long, PostClass)
1630 Public NotInheritable Class TabClass
1631 Private _unreadManage As Boolean = False
1632 Private _filters As List(Of FiltersClass)
1633 Private _unreadCount As Integer = 0
1634 Private _ids As List(Of Long)
1635 Private _tmpIds As New List(Of TemporaryId)
1636 Private _tabType As TabUsageType = TabUsageType.Undefined
1637 Private _sorter As New IdComparerClass
1639 Private ReadOnly _lockObj As New Object
1641 Public Property User As String
1645 Private _searchLang As String = ""
1646 Private _searchWords As String = ""
1648 Public Property SearchLang() As String
1652 Set(ByVal value As String)
1657 Public Property SearchWords() As String
1661 Set(ByVal value As String)
1663 _searchWords = value.Trim
1666 Public Function GetSearchPage(ByVal count As Integer) As Integer
1667 Return ((_ids.Count \ count) + 1)
1669 Private _beforeQuery As New Dictionary(Of String, String)
1670 Public Sub SaveQuery(ByVal more As Boolean)
1671 Dim qry As New Dictionary(Of String, String)
1672 If String.IsNullOrEmpty(_searchWords) Then
1676 qry.Add("q", _searchWords)
1677 If Not String.IsNullOrEmpty(_searchLang) Then qry.Add("lang", _searchLang)
1681 Public Function IsQueryChanged() As Boolean
1682 Dim qry As New Dictionary(Of String, String)
1683 If Not String.IsNullOrEmpty(_searchWords) Then
1684 qry.Add("q", _searchWords)
1685 If Not String.IsNullOrEmpty(_searchLang) Then qry.Add("lang", _searchLang)
1687 If qry.Count <> _beforeQuery.Count Then Return True
1689 For Each kvp As KeyValuePair(Of String, String) In qry
1690 If Not _beforeQuery.ContainsKey(kvp.Key) OrElse _beforeQuery(kvp.Key) <> kvp.Value Then
1698 Private _listInfo As ListElement
1699 Public Property ListInfo() As ListElement
1703 Set(ByVal value As ListElement)
1709 <Xml.Serialization.XmlIgnore()> _
1710 Public Property RelationTargetPost() As PostClass
1712 <Xml.Serialization.XmlIgnore()> _
1713 Public Property OldestId() As Long = Long.MaxValue
1715 <Xml.Serialization.XmlIgnore()> _
1716 Public Property SinceId() As Long
1718 <Xml.Serialization.XmlIgnore()> _
1719 Public Property Posts() As New Dictionary(Of Long, PostClass)
1721 Public Function GetTemporaryPosts() As PostClass()
1722 Dim tempPosts As New List(Of PostClass)
1723 If _tmpIds.Count = 0 Then Return tempPosts.ToArray
1724 For Each tempId As TemporaryId In _tmpIds
1725 tempPosts.Add(_Posts(tempId.Id))
1727 Return tempPosts.ToArray
1730 Public Function GetTemporaryCount() As Integer
1731 Return _tmpIds.Count
1734 Private Structure TemporaryId
1736 Public Read As Boolean
1738 Public Sub New(ByVal argId As Long, ByVal argRead As Boolean)
1745 _filters = New List(Of FiltersClass)
1748 _unreadManage = True
1749 _ids = New List(Of Long)
1750 Me.OldestUnreadId = -1
1751 _tabType = TabUsageType.Undefined
1755 Public Sub New(ByVal TabName As String, ByVal TabType As TabUsageType, ByVal list As ListElement)
1757 _filters = New List(Of FiltersClass)
1760 _unreadManage = True
1761 _ids = New List(Of Long)
1762 Me.OldestUnreadId = -1
1765 If Me.IsInnerStorageTabType Then
1766 _sorter.posts = _Posts
1768 _sorter.posts = TabInformations.GetInstance.Posts
1773 _ids.Sort(_sorter.CmpMethod)
1776 Public ReadOnly Property Sorter() As IdComparerClass
1783 Private Sub Add(ByVal ID As Long, ByVal Read As Boolean)
1784 If Me._ids.Contains(ID) Then Exit Sub
1786 If Me.Sorter.Mode = IdComparerClass.ComparerMode.Id Then
1787 If Me.Sorter.Order = SortOrder.Ascending Then
1790 Me._ids.Insert(0, ID)
1796 If Not Read AndAlso Me._unreadManage Then
1797 Me._unreadCount += 1
1798 If Me.OldestUnreadId = -1 Then
1799 Me.OldestUnreadId = ID
1801 If ID < Me.OldestUnreadId Then Me.OldestUnreadId = ID
1806 Public Sub Add(ByVal ID As Long, ByVal Read As Boolean, ByVal Temporary As Boolean)
1807 If Not Temporary Then
1810 _tmpIds.Add(New TemporaryId(ID, Read))
1815 Public Function AddFiltered(ByVal post As PostClass) As HITRESULT
1816 If Me.IsInnerStorageTabType Then Return HITRESULT.None
1818 Dim rslt As HITRESULT = HITRESULT.None
1820 SyncLock Me._lockObj
1821 For Each ft As FiltersClass In _filters
1822 Select Case ft.IsHit(post) 'フィルタクラスでヒット判定
1825 If rslt <> HITRESULT.CopyAndMark Then rslt = HITRESULT.Copy
1826 Case HITRESULT.CopyAndMark
1827 rslt = HITRESULT.CopyAndMark
1829 rslt = HITRESULT.Move
1830 Case HITRESULT.Exclude
1831 rslt = HITRESULT.Exclude
1837 If rslt <> HITRESULT.None AndAlso rslt <> HITRESULT.Exclude Then
1838 _tmpIds.Add(New TemporaryId(post.StatusId, post.IsRead))
1841 Return rslt 'マーク付けは呼び出し元で行うこと
1845 Public Sub AddPostToInnerStorage(ByVal Post As PostClass)
1846 If _Posts.ContainsKey(Post.StatusId) Then Exit Sub
1847 _Posts.Add(Post.StatusId, Post)
1848 _tmpIds.Add(New TemporaryId(Post.StatusId, Post.IsRead))
1851 Public Sub AddSubmit(ByRef isMentionIncluded As Boolean)
1852 If _tmpIds.Count = 0 Then Exit Sub
1853 _tmpIds.Sort(Function(x As TemporaryId, y As TemporaryId) x.Id.CompareTo(y.Id))
1854 For Each tId As TemporaryId In _tmpIds
1855 If Me.TabType = TabUsageType.Mentions AndAlso TabInformations.GetInstance.Item(tId.Id).IsReply Then isMentionIncluded = True
1856 Me.Add(tId.Id, tId.Read)
1861 Public Sub AddSubmit()
1862 Dim mention As Boolean
1866 Public Sub Remove(ByVal Id As Long)
1867 If Not Me._ids.Contains(Id) Then Exit Sub
1869 If Me.IsInnerStorageTabType Then _Posts.Remove(Id)
1872 Public Sub Remove(ByVal Id As Long, ByVal Read As Boolean)
1873 If Not Me._ids.Contains(Id) Then Exit Sub
1875 If Not Read AndAlso Me._unreadManage Then
1876 Me._unreadCount -= 1
1877 Me.OldestUnreadId = -1
1881 If Me.IsInnerStorageTabType Then _Posts.Remove(Id)
1884 Public Property UnreadManage() As Boolean
1886 Return _unreadManage
1888 Set(ByVal value As Boolean)
1889 Me._unreadManage = value
1891 Me.OldestUnreadId = -1
1897 Public Property Notify() As Boolean
1899 Public Property SoundFile() As String = ""
1901 <Xml.Serialization.XmlIgnore()> _
1902 Public Property OldestUnreadId() As Long = -1
1904 <Xml.Serialization.XmlIgnore()> _
1905 Public Property UnreadCount() As Integer
1907 Return If(Me.UnreadManage AndAlso AppendSettingDialog.Instance.UnreadManage, _unreadCount, 0)
1909 Set(ByVal value As Integer)
1910 If value < 0 Then value = 0
1911 _unreadCount = value
1915 Public ReadOnly Property AllCount() As Integer
1917 Return Me._ids.Count
1921 Public Function GetFilters() As FiltersClass()
1922 SyncLock Me._lockObj
1923 Return _filters.ToArray()
1927 Public Sub RemoveFilter(ByVal filter As FiltersClass)
1928 SyncLock Me._lockObj
1929 _filters.Remove(filter)
1930 Me.FilterModified = True
1934 Public Function AddFilter(ByVal filter As FiltersClass) As Boolean
1935 SyncLock Me._lockObj
1936 If _filters.Contains(filter) Then Return False
1937 _filters.Add(filter)
1938 Me.FilterModified = True
1943 Public Sub EditFilter(ByVal original As FiltersClass, ByVal modified As FiltersClass)
1944 original.BodyFilter = modified.BodyFilter
1945 original.NameFilter = modified.NameFilter
1946 original.SearchBoth = modified.SearchBoth
1947 original.SearchUrl = modified.SearchUrl
1948 original.UseRegex = modified.UseRegex
1949 original.CaseSensitive = modified.CaseSensitive
1950 original.IsRt = modified.IsRt
1951 original.UseLambda = modified.UseLambda
1952 original.Source = modified.Source
1953 original.ExBodyFilter = modified.ExBodyFilter
1954 original.ExNameFilter = modified.ExNameFilter
1955 original.ExSearchBoth = modified.ExSearchBoth
1956 original.ExSearchUrl = modified.ExSearchUrl
1957 original.ExUseRegex = modified.ExUseRegex
1958 original.ExCaseSensitive = modified.ExCaseSensitive
1959 original.IsExRt = modified.IsExRt
1960 original.ExUseLambda = modified.ExUseLambda
1961 original.ExSource = modified.ExSource
1962 original.MoveFrom = modified.MoveFrom
1963 original.SetMark = modified.SetMark
1964 Me.FilterModified = True
1967 <Xml.Serialization.XmlIgnore()> _
1968 Public Property Filters() As List(Of FiltersClass)
1970 SyncLock Me._lockObj
1974 Set(ByVal value As List(Of FiltersClass))
1975 SyncLock Me._lockObj
1981 Public Property FilterArray() As FiltersClass()
1983 SyncLock Me._lockObj
1984 Return _filters.ToArray
1987 Set(ByVal value As FiltersClass())
1988 SyncLock Me._lockObj
1989 For Each filters As FiltersClass In value
1990 _filters.Add(filters)
1995 Public Function Contains(ByVal ID As Long) As Boolean
1996 Return _ids.Contains(ID)
1999 Public Sub ClearIDs()
2003 Me.OldestUnreadId = -1
2004 If _Posts IsNot Nothing Then
2009 Public Function GetId(ByVal Index As Integer) As Long
2010 Return If(Index < _ids.Count, _ids(Index), -1)
2013 Public Function IndexOf(ByVal ID As Long) As Integer
2014 Return _ids.IndexOf(ID)
2017 <Xml.Serialization.XmlIgnore()> _
2018 Public Property FilterModified() As Boolean
2020 Public Function BackupIds() As Long()
2021 Return _ids.ToArray()
2024 Public Property TabName() As String = ""
2026 Public Property TabType() As TabUsageType
2030 Set(ByVal value As TabUsageType)
2032 If Me.IsInnerStorageTabType Then
2033 _sorter.posts = _Posts
2035 _sorter.posts = TabInformations.GetInstance.Posts
2040 Public ReadOnly Property IsInnerStorageTabType As Boolean
2042 If _tabType = TabUsageType.PublicSearch OrElse
2043 _tabType = TabUsageType.DirectMessage OrElse
2044 _tabType = TabUsageType.Lists OrElse
2045 _tabType = TabUsageType.UserTimeline OrElse
2046 _tabType = TabUsageType.Related Then
2056 Public NotInheritable Class FiltersClass
2057 Implements System.IEquatable(Of FiltersClass)
2058 Private _name As String = ""
2059 Private _body As New List(Of String)
2060 Private _searchBoth As Boolean = True
2061 Private _searchUrl As Boolean = False
2062 Private _caseSensitive As Boolean = False
2063 Private _useRegex As Boolean = False
2064 Private _isRt As Boolean = False
2065 Private _source As String = ""
2066 Private _exname As String = ""
2067 Private _exbody As New List(Of String)
2068 Private _exsearchBoth As Boolean = True
2069 Private _exsearchUrl As Boolean = False
2070 Private _exuseRegex As Boolean = False
2071 Private _excaseSensitive As Boolean = False
2072 Private _isExRt As Boolean = False
2073 Private _exSource As String = ""
2074 Private _moveFrom As Boolean = False
2075 Private _setMark As Boolean = True
2076 Private _useLambda As Boolean = False
2077 Private _exuseLambda As Boolean = False
2084 Private Function MakeSummary() As String
2085 Dim fs As New StringBuilder()
2086 If Not String.IsNullOrEmpty(_name) OrElse _body.Count > 0 OrElse _isRt OrElse Not String.IsNullOrEmpty(_source) Then
2088 If Not String.IsNullOrEmpty(_name) Then
2089 fs.AppendFormat(My.Resources.SetFiltersText1, _name)
2091 fs.Append(My.Resources.SetFiltersText2)
2094 If _body.Count > 0 Then
2095 fs.Append(My.Resources.SetFiltersText3)
2096 For Each bf As String In _body
2101 fs.Append(My.Resources.SetFiltersText4)
2105 fs.Append(My.Resources.SetFiltersText5)
2107 fs.Append(My.Resources.SetFiltersText6)
2110 fs.Append(My.Resources.SetFiltersText7)
2113 fs.Append(My.Resources.SetFiltersText8)
2115 If _caseSensitive Then
2116 fs.Append(My.Resources.SetFiltersText13)
2122 fs.Append("LambdaExp/")
2124 If Not String.IsNullOrEmpty(_source) Then
2125 fs.AppendFormat("Src…{0}/", _source)
2130 If Not String.IsNullOrEmpty(_exname) OrElse _exbody.Count > 0 OrElse _isExRt OrElse Not String.IsNullOrEmpty(_exSource) Then
2132 fs.Append(My.Resources.SetFiltersText12)
2133 If _exsearchBoth Then
2134 If Not String.IsNullOrEmpty(_exname) Then
2135 fs.AppendFormat(My.Resources.SetFiltersText1, _exname)
2137 fs.Append(My.Resources.SetFiltersText2)
2140 If _exbody.Count > 0 Then
2141 fs.Append(My.Resources.SetFiltersText3)
2142 For Each bf As String In _exbody
2147 fs.Append(My.Resources.SetFiltersText4)
2150 If _exsearchBoth Then
2151 fs.Append(My.Resources.SetFiltersText5)
2153 fs.Append(My.Resources.SetFiltersText6)
2156 fs.Append(My.Resources.SetFiltersText7)
2158 If _exsearchUrl Then
2159 fs.Append(My.Resources.SetFiltersText8)
2161 If _excaseSensitive Then
2162 fs.Append(My.Resources.SetFiltersText13)
2167 If _exuseLambda Then
2168 fs.Append("LambdaExp/")
2170 If Not String.IsNullOrEmpty(_exSource) Then
2171 fs.AppendFormat("Src…{0}/", _exSource)
2179 fs.Append(My.Resources.SetFiltersText9)
2181 fs.Append(My.Resources.SetFiltersText11)
2183 If Not _moveFrom AndAlso _setMark Then
2184 fs.Append(My.Resources.SetFiltersText10)
2185 ElseIf Not _moveFrom Then
2191 Return fs.ToString()
2194 Public Property NameFilter() As String
2198 Set(ByVal value As String)
2203 Public Property ExNameFilter() As String
2207 Set(ByVal value As String)
2212 <Xml.Serialization.XmlIgnore()> _
2213 Public Property BodyFilter() As List(Of String)
2217 Set(ByVal value As List(Of String))
2222 Public Property BodyFilterArray() As String()
2224 Return _body.ToArray
2226 Set(ByVal value As String())
2227 _body = New List(Of String)
2228 For Each filter As String In value
2234 <Xml.Serialization.XmlIgnore()> _
2235 Public Property ExBodyFilter() As List(Of String)
2239 Set(ByVal value As List(Of String))
2244 Public Property ExBodyFilterArray() As String()
2246 Return _exbody.ToArray
2248 Set(ByVal value As String())
2249 _exbody = New List(Of String)
2250 For Each filter As String In value
2256 Public Property SearchBoth() As Boolean
2260 Set(ByVal value As Boolean)
2265 Public Property ExSearchBoth() As Boolean
2267 Return _exsearchBoth
2269 Set(ByVal value As Boolean)
2270 _exsearchBoth = value
2274 Public Property MoveFrom() As Boolean
2278 Set(ByVal value As Boolean)
2283 Public Property SetMark() As Boolean
2287 Set(ByVal value As Boolean)
2292 Public Property SearchUrl() As Boolean
2296 Set(ByVal value As Boolean)
2301 Public Property ExSearchUrl() As Boolean
2305 Set(ByVal value As Boolean)
2306 _exsearchUrl = value
2310 Public Property CaseSensitive() As Boolean
2312 Return _caseSensitive
2314 Set(ByVal value As Boolean)
2315 _caseSensitive = value
2319 Public Property ExCaseSensitive() As Boolean
2321 Return _excaseSensitive
2323 Set(ByVal value As Boolean)
2324 _excaseSensitive = value
2328 Public Property UseLambda() As Boolean
2332 Set(ByVal value As Boolean)
2337 Public Property ExUseLambda() As Boolean
2341 Set(ByVal value As Boolean)
2342 _exuseLambda = value
2346 Public Property UseRegex() As Boolean
2350 Set(ByVal value As Boolean)
2355 Public Property ExUseRegex() As Boolean
2359 Set(ByVal value As Boolean)
2364 Public Property IsRt() As Boolean
2368 Set(ByVal value As Boolean)
2373 Public Property IsExRt() As Boolean
2377 Set(ByVal value As Boolean)
2382 Public Property Source() As String
2386 Set(ByVal value As String)
2391 Public Property ExSource() As String
2395 Set(ByVal value As String)
2400 Public Overrides Function ToString() As String
2401 Return MakeSummary()
2404 Public Function ExecuteLambdaExpression(ByVal expr As String, ByVal post As PostClass) As Boolean
2405 Dim dlg As [Delegate]
2406 Dim exp As LambdaExpression
2407 exp = ParseLambda(Of PostClass, Boolean)(expr, post)
2409 Return DirectCast(dlg.DynamicInvoke(post), Boolean)
2412 Public Function IsHit(ByVal post As PostClass) As HITRESULT
2413 Dim bHit As Boolean = True
2415 Dim tSource As String
2418 tSource = post.SourceHtml
2420 tBody = post.TextFromApi
2421 tSource = post.Source
2424 Dim compOpt As System.StringComparison
2425 Dim rgOpt As System.Text.RegularExpressions.RegexOptions
2426 If _caseSensitive Then
2427 compOpt = StringComparison.Ordinal
2428 rgOpt = RegexOptions.None
2430 compOpt = StringComparison.OrdinalIgnoreCase
2431 rgOpt = RegexOptions.IgnoreCase
2434 If String.IsNullOrEmpty(_name) OrElse
2435 (Not _useRegex AndAlso
2436 (post.ScreenName.Equals(_name, compOpt) OrElse
2437 post.RetweetedBy.Equals(_name, compOpt)
2441 (Regex.IsMatch(post.ScreenName, _name, rgOpt) OrElse
2442 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso Regex.IsMatch(post.RetweetedBy, _name, rgOpt))
2446 If Not ExecuteLambdaExpression(_body.Item(0), post) Then bHit = False
2448 For Each fs As String In _body
2450 If Not Regex.IsMatch(tBody, fs, rgOpt) Then bHit = False
2452 If _caseSensitive Then
2453 If Not tBody.Contains(fs) Then bHit = False
2455 If Not tBody.ToLower().Contains(fs.ToLower()) Then bHit = False
2458 If Not bHit Then Exit For
2466 If Not ExecuteLambdaExpression(_body.Item(0), post) Then bHit = False
2468 For Each fs As String In _body
2470 If Not (Regex.IsMatch(post.ScreenName, fs, rgOpt) OrElse
2471 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso Regex.IsMatch(post.RetweetedBy, fs, rgOpt)) OrElse
2472 Regex.IsMatch(tBody, fs, rgOpt)) Then bHit = False
2474 If _caseSensitive Then
2475 If Not (post.ScreenName.Contains(fs) OrElse _
2476 post.RetweetedBy.Contains(fs) OrElse _
2477 tBody.Contains(fs)) Then bHit = False
2479 If Not (post.ScreenName.ToLower().Contains(fs.ToLower()) OrElse _
2480 post.RetweetedBy.ToLower().Contains(fs.ToLower()) OrElse _
2481 tBody.ToLower().Contains(fs.ToLower())) Then bHit = False
2484 If Not bHit Then Exit For
2489 If post.RetweetedId = 0 Then bHit = False
2491 If Not String.IsNullOrEmpty(_source) Then
2493 If Not Regex.IsMatch(tSource, _source, rgOpt) Then bHit = False
2495 If Not tSource.Equals(_source, compOpt) Then bHit = False
2500 If _exsearchUrl Then
2502 tSource = post.SourceHtml
2504 tBody = post.TextFromApi
2505 tSource = post.Source
2508 Dim exFlag As Boolean = False
2509 If Not String.IsNullOrEmpty(_exname) OrElse _exbody.Count > 0 Then
2510 If _excaseSensitive Then
2511 compOpt = StringComparison.Ordinal
2512 rgOpt = RegexOptions.None
2514 compOpt = StringComparison.OrdinalIgnoreCase
2515 rgOpt = RegexOptions.IgnoreCase
2517 If _exsearchBoth Then
2518 If String.IsNullOrEmpty(_exname) OrElse
2519 (Not _exuseRegex AndAlso
2520 (post.ScreenName.Equals(_exname, compOpt) OrElse
2521 post.RetweetedBy.Equals(_exname, compOpt)
2524 (_exuseRegex AndAlso _
2525 (Regex.IsMatch(post.ScreenName, _exname, rgOpt) OrElse _
2526 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso Regex.IsMatch(post.RetweetedBy, _exname, rgOpt))
2529 If _exbody.Count > 0 Then
2530 If _exuseLambda Then
2531 If ExecuteLambdaExpression(_exbody.Item(0), post) Then exFlag = True
2533 For Each fs As String In _exbody
2535 If Regex.IsMatch(tBody, fs, rgOpt) Then exFlag = True
2537 If _excaseSensitive Then
2538 If tBody.Contains(fs) Then exFlag = True
2540 If tBody.ToLower().Contains(fs.ToLower()) Then exFlag = True
2543 If exFlag Then Exit For
2551 If _exuseLambda Then
2552 If ExecuteLambdaExpression(_exbody.Item(0), post) Then exFlag = True
2554 For Each fs As String In _exbody
2556 If Regex.IsMatch(post.ScreenName, fs, rgOpt) OrElse
2557 (Not String.IsNullOrEmpty(post.RetweetedBy) AndAlso Regex.IsMatch(post.RetweetedBy, fs, rgOpt)) OrElse
2558 Regex.IsMatch(tBody, fs, rgOpt) Then exFlag = True
2560 If _excaseSensitive Then
2561 If post.ScreenName.Contains(fs) OrElse _
2562 post.RetweetedBy.Contains(fs) OrElse _
2563 tBody.Contains(fs) Then exFlag = True
2565 If post.ScreenName.ToLower().Contains(fs.ToLower()) OrElse _
2566 post.RetweetedBy.ToLower().Contains(fs.ToLower()) OrElse _
2567 tBody.ToLower().Contains(fs.ToLower()) Then exFlag = True
2570 If exFlag Then Exit For
2576 If post.RetweetedId > 0 Then exFlag = True
2578 If Not String.IsNullOrEmpty(_exSource) Then
2580 If Regex.IsMatch(tSource, _exSource, rgOpt) Then exFlag = True
2582 If tSource.Equals(_exSource, compOpt) Then exFlag = True
2586 If String.IsNullOrEmpty(_name) AndAlso _body.Count = 0 AndAlso Not _isRt AndAlso String.IsNullOrEmpty(_source) Then
2592 Return HITRESULT.Move
2595 Return HITRESULT.CopyAndMark
2597 Return HITRESULT.Copy
2600 Return HITRESULT.Exclude
2604 Return HITRESULT.Exclude
2606 Return HITRESULT.None
2610 Return HITRESULT.None
2614 Public Overloads Function Equals(ByVal other As FiltersClass) As Boolean _
2615 Implements System.IEquatable(Of Tween.FiltersClass).Equals
2617 If Me.BodyFilter.Count <> other.BodyFilter.Count Then Return False
2618 If Me.ExBodyFilter.Count <> other.ExBodyFilter.Count Then Return False
2619 For i As Integer = 0 To Me.BodyFilter.Count - 1
2620 If Me.BodyFilter(i) <> other.BodyFilter(i) Then Return False
2622 For i As Integer = 0 To Me.ExBodyFilter.Count - 1
2623 If Me.ExBodyFilter(i) <> other.ExBodyFilter(i) Then Return False
2626 Return (Me.MoveFrom = other.MoveFrom) And
2627 (Me.SetMark = other.SetMark) And
2628 (Me.NameFilter = other.NameFilter) And
2629 (Me.SearchBoth = other.SearchBoth) And
2630 (Me.SearchUrl = other.SearchUrl) And
2631 (Me.UseRegex = other.UseRegex) And
2632 (Me.ExNameFilter = other.ExNameFilter) And
2633 (Me.ExSearchBoth = other.ExSearchBoth) And
2634 (Me.ExSearchUrl = other.ExSearchUrl) And
2635 (Me.ExUseRegex = other.ExUseRegex) And
2636 (Me.IsRt = other.IsRt) And
2637 (Me.Source = other.Source) And
2638 (Me.IsExRt = other.IsExRt) And
2639 (Me.ExSource = other.ExSource) And
2640 (Me.UseLambda = other.UseLambda) And
2641 (Me.ExUseLambda = other.ExUseLambda)
2644 Public Function CopyTo(ByVal destination As FiltersClass) As FiltersClass
2646 If Me.BodyFilter.Count > 0 Then
2647 For Each flt As String In Me.BodyFilter
2648 destination.BodyFilter.Add(String.Copy(flt))
2652 If Me.ExBodyFilter.Count > 0 Then
2653 For Each flt As String In Me.ExBodyFilter
2654 destination.ExBodyFilter.Add(String.Copy(flt))
2658 destination.MoveFrom = Me.MoveFrom
2659 destination.SetMark = Me.SetMark
2660 destination.NameFilter = Me.NameFilter
2661 destination.SearchBoth = Me.SearchBoth
2662 destination.SearchUrl = Me.SearchUrl
2663 destination.UseRegex = Me.UseRegex
2664 destination.ExNameFilter = Me.ExNameFilter
2665 destination.ExSearchBoth = Me.ExSearchBoth
2666 destination.ExSearchUrl = Me.ExSearchUrl
2667 destination.ExUseRegex = Me.ExUseRegex
2668 destination.IsRt = Me.IsRt
2669 destination.Source = Me.Source
2670 destination.IsExRt = Me.IsExRt
2671 destination.ExSource = Me.ExSource
2672 destination.UseLambda = Me.UseLambda
2673 destination.ExUseLambda = Me.ExUseLambda
2677 Public Overrides Function Equals(ByVal obj As Object) As Boolean
2678 If (obj Is Nothing) OrElse Not (Me.GetType() Is obj.GetType()) Then Return False
2679 Return Me.Equals(CType(obj, FiltersClass))
2682 Public Overrides Function GetHashCode() As Integer
2683 Return Me.MoveFrom.GetHashCode Xor
2684 Me.SetMark.GetHashCode Xor
2685 Me.BodyFilter.GetHashCode Xor
2686 Me.NameFilter.GetHashCode Xor
2687 Me.SearchBoth.GetHashCode Xor
2688 Me.SearchUrl.GetHashCode Xor
2689 Me.UseRegex.GetHashCode Xor
2690 Me.ExBodyFilter.GetHashCode Xor
2691 Me.ExNameFilter.GetHashCode Xor
2692 Me.ExSearchBoth.GetHashCode Xor
2693 Me.ExSearchUrl.GetHashCode Xor
2694 Me.ExUseRegex.GetHashCode Xor
2695 Me.IsRt.GetHashCode Xor
2696 Me.Source.GetHashCode Xor
2697 Me.IsExRt.GetHashCode Xor
2698 Me.ExSource.GetHashCode Xor
2699 Me.UseLambda.GetHashCode Xor
2700 Me.ExUseLambda.GetHashCode
2705 Public NotInheritable Class IdComparerClass
2706 Implements IComparer(Of Long)
2711 Public Enum ComparerMode
2719 Private _order As SortOrder
2720 Private _mode As ComparerMode
2721 Private _statuses As Dictionary(Of Long, PostClass)
2722 Private _CmpMethod As Comparison(Of Long)
2725 ''' 昇順か降順か Setの際は同時に比較関数の切り替えを行う
2727 Public Property Order() As SortOrder
2731 Set(ByVal Value As SortOrder)
2733 SetCmpMethod(_mode, _order)
2738 ''' 並び替えの方法 Setの際は同時に比較関数の切り替えを行う
2740 Public Property Mode() As ComparerMode
2744 Set(ByVal Value As ComparerMode)
2746 SetCmpMethod(_mode, _order)
2751 ''' ListViewItemComparerクラスのコンストラクタ(引数付は未使用)
2753 ''' <param name="col">並び替える列番号</param>
2754 ''' <param name="ord">昇順か降順か</param>
2755 ''' <param name="cmod">並び替えの方法</param>
2758 _order = SortOrder.Ascending
2759 _mode = ComparerMode.Id
2760 SetCmpMethod(_mode, _order)
2763 Public WriteOnly Property posts() As Dictionary(Of Long, PostClass)
2764 Set(ByVal value As Dictionary(Of Long, PostClass))
2769 ' 指定したソートモードとソートオーダーに従い使用する比較関数のアドレスを返す
2770 Public Overloads ReadOnly Property CmpMethod(ByVal _sortmode As ComparerMode, ByVal _sortorder As SortOrder) As Comparison(Of Long)
2772 Dim _method As Comparison(Of Long) = Nothing
2773 If _sortorder = SortOrder.Ascending Then
2775 Select Case _sortmode
2776 Case ComparerMode.Data
2777 _method = AddressOf Compare_ModeData_Ascending
2778 Case ComparerMode.Id
2779 _method = AddressOf Compare_ModeId_Ascending
2780 Case ComparerMode.Name
2781 _method = AddressOf Compare_ModeName_Ascending
2782 Case ComparerMode.Nickname
2783 _method = AddressOf Compare_ModeNickName_Ascending
2784 Case ComparerMode.Source
2785 _method = AddressOf Compare_ModeSource_Ascending
2789 Select Case _sortmode
2790 Case ComparerMode.Data
2791 _method = AddressOf Compare_ModeData_Descending
2792 Case ComparerMode.Id
2793 _method = AddressOf Compare_ModeId_Descending
2794 Case ComparerMode.Name
2795 _method = AddressOf Compare_ModeName_Descending
2796 Case ComparerMode.Nickname
2797 _method = AddressOf Compare_ModeNickName_Descending
2798 Case ComparerMode.Source
2799 _method = AddressOf Compare_ModeSource_Descending
2806 ' ソートモードとソートオーダーに従い使用する比較関数のアドレスを返す
2807 ' (overload 現在の使用中の比較関数のアドレスを返す)
2808 Public Overloads ReadOnly Property CmpMethod() As Comparison(Of Long)
2814 ' ソートモードとソートオーダーに従い比較関数のアドレスを切り替え
2815 Private Sub SetCmpMethod(ByVal mode As ComparerMode, ByVal order As SortOrder)
2816 _CmpMethod = Me.CmpMethod(mode, order)
2819 'xがyより小さいときはマイナスの数、大きいときはプラスの数、
2820 '同じときは0を返す (こちらは未使用 一応比較関数群呼び出しの形のまま残しておく)
2821 Public Function Compare(ByVal x As Long, ByVal y As Long) _
2822 As Integer Implements IComparer(Of Long).Compare
2823 Return _CmpMethod(x, y)
2826 ' 比較用関数群 いずれもステータスIDの順序を考慮する
2828 Public Function Compare_ModeData_Ascending(ByVal x As Long, ByVal y As Long) As Integer
2829 Dim result As Integer = String.Compare(_statuses.Item(x).TextFromApi, _statuses.Item(y).TextFromApi)
2830 If result = 0 Then result = x.CompareTo(y)
2835 Public Function Compare_ModeData_Descending(ByVal x As Long, ByVal y As Long) As Integer
2836 Dim result As Integer = String.Compare(_statuses.Item(y).TextFromApi, _statuses.Item(x).TextFromApi)
2837 If result = 0 Then result = y.CompareTo(x)
2842 Public Function Compare_ModeId_Ascending(ByVal x As Long, ByVal y As Long) As Integer
2843 Return x.CompareTo(y)
2847 Public Function Compare_ModeId_Descending(ByVal x As Long, ByVal y As Long) As Integer
2848 Return y.CompareTo(x)
2852 Public Function Compare_ModeName_Ascending(ByVal x As Long, ByVal y As Long) As Integer
2853 Dim result As Integer = String.Compare(_statuses.Item(x).ScreenName, _statuses.Item(y).ScreenName)
2854 If result = 0 Then result = x.CompareTo(y)
2859 Public Function Compare_ModeName_Descending(ByVal x As Long, ByVal y As Long) As Integer
2860 Dim result As Integer = String.Compare(_statuses.Item(y).ScreenName, _statuses.Item(x).ScreenName)
2861 If result = 0 Then result = y.CompareTo(x)
2866 Public Function Compare_ModeNickName_Ascending(ByVal x As Long, ByVal y As Long) As Integer
2867 Dim result As Integer = String.Compare(_statuses.Item(x).Nickname, _statuses.Item(y).Nickname)
2868 If result = 0 Then result = x.CompareTo(y)
2873 Public Function Compare_ModeNickName_Descending(ByVal x As Long, ByVal y As Long) As Integer
2874 Dim result As Integer = String.Compare(_statuses.Item(y).Nickname, _statuses.Item(x).Nickname)
2875 If result = 0 Then result = y.CompareTo(x)
2880 Public Function Compare_ModeSource_Ascending(ByVal x As Long, ByVal y As Long) As Integer
2881 Dim result As Integer = String.Compare(_statuses.Item(x).Source, _statuses.Item(y).Source)
2882 If result = 0 Then result = x.CompareTo(y)
2887 Public Function Compare_ModeSource_Descending(ByVal x As Long, ByVal y As Long) As Integer
2888 Dim result As Integer = String.Compare(_statuses.Item(y).Source, _statuses.Item(x).Source)
2889 If result = 0 Then result = y.CompareTo(x)