From 5c9f9615c61dce3cdabd096fee97e9a82790cef0 Mon Sep 17 00:00:00 2001 From: spx Date: Sat, 3 May 2014 18:29:19 +0900 Subject: [PATCH] =?utf8?q?=E3=83=9D=E3=82=B9=E3=83=88=E9=81=B8=E6=8A=9E?= =?utf8?q?=E5=B1=A5=E6=AD=B4=E3=81=BE=E3=82=8F=E3=82=8A=E3=81=AE=E5=87=A6?= =?utf8?q?=E7=90=86=E3=82=92=E8=8B=A5=E5=B9=B2=E5=A4=89=E6=9B=B4=20?= =?utf8?q?=E5=B1=A5=E6=AD=B4=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?utf8?q?=E3=81=8C2500=E4=BB=B6=E6=BA=9C=E3=81=BE=E3=82=8B=E3=81=94?= =?utf8?q?=E3=81=A8=E3=81=AB=E3=83=88=E3=83=AA=E3=83=A0=E5=87=A6=E7=90=86?= =?utf8?q?=E3=82=92=E5=91=BC=E3=81=B6=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?utf8?q?=E6=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/Tween.cs | 75 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index a7f37059..20d76398 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -1429,7 +1429,6 @@ namespace OpenTween doGetFollowersMenu(); GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, ""); GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, ""); - if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain)); } if (osResumed) { @@ -1446,7 +1445,6 @@ namespace OpenTween GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, ""); doGetFollowersMenu(); GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, ""); - if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain)); } } } @@ -7521,35 +7519,78 @@ namespace OpenTween private void GoBackSelectPostChain() { - try + if (this.selectPostChains.Count > 1) { - this.selectPostChains.Pop(); - Tuple tabPostPair = this.selectPostChains.Pop(); - if (!this.ListTab.TabPages.Contains(tabPostPair.Item1)) return; - this.ListTab.SelectedTab = tabPostPair.Item1; - if (tabPostPair.Item2 != null && this._statuses.Tabs[this._curTab.Text].IndexOf(tabPostPair.Item2.StatusId) > -1) + var idx = -1; + TabPage tp = null; + + do + { + try + { + this.selectPostChains.Pop(); + var tabPostPair = this.selectPostChains.Peek(); + + if (!this.ListTab.TabPages.Contains(tabPostPair.Item1)) continue; //該当タブが存在しないので無視 + + if (tabPostPair.Item2 != null) + { + idx = this._statuses.Tabs[tabPostPair.Item1.Text].IndexOf(tabPostPair.Item2.StatusId); + if (idx == -1) continue; //該当ポストが存在しないので無視 + } + + tp = tabPostPair.Item1; + + this.selectPostChains.Pop(); + } + catch (InvalidOperationException) + { + } + + break; + } + while (this.selectPostChains.Count > 1); + + if (tp == null) { - this.SelectListItem(this._curList, this._statuses.Tabs[this._curTab.Text].IndexOf(tabPostPair.Item2.StatusId)); - this._curList.EnsureVisible(this._statuses.Tabs[this._curTab.Text].IndexOf(tabPostPair.Item2.StatusId)); + //状態がおかしいので処理を中断 + //履歴が残り1つであればクリアしておく + if (this.selectPostChains.Count == 1) + this.selectPostChains.Clear(); + return; } - } - catch (InvalidOperationException) - { + + DetailsListView lst = (DetailsListView)tp.Tag; + this.ListTab.SelectedTab = tp; + if (idx > -1) + { + SelectListItem(lst, idx); + lst.EnsureVisible(idx); + } + lst.Focus(); } } private void PushSelectPostChain() { - if (this.selectPostChains.Count == 0 || (this.selectPostChains.Peek().Item1.Text != this._curTab.Text || this._curPost != this.selectPostChains.Peek().Item2)) + int count = this.selectPostChains.Count; + if (count > 0) { - this.selectPostChains.Push(Tuple.Create(this._curTab, _curPost)); + var p = this.selectPostChains.Peek(); + if (p.Item1 == this._curTab) + { + if (p.Item2 == this._curPost) return; //最新の履歴と同一 + if (p.Item2 == null) this.selectPostChains.Pop(); //置き換えるため削除 + } } + if (count >= 2500) TrimPostChain(); + this.selectPostChains.Push(Tuple.Create(this._curTab, this._curPost)); } private void TrimPostChain() { - if (this.selectPostChains.Count < 2000) return; - Stack> p = new Stack>(); + if (this.selectPostChains.Count <= 2000) return; + var p = new Stack>(2000); for (int i = 0; i < 2000; i++) { p.Push(this.selectPostChains.Pop()); -- 2.11.0