svnno****@sourc*****
svnno****@sourc*****
2010年 12月 9日 (木) 20:26:16 JST
Revision: 1187 http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1187 Author: kiri_feather Date: 2010-12-09 20:26:16 +0900 (Thu, 09 Dec 2010) Log Message: ----------- USのイベントデータもデータモデルでデシリアライズ SetReadで発生する例外に対処したつもり USのイベントをUIの処理履歴に反映 USのイベント表示画面追加 Modified Paths: -------------- trunk/Tween/DataModel.vb trunk/Tween/StatusDictionary.vb trunk/Tween/Tween.Designer.vb trunk/Tween/Tween.resx trunk/Tween/Tween.vb trunk/Tween/Tween.vbproj trunk/Tween/Twitter.vb Added Paths: ----------- trunk/Tween/EventViewerDialog.Designer.vb trunk/Tween/EventViewerDialog.resx trunk/Tween/EventViewerDialog.vb -------------- next part -------------- Modified: trunk/Tween/DataModel.vb =================================================================== --- trunk/Tween/DataModel.vb 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/DataModel.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -155,6 +155,20 @@ End Class <DataContract()> _ + Public Class TargetObject + Inherits Status + <DataMember(Name:="mode")> Public Mode As String + <DataMember(Name:="description")> Public Description As String + <DataMember(Name:="slug")> Public Slug As String + <DataMember(Name:="uri")> Public Uri As String + <DataMember(Name:="member_count")> Public MemberCount As Integer + <DataMember(Name:="full_name")> Public FullName As String + <DataMember(Name:="subscriber_count")> Public SubscriberCount As Integer + <DataMember(Name:="name")> Public Name As String + <DataMember(Name:="following")> Public Following As Boolean + End Class + + <DataContract()> _ Public Class Directmessage <DataMember(Name:="created_at")> Public CreatedAt As String <DataMember(Name:="sender_id")> Public SenderId As Int64 @@ -216,7 +230,7 @@ <DataContract()> _ Public Class EventData <DataMember(Name:="target")> Public Target As User - <DataMember(Name:="target_object", isRequired:=False)> Public TargetObject As Status + <DataMember(Name:="target_object", isRequired:=False)> Public TargetObject As TargetObject <DataMember(Name:="created_at")> Public CreatedAt As String <DataMember(Name:="event")> Public [Event] As String <DataMember(Name:="source")> Public Source As User Added: trunk/Tween/EventViewerDialog.Designer.vb =================================================================== --- trunk/Tween/EventViewerDialog.Designer.vb (rev 0) +++ trunk/Tween/EventViewerDialog.Designer.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -0,0 +1,131 @@ +<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ +Partial Class EventViewerDialog + Inherits System.Windows.Forms.Form + + 'フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 + <System.Diagnostics.DebuggerNonUserCode()> _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Windows フォーム デザイナーで必要です。 + Private components As System.ComponentModel.IContainer + + 'メモ: 以下のプロシージャは Windows フォーム デザイナーで必要です。 + 'Windows フォーム デザイナーを使用して変更できます。 + 'コード エディターを使って変更しないでください。 + <System.Diagnostics.DebuggerStepThrough()> _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel() + Me.OK_Button = New System.Windows.Forms.Button() + Me.Cancel_Button = New System.Windows.Forms.Button() + Me.EventList = New System.Windows.Forms.ListView() + Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.TableLayoutPanel1.SuspendLayout() + Me.SuspendLayout() + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 2 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(531, 253) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 1 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 27) + Me.TableLayoutPanel1.TabIndex = 0 + ' + 'OK_Button + ' + Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.OK_Button.Location = New System.Drawing.Point(3, 3) + Me.OK_Button.Name = "OK_Button" + Me.OK_Button.Size = New System.Drawing.Size(67, 21) + Me.OK_Button.TabIndex = 0 + Me.OK_Button.Text = "OK" + ' + 'Cancel_Button + ' + Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None + Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Cancel_Button.Location = New System.Drawing.Point(76, 3) + Me.Cancel_Button.Name = "Cancel_Button" + Me.Cancel_Button.Size = New System.Drawing.Size(67, 21) + Me.Cancel_Button.TabIndex = 1 + Me.Cancel_Button.Text = "キャンセル" + ' + 'EventList + ' + Me.EventList.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader4}) + Me.EventList.FullRowSelect = True + Me.EventList.Location = New System.Drawing.Point(12, 12) + Me.EventList.Name = "EventList" + Me.EventList.Size = New System.Drawing.Size(665, 235) + Me.EventList.TabIndex = 1 + Me.EventList.UseCompatibleStateImageBehavior = False + Me.EventList.View = System.Windows.Forms.View.Details + ' + 'ColumnHeader1 + ' + Me.ColumnHeader1.Text = "Datetime" + Me.ColumnHeader1.Width = 86 + ' + 'ColumnHeader2 + ' + Me.ColumnHeader2.Text = "Type" + Me.ColumnHeader2.Width = 90 + ' + 'ColumnHeader3 + ' + Me.ColumnHeader3.Text = "Username" + Me.ColumnHeader3.Width = 106 + ' + 'ColumnHeader4 + ' + Me.ColumnHeader4.Text = "Target" + Me.ColumnHeader4.Width = 360 + ' + 'EventViewerDialog + ' + Me.AcceptButton = Me.OK_Button + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.Cancel_Button + Me.ClientSize = New System.Drawing.Size(689, 291) + Me.Controls.Add(Me.EventList) + Me.Controls.Add(Me.TableLayoutPanel1) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "EventViewerDialog" + Me.ShowInTaskbar = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Events" + Me.TableLayoutPanel1.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel + Friend WithEvents OK_Button As System.Windows.Forms.Button + Friend WithEvents Cancel_Button As System.Windows.Forms.Button + Friend WithEvents EventList As System.Windows.Forms.ListView + Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader + +End Class Added: trunk/Tween/EventViewerDialog.resx =================================================================== --- trunk/Tween/EventViewerDialog.resx (rev 0) +++ trunk/Tween/EventViewerDialog.resx 2010-12-09 11:26:16 UTC (rev 1187) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Added: trunk/Tween/EventViewerDialog.vb =================================================================== --- trunk/Tween/EventViewerDialog.vb (rev 0) +++ trunk/Tween/EventViewerDialog.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -0,0 +1,23 @@ +Imports System.Windows.Forms + +Public Class EventViewerDialog + Public Property EventSource As List(Of Twitter.FormattedEvent) + + Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub + + Private Sub EventViewerDialog_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown + For Each x As Twitter.FormattedEvent In EventSource + Dim s() As String = {x.CreatedAt.ToString, x.Event.ToUpper, x.Username, x.Target} + Me.EventList.Items.Add(New ListViewItem(s)) + Next + Me.EventList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent) + End Sub +End Class Modified: trunk/Tween/StatusDictionary.vb =================================================================== --- trunk/Tween/StatusDictionary.vb 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/StatusDictionary.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -998,6 +998,7 @@ If tb.UnreadManage = False Then Exit Sub '未読管理していなければ終了 + If Not tb.Contains(Index) Then Exit Sub Dim Id As Long = tb.GetId(Index) Dim post As PostClass If Not tb.IsInnerStorageTabType Then @@ -1005,6 +1006,7 @@ Else post = tb.Posts(Id) End If + If post.IsRead = Read Then Exit Sub '状態変更なければ終了 post.IsRead = Read '指定の状態に変更 @@ -1045,22 +1047,24 @@ Dim tb As TabClass = GetTabByType(TabUsageType.Home) If tb.UnreadManage = False Then Exit Sub - For i As Integer = 0 To tb.AllCount - 1 - Dim id As Long = tb.GetId(i) - If Not _statuses(id).IsReply AndAlso _ - Not _statuses(id).IsRead AndAlso _ - Not _statuses(id).FilterHit Then - _statuses(id).IsRead = True - Me.SetNextUnreadId(id, tb) '次の未読セット - For Each key As String In _tabs.Keys - If _tabs(key).UnreadManage AndAlso _ - _tabs(key).Contains(id) Then - _tabs(key).UnreadCount -= 1 - If _tabs(key).OldestUnreadId = id Then _tabs(key).OldestUnreadId = -1 - End If - Next - End If - Next + SyncLock LockObj + For i As Integer = 0 To tb.AllCount - 1 + Dim id As Long = tb.GetId(i) + If Not _statuses(id).IsReply AndAlso _ + Not _statuses(id).IsRead AndAlso _ + Not _statuses(id).FilterHit Then + _statuses(id).IsRead = True + Me.SetNextUnreadId(id, tb) '次の未読セット + For Each key As String In _tabs.Keys + If _tabs(key).UnreadManage AndAlso _ + _tabs(key).Contains(id) Then + _tabs(key).UnreadCount -= 1 + If _tabs(key).OldestUnreadId = id Then _tabs(key).OldestUnreadId = -1 + End If + Next + End If + Next + End SyncLock End Sub Public ReadOnly Property Item(ByVal ID As Long) As PostClass Modified: trunk/Tween/Tween.Designer.vb =================================================================== --- trunk/Tween/Tween.Designer.vb 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/Tween.Designer.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -289,6 +289,8 @@ Me.TimerRefreshIcon = New System.Windows.Forms.Timer(Me.components) Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.ToolStripSeparator42 = New System.Windows.Forms.ToolStripSeparator() + Me.EventViewerMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripContainer1.BottomToolStripPanel.SuspendLayout() Me.ToolStripContainer1.ContentPanel.SuspendLayout() Me.ToolStripContainer1.TopToolStripPanel.SuspendLayout() @@ -1453,7 +1455,7 @@ ' 'MenuItemUserStream ' - Me.MenuItemUserStream.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.StopToolStripMenuItem, Me.ToolStripSeparator40, Me.TrackToolStripMenuItem, Me.AllrepliesToolStripMenuItem}) + Me.MenuItemUserStream.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.StopToolStripMenuItem, Me.ToolStripSeparator40, Me.TrackToolStripMenuItem, Me.AllrepliesToolStripMenuItem, Me.ToolStripSeparator42, Me.EventViewerMenuItem}) resources.ApplyResources(Me.MenuItemUserStream, "MenuItemUserStream") Me.MenuItemUserStream.Name = "MenuItemUserStream" ' @@ -1809,6 +1811,16 @@ ' Me.OpenFileDialog1.FileName = "OpenFileDialog1" ' + 'ToolStripSeparator42 + ' + Me.ToolStripSeparator42.Name = "ToolStripSeparator42" + resources.ApplyResources(Me.ToolStripSeparator42, "ToolStripSeparator42") + ' + 'EventViewerMenuItem + ' + Me.EventViewerMenuItem.Name = "EventViewerMenuItem" + resources.ApplyResources(Me.EventViewerMenuItem, "EventViewerMenuItem") + ' 'TweenMain ' Me.AllowDrop = True @@ -2123,5 +2135,7 @@ Friend WithEvents ToolStripSeparator41 As System.Windows.Forms.ToolStripSeparator Friend WithEvents OpenOwnHomeMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents OpenOwnFavedMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents ToolStripSeparator42 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents EventViewerMenuItem As System.Windows.Forms.ToolStripMenuItem End Class Modified: trunk/Tween/Tween.resx =================================================================== --- trunk/Tween/Tween.resx 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/Tween.resx 2010-12-09 11:26:16 UTC (rev 1187) @@ -382,7 +382,7 @@ <value>0, 0, 0, 0</value> </data> <data name="ListTab.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 242</value> + <value>570, 244</value> </data> <data name="ListTab.TabIndex" type="System.Int32, mscorlib"> <value>0</value> @@ -406,7 +406,7 @@ <value>0, 0</value> </data> <data name="TimelinePanel.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 242</value> + <value>570, 244</value> </data> <data name="TimelinePanel.TabIndex" type="System.Int32, mscorlib"> <value>0</value> @@ -436,7 +436,7 @@ <value>0, 0</value> </data> <data name="ImageSelectedPicture.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 214</value> + <value>570, 216</value> </data> <data name="ImageSelectedPicture.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms"> <value>Zoom</value> @@ -640,7 +640,7 @@ <value>Bottom</value> </data> <data name="ImagePathPanel.Location" type="System.Drawing.Point, System.Drawing"> - <value>0, 214</value> + <value>0, 216</value> </data> <data name="ImagePathPanel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms"> <value>3, 3, 3, 3</value> @@ -670,7 +670,7 @@ <value>0, 0</value> </data> <data name="ImageSelectionPanel.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 242</value> + <value>570, 244</value> </data> <data name="ImageSelectionPanel.TabIndex" type="System.Int32, mscorlib"> <value>1</value> @@ -697,7 +697,7 @@ <value>0, 0</value> </data> <data name="ProfilePanel.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 242</value> + <value>570, 244</value> </data> <data name="ProfilePanel.TabIndex" type="System.Int32, mscorlib"> <value>2</value> @@ -1039,7 +1039,7 @@ <value>59, 20</value> </data> <data name="PostBrowser.Size" type="System.Drawing.Size, System.Drawing"> - <value>508, 46</value> + <value>508, 44</value> </data> <data name="PostBrowser.TabIndex" type="System.Int32, mscorlib"> <value>6</value> @@ -1144,7 +1144,7 @@ <value>2</value> </data> <data name="TableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 69</value> + <value>570, 67</value> </data> <data name="TableLayoutPanel1.TabIndex" type="System.Int32, mscorlib"> <value>1</value> @@ -1282,10 +1282,10 @@ <value>19</value> </data> <data name="SplitContainer2.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 96</value> + <value>570, 94</value> </data> <data name="SplitContainer2.SplitterDistance" type="System.Int32, mscorlib"> - <value>69</value> + <value>67</value> </data> <data name="SplitContainer2.SplitterWidth" type="System.Int32, mscorlib"> <value>2</value> @@ -1327,7 +1327,7 @@ <value>0, 0</value> </data> <data name="PreviewPicture.Size" type="System.Drawing.Size, System.Drawing"> - <value>194, 98</value> + <value>194, 96</value> </data> <data name="PreviewPicture.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms"> <value>Zoom</value> @@ -1357,7 +1357,7 @@ <value>194, 0</value> </data> <data name="PreviewScrollBar.Size" type="System.Drawing.Size, System.Drawing"> - <value>17, 98</value> + <value>17, 96</value> </data> <data name="PreviewScrollBar.TabIndex" type="System.Int32, mscorlib"> <value>0</value> @@ -1387,7 +1387,7 @@ <value>1</value> </data> <data name="SplitContainer3.Size" type="System.Drawing.Size, System.Drawing"> - <value>570, 96</value> + <value>570, 94</value> </data> <data name="SplitContainer3.SplitterDistance" type="System.Int32, mscorlib"> <value>355</value> @@ -1426,7 +1426,7 @@ <value>574, 348</value> </data> <data name="SplitContainer1.SplitterDistance" type="System.Int32, mscorlib"> - <value>246</value> + <value>248</value> </data> <data name="SplitContainer1.SplitterWidth" type="System.Int32, mscorlib"> <value>2</value> @@ -2140,26 +2140,35 @@ <value>その他機能(&C)</value> </data> <data name="StopToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>144, 22</value> + <value>152, 22</value> </data> <data name="StopToolStripMenuItem.Text" xml:space="preserve"> <value>Stop</value> </data> <data name="ToolStripSeparator40.Size" type="System.Drawing.Size, System.Drawing"> - <value>141, 6</value> + <value>149, 6</value> </data> <data name="TrackToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>144, 22</value> + <value>152, 22</value> </data> <data name="TrackToolStripMenuItem.Text" xml:space="preserve"> <value>Track</value> </data> <data name="AllrepliesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> - <value>144, 22</value> + <value>152, 22</value> </data> <data name="AllrepliesToolStripMenuItem.Text" xml:space="preserve"> <value>All @replies</value> </data> + <data name="ToolStripSeparator42.Size" type="System.Drawing.Size, System.Drawing"> + <value>149, 6</value> + </data> + <data name="EventViewerMenuItem.Size" type="System.Drawing.Size, System.Drawing"> + <value>152, 22</value> + </data> + <data name="EventViewerMenuItem.Text" xml:space="preserve"> + <value>View Events</value> + </data> <data name="MenuItemUserStream.Enabled" type="System.Boolean, mscorlib"> <value>False</value> </data> @@ -3981,6 +3990,18 @@ <data name=">>ToolTip1.Type" xml:space="preserve"> <value>System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </data> + <data name=">>ToolStripSeparator42.Name" xml:space="preserve"> + <value>ToolStripSeparator42</value> + </data> + <data name=">>ToolStripSeparator42.Type" xml:space="preserve"> + <value>System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </data> + <data name=">>EventViewerMenuItem.Name" xml:space="preserve"> + <value>EventViewerMenuItem</value> + </data> + <data name=">>EventViewerMenuItem.Type" xml:space="preserve"> + <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </data> <data name=">>$this.Name" xml:space="preserve"> <value>TweenMain</value> </data> Modified: trunk/Tween/Tween.vb =================================================================== --- trunk/Tween/Tween.vb 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/Tween.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -8353,6 +8353,7 @@ AddHandler tw.UserStreamStarted, AddressOf tw_UserStreamStarted AddHandler tw.UserStreamStopped, AddressOf tw_UserStreamStopped AddHandler tw.PostDeleted, AddressOf tw_PostDeleted + AddHandler tw.UserStreamEventReceived, AddressOf tw_UserStreamEventArrived MenuItemUserStream.Text = "&UserStream ■" MenuItemUserStream.Enabled = True @@ -9910,6 +9911,14 @@ StatusLabel.Text = "UserStream Stopped." End Sub + Private Sub tw_UserStreamEventArrived(ByVal eventType As String) + If InvokeRequired Then + Invoke(New Action(Of String)(AddressOf tw_UserStreamEventArrived), eventType) + Exit Sub + End If + StatusLabel.Text = "Event: " + eventType + End Sub + Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click MenuItemUserStream.Enabled = False tw.StartUserStream() @@ -9958,4 +9967,13 @@ Private Sub OpenOwnHomeMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenOwnHomeMenuItem.Click OpenUriAsync("http://twitter.com/" + tw.Username) End Sub + + Private Sub EventViewerMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventViewerMenuItem.Click + Using dlg As New EventViewerDialog + dlg.Owner = Me + dlg.EventSource = tw.StoredEvent + dlg.ShowDialog() + Me.TopMost = SettingDialog.AlwaysTop + End Using + End Sub End Class Modified: trunk/Tween/Tween.vbproj =================================================================== --- trunk/Tween/Tween.vbproj 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/Tween.vbproj 2010-12-09 11:26:16 UTC (rev 1187) @@ -137,6 +137,12 @@ <Compile Include="DetailsListView.vb"> <SubType>Component</SubType> </Compile> + <Compile Include="EventViewerDialog.Designer.vb"> + <DependentUpon>EventViewerDialog.vb</DependentUpon> + </Compile> + <Compile Include="EventViewerDialog.vb"> + <SubType>Form</SubType> + </Compile> <Compile Include="DialogAsShieldIcon.Designer.vb"> <DependentUpon>DialogAsShieldIcon.vb</DependentUpon> </Compile> @@ -287,6 +293,9 @@ <DependentUpon>AtIdSupplement.vb</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="EventViewerDialog.resx"> + <DependentUpon>EventViewerDialog.vb</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="DialogAsShieldIcon.resx"> <DependentUpon>DialogAsShieldIcon.vb</DependentUpon> <SubType>Designer</SubType> Modified: trunk/Tween/Twitter.vb =================================================================== --- trunk/Tween/Twitter.vb 2010-12-09 09:35:10 UTC (rev 1186) +++ trunk/Tween/Twitter.vb 2010-12-09 11:26:16 UTC (rev 1187) @@ -2113,12 +2113,7 @@ Dim item As List(Of TwitterDataModel.Status) Try - Using stream As New MemoryStream() - Dim buf As Byte() = Encoding.Unicode.GetBytes(content) - stream.Write(buf, 0, buf.Length) - stream.Seek(offset:=0, loc:=SeekOrigin.Begin) - item = DirectCast(serializer.ReadObject(stream), List(Of TwitterDataModel.Status)) - End Using + item = CreateDataFromJson(Of List(Of TwitterDataModel.Status))(content) Catch ex As SerializationException TraceOut(ex.Message + Environment.NewLine + content) Return "Json Parse Error(DataContractJsonSerializer)" @@ -2813,8 +2808,25 @@ Public Event UserStreamStopped() Public Event UserStreamGetFriendsList() Public Event PostDeleted(ByVal id As Long) + Public Event UserStreamEventReceived(ByVal eventType As String) Private WithEvents userStream As TwitterUserstream + Public Class FormattedEvent + Public Property CreatedAt As DateTime + Public Property [Event] As String + Public Property Username As String + Public Property Target As String + + Public Overrides Function ToString() As String + Return (Me.CreatedAt.ToString() + " ").Substring(0, 20) + + ("[" + Me.Event.ToUpper + "] ").Substring(0, 20) + + (Me.Username + " ").Substring(0, 20) + + Me.Target + End Function + End Class + + Public Property StoredEvent As New List(Of FormattedEvent) + Private EventNameTable() As String = { "favorite", "unfavorite", @@ -2847,9 +2859,7 @@ Exit Sub ElseIf xElm.Element("event") IsNot Nothing Then Debug.Print("event: " + xElm.Element("event").Value) - If Array.IndexOf(EventNameTable, xElm.Element("event").Value) = -1 Then - TraceOut("Unknown Event:" + xElm.Element("event").Value + Environment.NewLine + line) - End If + CreateEventFromJson(line) Exit Sub ElseIf xElm.Element("direct_message") IsNot Nothing Then Debug.Print("direct_message") @@ -2872,6 +2882,41 @@ RaiseEvent NewPostFromStream() End Sub + Private Sub CreateEventFromJson(ByVal content As String) + Dim eventData As TwitterDataModel.EventData = Nothing + Try + eventData = CreateDataFromJson(Of TwitterDataModel.EventData)(content) + Catch ex As SerializationException + TraceOut(ex, "Event Serialize Exception!" + Environment.NewLine + content) + Catch ex As Exception + TraceOut(ex, "Event Exception!" + Environment.NewLine + content) + End Try + + Dim evt As New FormattedEvent + evt.CreatedAt = Me.DateTimeParse(eventData.CreatedAt) + evt.Event = eventData.Event + evt.Username = eventData.Source.ScreenName + Select Case eventData.Event + Case "follow" + If eventData.Target.ScreenName.ToLower.Equals(_uid) Then + If Not Me.followerId.Contains(eventData.Source.Id) Then Me.followerId.Add(eventData.Source.Id) + Else + Exit Sub 'Block後のUndoをすると、SourceとTargetが逆転したfollowイベントが帰ってくるため。 + End If + evt.Target = "" + Case "favorite", "unfavorite" + evt.Target = eventData.TargetObject.Text + Case "list_member_added", "list_member_removed" + evt.Target = eventData.TargetObject.Name + Case "block" + evt.Target = "" + Case Else + TraceOut("Unknown Event:" + evt.Event + Environment.NewLine + content) + End Select + Me.StoredEvent.Insert(0, evt) + RaiseEvent UserStreamEventReceived(evt.Event) + End Sub + Private Function CreateDataFromJson(Of T)(ByVal content As String) As T Dim data As T Using stream As New MemoryStream()