From ae391a90341541547cc837590995328649a94d7b Mon Sep 17 00:00:00 2001 From: ggslyman Date: Fri, 21 Mar 2014 17:29:48 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AC=E3=82=B9=E5=8F=96=E5=BE=97=E3=82=92Ja?= =?UTF-8?q?vaScript=E3=81=A7=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++ SpeechCast/FormMain.Designer.cs | 22 ++++---- SpeechCast/FormMain.cs | 75 ++++++++++++++++----------- SpeechCast/FormViewResource.cs | 1 + SpeechCast/Properties/AssemblyInfo.cs | 4 +- 5 files changed, 63 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index d23d677..50f5ec6 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,9 @@ ##更新履歴 +* 14/03/10 2.0.1 Rev.8 + - レス取得をJavaScriptで取得するよう変更 + * 14/03/10 2.0.1 Rev.7 - ビューアのタブを閉じてもメモリが解放されない不具合を修正 - youtubeもビューアで開く様に変更 diff --git a/SpeechCast/FormMain.Designer.cs b/SpeechCast/FormMain.Designer.cs index a688818..db7e4a4 100644 --- a/SpeechCast/FormMain.Designer.cs +++ b/SpeechCast/FormMain.Designer.cs @@ -73,6 +73,7 @@ private void InitializeComponent() this.toolStripButtonSettings = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonCaptionAutoSmall = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButton19 = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonThreads = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonResponse = new System.Windows.Forms.ToolStripButton(); this.toolStripButton1 = new System.Windows.Forms.ToolStripSeparator(); @@ -136,7 +137,6 @@ private void InitializeComponent() this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton17 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton18 = new System.Windows.Forms.ToolStripButton(); - this.toolStripButton19 = new System.Windows.Forms.ToolStripButton(); this.statusStrip1.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -636,6 +636,16 @@ private void InitializeComponent() this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(6, 26); // + // toolStripButton19 + // + this.toolStripButton19.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton19.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton19.Image"))); + this.toolStripButton19.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton19.Name = "toolStripButton19"; + this.toolStripButton19.Size = new System.Drawing.Size(23, 23); + this.toolStripButton19.Text = "toolStripButton19"; + this.toolStripButton19.Click += new System.EventHandler(this.toolStripButton19_Click); + // // toolStripButtonThreads // this.toolStripButtonThreads.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; @@ -1193,16 +1203,6 @@ private void InitializeComponent() this.toolStripButton18.Size = new System.Drawing.Size(23, 23); this.toolStripButton18.Text = "toolStripButtonAutoNextThread"; // - // toolStripButton19 - // - this.toolStripButton19.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton19.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton19.Image"))); - this.toolStripButton19.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton19.Name = "toolStripButton19"; - this.toolStripButton19.Size = new System.Drawing.Size(23, 23); - this.toolStripButton19.Text = "toolStripButton19"; - this.toolStripButton19.Click += new System.EventHandler(this.toolStripButton19_Click); - // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/SpeechCast/FormMain.cs b/SpeechCast/FormMain.cs index f81db3c..789d4fb 100644 --- a/SpeechCast/FormMain.cs +++ b/SpeechCast/FormMain.cs @@ -65,6 +65,20 @@ public FormMain() // Webブラウザオブジェクトへの新規イベント追加 this.webBrowser.StatusTextChanged += new EventHandler(webBrowser_StatusTextChanged); this.webBrowser.Navigating += new WebBrowserNavigatingEventHandler(webBrowser_Navigating); + // JavaScriptでの差分取得用HTMLをセット + this.webBrowser.DocumentText = @" +
"; } // ブラウザ内リンクのイベント追加 @@ -326,6 +340,8 @@ private bool CheckBaseURL() string debugDatFileName = null; #endif // 元ソースより非同期に変更 + private int oldResCount = 0; + private string oldUrl = ""; private async Task GetFromURL(bool next) { @@ -408,6 +424,15 @@ private async Task GetFromURL(bool next) } url = rawURL; datSize = 1; + // レス差分取得関係の初期化処理 + if (oldUrl != rawURL) + { + responses.Clear(); + oldUrl = rawURL; + oldResCount = 0; + Object[] objArray = new Object[1]; + webBrowser.Document.InvokeScript("clearRes", objArray); + } } System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); @@ -623,6 +648,15 @@ await Task.Run(() => //レスが増えた updated = true; + // 差分用処理 + if (responses.Count == 0) + { + oldResCount = 0; + } + else + { + oldResCount = responses.Count; + } listViewResponses.BeginUpdate(); int startIndex; if (clearItems) @@ -684,34 +718,16 @@ await Task.Run(() => if (updated) { - string[] htmlStrings = new string[responses.Count]; - - int i = 0; - foreach (Response res in responses) + // JavaScriptでの差分追加処理 + if (webBrowser.Document != null) { - htmlStrings[i] = res.Html; - i++; - } - - string html = string.Format("{0}" - , string.Concat(htmlStrings) - ); - - try - { - webBrowser.DocumentText = html; - documetnTime = stopWatch.ElapsedMilliseconds; - -#if DEBUG - AddLog("Elasped res={0} read={1} enc={2} list={3} doc={4} set={5}", - responseTime, readTime, encodingTime, listViewTime, documetnTime, setTime); -#endif - } - catch (Exception ex) - { - result = false; - AddLog("webBrowser Exception: {0}", ex.Message); - } + for (int idx = oldResCount; idx < responses.Count; idx++) + { + Object[] objArray = new Object[1]; + objArray[0] = responses[idx].Html; + webBrowser.Document.InvokeScript("addRes", objArray); + } + } } return result; } @@ -834,7 +850,7 @@ private int GetResponsesScrollY(int no) private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { - ScrollToDocumentEnd(); + //ScrollToDocumentEnd(); } private int currentResNumber_ = 0; @@ -948,7 +964,7 @@ private void StartSpeaking() isSpeaking = true; StartSpeaking(text); listViewResponses.Items[CurrentResNumber - 1].Selected = true; - webBrowser.Document.Window.ScrollTo(0, GetResponsesScrollY(CurrentResNumber)); + //webBrowser.Document.Window.ScrollTo(0, GetResponsesScrollY(CurrentResNumber)); } else if (openNextThread == OpenNextThread) { @@ -2135,5 +2151,6 @@ public void saveViewerPos(FormViewResource frm) { UserConfig.SetFormToRect(ref UserConfig.FormViewToRect, frm); } + } } diff --git a/SpeechCast/FormViewResource.cs b/SpeechCast/FormViewResource.cs index 179922f..44b200e 100644 --- a/SpeechCast/FormViewResource.cs +++ b/SpeechCast/FormViewResource.cs @@ -39,6 +39,7 @@ public void addTabYoutube(string id) { // コンテンツ格納用のWebブラウザを作成 WebBrowser wb = new WebBrowser(); + // ウィジェットHTMLを生成 string widgetCode = ""; wb.DocumentText = "" + widgetCode + ""; wb.Dock = DockStyle.Fill; diff --git a/SpeechCast/Properties/AssemblyInfo.cs b/SpeechCast/Properties/AssemblyInfo.cs index 51f9d80..f0fef0d 100644 --- a/SpeechCast/Properties/AssemblyInfo.cs +++ b/SpeechCast/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.1.7")] -[assembly: AssemblyFileVersion("2.0.1.7")] +[assembly: AssemblyVersion("2.0.1.8")] +[assembly: AssemblyFileVersion("2.0.1.8")]