{
public partial class TweenMain : OTBaseForm
{
- private readonly HttpClient http;
-
//各種設定
private Size _mySize; //画面サイズ
private Point _myLoc; //画面位置
private bool _waitLists = false;
private BackgroundWorker[] _bw = new BackgroundWorker[20];
private BackgroundWorker _bwFollower;
- private InternetSecurityManager SecurityManager;
private int UnreadCounter = -1;
private int UnreadAtCounter = -1;
private class GetWorkerResult
{
public string retMsg = ""; //処理結果詳細メッセージ。エラー時に値がセットされる
- public int page; //取得対象ページ番号
- public int endPage = 0; //取得終了ページ番号(継続可能ならインクリメントされて返る。pageと比較して継続判定)
public MyCommon.WORKERTYPE type; //処理種別
- public Dictionary<string, Image> imgs = null; //新規取得したアイコンイメージ
public string tName = ""; //Fav追加・削除時のタブ名
- public List<long> ids = null; //Fav追加・削除時のID
public List<long> sIds = null; //Fav追加・削除成功分のID
public bool newDM = false;
public int addCount;
private class GetWorkerArg
{
public int page; //処理対象ページ番号
- public int endPage; //処理終了ページ番号(起動時の読み込みページ数。通常時はpageと同じ値をセット)
public MyCommon.WORKERTYPE type; //処理種別
- public string url = ""; //URLをブラウザで開くときのアドレス
public PostingStatus status = new PostingStatus(); //発言POST時の発言内容
public List<long> ids; //Fav追加・削除時のItemIndex
public List<long> sIds; //Fav追加・削除成功分のItemIndex
}
}
- private void TweenMain_Disposed(object sender, EventArgs e)
+ private bool disposed = false;
+
+ /// <summary>
+ /// 使用中のリソースをすべてクリーンアップします。
+ /// </summary>
+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
+ protected override void Dispose(bool disposing)
{
- //後始末
- SettingDialog.Dispose();
- SearchDialog.Dispose();
- fltDialog.Dispose();
- UrlDialog.Dispose();
- if (NIconAt != null) NIconAt.Dispose();
- if (NIconAtRed != null) NIconAtRed.Dispose();
- if (NIconAtSmoke != null) NIconAtSmoke.Dispose();
- if (NIconRefresh[0] != null) NIconRefresh[0].Dispose();
- if (NIconRefresh[1] != null) NIconRefresh[1].Dispose();
- if (NIconRefresh[2] != null) NIconRefresh[2].Dispose();
- if (NIconRefresh[3] != null) NIconRefresh[3].Dispose();
- if (TabIcon != null) TabIcon.Dispose();
- if (MainIcon != null) MainIcon.Dispose();
- if (ReplyIcon != null) ReplyIcon.Dispose();
- if (ReplyIconBlink != null) ReplyIconBlink.Dispose();
- _listViewImageList.Dispose();
- _brsHighLight.Dispose();
- if (_brsBackColorMine != null) _brsBackColorMine.Dispose();
- if (_brsBackColorAt != null) _brsBackColorAt.Dispose();
- if (_brsBackColorYou != null) _brsBackColorYou.Dispose();
- if (_brsBackColorAtYou != null) _brsBackColorAtYou.Dispose();
- if (_brsBackColorAtFromTarget != null) _brsBackColorAtFromTarget.Dispose();
- if (_brsBackColorAtTo != null) _brsBackColorAtTo.Dispose();
- if (_brsBackColorNone != null) _brsBackColorNone.Dispose();
- if (_brsDeactiveSelection != null) _brsDeactiveSelection.Dispose();
- //sf.Dispose();
- sfTab.Dispose();
- foreach (BackgroundWorker bw in _bw)
- {
- if (bw != null)
- bw.Dispose();
- }
- if (_bwFollower != null)
- {
- _bwFollower.Dispose();
- }
- this._apiGauge.Dispose();
- if (IconCache != null)
- {
- this.IconCache.CancelAsync();
- this.IconCache.Dispose();
- }
+ base.Dispose(disposing);
- this.http.Dispose();
+ if (this.disposed)
+ return;
+
+ if (disposing)
+ {
+ if (this.components != null)
+ this.components.Dispose();
+
+ //後始末
+ SettingDialog.Dispose();
+ SearchDialog.Dispose();
+ fltDialog.Dispose();
+ UrlDialog.Dispose();
+ if (NIconAt != null) NIconAt.Dispose();
+ if (NIconAtRed != null) NIconAtRed.Dispose();
+ if (NIconAtSmoke != null) NIconAtSmoke.Dispose();
+ if (NIconRefresh[0] != null) NIconRefresh[0].Dispose();
+ if (NIconRefresh[1] != null) NIconRefresh[1].Dispose();
+ if (NIconRefresh[2] != null) NIconRefresh[2].Dispose();
+ if (NIconRefresh[3] != null) NIconRefresh[3].Dispose();
+ if (TabIcon != null) TabIcon.Dispose();
+ if (MainIcon != null) MainIcon.Dispose();
+ if (ReplyIcon != null) ReplyIcon.Dispose();
+ if (ReplyIconBlink != null) ReplyIconBlink.Dispose();
+ _listViewImageList.Dispose();
+ _brsHighLight.Dispose();
+ if (_brsBackColorMine != null) _brsBackColorMine.Dispose();
+ if (_brsBackColorAt != null) _brsBackColorAt.Dispose();
+ if (_brsBackColorYou != null) _brsBackColorYou.Dispose();
+ if (_brsBackColorAtYou != null) _brsBackColorAtYou.Dispose();
+ if (_brsBackColorAtFromTarget != null) _brsBackColorAtFromTarget.Dispose();
+ if (_brsBackColorAtTo != null) _brsBackColorAtTo.Dispose();
+ if (_brsBackColorNone != null) _brsBackColorNone.Dispose();
+ if (_brsDeactiveSelection != null) _brsDeactiveSelection.Dispose();
+ //sf.Dispose();
+ sfTab.Dispose();
+ foreach (BackgroundWorker bw in _bw)
+ {
+ if (bw != null)
+ bw.Dispose();
+ }
+ if (_bwFollower != null)
+ {
+ _bwFollower.Dispose();
+ }
+ this._apiGauge.Dispose();
+ if (IconCache != null)
+ {
+ this.IconCache.CancelAsync();
+ this.IconCache.Dispose();
+ }
+
+ this.thumbnailTokenSource.Dispose();
+ this.itemCacheLock.Dispose();
+ this.tw.Dispose();
+ this._hookGlobalHotkey.Dispose();
+ }
// 終了時にRemoveHandlerしておかないとメモリリークする
// http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.powermodechanged.aspx
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
+
+ this.disposed = true;
}
private void LoadIcon(ref Icon IconInstance, string FileName)
//Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass")
- SecurityManager = new InternetSecurityManager(PostBrowser);
+ new InternetSecurityManager(PostBrowser);
this.PostBrowser.AllowWebBrowserDrop = false; // COMException を回避するため、ActiveX の初期化が終わってから設定する
MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated;
////設定読み出し
LoadConfig();
- ThumbnailGenerator.InitializeGenerator(this.http);
+ ThumbnailGenerator.InitializeGenerator();
var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet;
_initial = true;
+ Networking.Initialize();
+
//アイコンリスト作成
- this.IconCache = new ImageCache(this.http);
+ this.IconCache = new ImageCache();
bool saveRequired = false;
bool firstRun = false;
}
//Twitter用通信クラス初期化
- HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut,
- SettingDialog.SelectedProxyType,
- SettingDialog.ProxyAddress,
- SettingDialog.ProxyPort,
- SettingDialog.ProxyUser,
- SettingDialog.ProxyPassword);
+ Networking.DefaultTimeout = TimeSpan.FromSeconds(this.SettingDialog.DefaultTimeOut);
+ Networking.SetWebProxy(this.SettingDialog.SelectedProxyType,
+ this.SettingDialog.ProxyAddress, this.SettingDialog.ProxyPort,
+ this.SettingDialog.ProxyUser, this.SettingDialog.ProxyPassword);
tw.RestrictFavCheck = SettingDialog.RestrictFavCheck;
tw.ReadOwnPost = SettingDialog.ReadOwnPost;
ApplyListViewIconSize(SettingDialog.IconSz);
- tw.TinyUrlResolve = SettingDialog.TinyUrlResolve;
-
StatusLabel.Text = Properties.Resources.Form1_LoadText1; //画面右下の状態表示を変更
StatusLabelUrl.Text = ""; //画面左下のリンク先URL表示部を初期化
NameLabel.Text = ""; //発言詳細部名前ラベル初期化
{
tab.TabType = MyCommon.TabUsageType.UserDefined;
}
- if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo)) throw new Exception(Properties.Resources.TweenMain_LoadText1);
+ if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo))
+ throw new TabException(Properties.Resources.TweenMain_LoadText1);
}
this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space";
if (ResetTimers.Timeline || homeCounter <= 0 && SettingDialog.TimelinePeriodInt > 0)
{
Interlocked.Exchange(ref homeCounter, SettingDialog.TimelinePeriodInt);
- if (!tw.IsUserstreamDataReceived && !ResetTimers.Timeline) GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
+ if (!tw.IsUserstreamDataReceived && !ResetTimers.Timeline) GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
ResetTimers.Timeline = false;
}
if (ResetTimers.Reply || mentionCounter <= 0 && SettingDialog.ReplyPeriodInt > 0)
{
Interlocked.Exchange(ref mentionCounter, SettingDialog.ReplyPeriodInt);
- if (!tw.IsUserstreamDataReceived && !ResetTimers.Reply) GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 0, "");
+ if (!tw.IsUserstreamDataReceived && !ResetTimers.Reply) GetTimeline(MyCommon.WORKERTYPE.Reply, 1, "");
ResetTimers.Reply = false;
}
if (ResetTimers.DirectMessage || dmCounter <= 0 && SettingDialog.DMPeriodInt > 0)
{
Interlocked.Exchange(ref dmCounter, SettingDialog.DMPeriodInt);
- if (!tw.IsUserstreamDataReceived && !ResetTimers.DirectMessage) GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, "");
+ if (!tw.IsUserstreamDataReceived && !ResetTimers.DirectMessage) GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
ResetTimers.DirectMessage = false;
}
if (ResetTimers.PublicSearch || pubSearchCounter <= 0 && SettingDialog.PubSearchPeriodInt > 0)
{
Interlocked.Exchange(ref pubSearchCounter, SettingDialog.PubSearchPeriodInt);
- if (!ResetTimers.PublicSearch) GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, "");
+ if (!ResetTimers.PublicSearch) GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, "");
ResetTimers.PublicSearch = false;
}
if (ResetTimers.UserTimeline || userTimelineCounter <= 0 && SettingDialog.UserTimelinePeriodInt > 0)
{
Interlocked.Exchange(ref userTimelineCounter, SettingDialog.UserTimelinePeriodInt);
- if (!ResetTimers.UserTimeline) GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, "");
+ if (!ResetTimers.UserTimeline) GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, "");
ResetTimers.UserTimeline = false;
}
if (ResetTimers.Lists || listsCounter <= 0 && SettingDialog.ListsPeriodInt > 0)
{
Interlocked.Exchange(ref listsCounter, SettingDialog.ListsPeriodInt);
- if (!ResetTimers.Lists) GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, "");
+ if (!ResetTimers.Lists) GetTimeline(MyCommon.WORKERTYPE.List, 1, "");
ResetTimers.Lists = false;
}
if (ResetTimers.UserStream || usCounter <= 0 && SettingDialog.UserstreamPeriodInt > 0)
{
Interlocked.Exchange(ref refreshFollowers, 0);
doGetFollowersMenu();
- GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
}
if (osResumed)
{
{
osResumed = false;
Interlocked.Exchange(ref ResumeWait, 0);
- GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.List, 1, "");
doGetFollowersMenu();
- GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
}
}
}
//アイコン描画不具合あり?
}
this.SelectListItem(lst,
- _statuses.IndexOf(tab.Text, selId[tab.Text]),
- _statuses.IndexOf(tab.Text, focusedId[tab.Text]));
+ tabInfo.IndexOf(selId[tab.Text]),
+ tabInfo.IndexOf(focusedId[tab.Text]));
}
}
if (tabInfo.UnreadCount > 0)
if (MyCommon._endingFlag) return;
foreach (TabPage tab in ListTab.TabPages)
{
- DetailsListView lst = (DetailsListView)tab.Tag;
+ var lst = (DetailsListView)tab.Tag;
+ var tabInfo = _statuses.Tabs[tab.Text];
if (lst.SelectedIndices.Count > 0 && lst.SelectedIndices.Count < 61)
{
- selId.Add(tab.Text, _statuses.GetId(tab.Text, lst.SelectedIndices));
+ selId.Add(tab.Text, tabInfo.GetId(lst.SelectedIndices));
}
else
{
var fIds = new long[2]; // 0 = focus, 1 = selection mark
var item = lst.FocusedItem;
- fIds[0] = (item != null) ? _statuses.GetId(tab.Text, item.Index) : -2;
+ fIds[0] = (item != null) ? tabInfo.GetId(item.Index) : -2;
var mIdx = lst.SelectionMark;
- fIds[1] = (mIdx > -1) ? _statuses.GetId(tab.Text, mIdx) : -2;
+ fIds[1] = (mIdx > -1) ? tabInfo.GetId(mIdx) : -2;
focusedId.Add(tab.Text, fIds);
}
!SettingDialog.LimitBalloon
)
) &&
- !Win32Api.IsScreenSaverRunning())
+ !NativeMethods.IsScreenSaverRunning())
{
return true;
}
//mentions新着時に画面ブリンク
if (!_initial && SettingDialog.BlinkNewMentions && newMentions && Form.ActiveForm == null)
{
- Win32Api.FlashMyWindow(this.Handle, Win32Api.FlashSpecification.FlashTray, 3);
+ NativeMethods.FlashMyWindow(this.Handle, NativeMethods.FlashSpecification.FlashTray, 3);
}
}
private void ChangeCacheStyleRead(bool Read, int Index)
{
+ var tabInfo = _statuses.Tabs[_curTab.Text];
//Read:true=既読 false=未読
//未読管理していなかったら既読として扱う
- if (!_statuses.Tabs[_curTab.Text].UnreadManage ||
+ if (!tabInfo.UnreadManage ||
!SettingDialog.UnreadManage) Read = true;
//対象の特定
if (itm == null || post == null)
{
itm = ((DetailsListView)_curTab.Tag).Items[Index];
- post = _statuses[_curTab.Text, Index];
+ post = tabInfo[Index];
}
ChangeItemStyleRead(Read, itm, post, ((DetailsListView)_curTab.Tag));
StatusText.SelectionStart = StatusText.Text.Length;
GetWorkerArg args = new GetWorkerArg();
args.page = 0;
- args.endPage = 0;
args.type = MyCommon.WORKERTYPE.PostMessage;
CheckReplyTo(StatusText.Text);
rslt.retMsg = ret;
rslt.type = args.type;
rslt.tName = args.tName;
- if (args.type == MyCommon.WORKERTYPE.DirectMessegeRcv ||
- args.type == MyCommon.WORKERTYPE.DirectMessegeSnt ||
- args.type == MyCommon.WORKERTYPE.Reply ||
- args.type == MyCommon.WORKERTYPE.Timeline ||
- args.type == MyCommon.WORKERTYPE.Favorites)
- {
- rslt.page = args.page - 1; //値が正しいか後でチェック。10ページ毎の継続確認
- }
e.Result = rslt;
}
_waitReply = false;
if (rslt.newDM && !_initial)
{
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
}
break;
case MyCommon.WORKERTYPE.Favorites:
{
GetWorkerArg args = new GetWorkerArg();
args.page = 0;
- args.endPage = 0;
args.type = MyCommon.WORKERTYPE.PostMessage;
args.status = rslt.status;
RunAsync(args);
}
else
{
- GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
}
}
break;
_postTimestamps.RemoveAt(i);
}
}
- if (!_isActiveUserstream && SettingDialog.PostAndGet) GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
+ if (!_isActiveUserstream && SettingDialog.PostAndGet) GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
}
break;
case MyCommon.WORKERTYPE.Follower:
private static Dictionary<MyCommon.WORKERTYPE, DateTime> lastTime = new Dictionary<MyCommon.WORKERTYPE, DateTime>();
- private void GetTimeline(MyCommon.WORKERTYPE WkType, int fromPage, int toPage, string tabName)
+ private void GetTimeline(MyCommon.WORKERTYPE WkType, int fromPage, string tabName)
{
if (!this.IsNetworkAvailable()) return;
//非同期実行引数設定
GetWorkerArg args = new GetWorkerArg();
args.page = fromPage;
- args.endPage = toPage;
args.type = WkType;
args.tName = tabName;
switch (_statuses.Tabs[_curTab.Text].TabType)
{
case MyCommon.TabUsageType.Mentions:
- GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, 1, "");
break;
case MyCommon.TabUsageType.DirectMessage:
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
break;
case MyCommon.TabUsageType.Favorites:
- GetTimeline(MyCommon.WORKERTYPE.Favorites, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Favorites, 1, "");
break;
//case MyCommon.TabUsageType.Profile:
//// TODO
//// TODO
TabClass tb = _statuses.Tabs[_curTab.Text];
if (string.IsNullOrEmpty(tb.SearchWords)) return;
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, _curTab.Text);
break;
case MyCommon.TabUsageType.UserTimeline:
- GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, _curTab.Text);
break;
case MyCommon.TabUsageType.Lists:
//// TODO
TabClass tab = _statuses.Tabs[_curTab.Text];
if (tab.ListInfo == null || tab.ListInfo.Id == 0) return;
- GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.List, 1, _curTab.Text);
break;
default:
- GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
break;
}
}
else
{
- GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
}
}
switch (_statuses.Tabs[_curTab.Text].TabType)
{
case MyCommon.TabUsageType.Mentions:
- GetTimeline(MyCommon.WORKERTYPE.Reply, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, -1, "");
break;
case MyCommon.TabUsageType.DirectMessage:
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, -1, "");
break;
case MyCommon.TabUsageType.Favorites:
- GetTimeline(MyCommon.WORKERTYPE.Favorites, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Favorites, -1, "");
break;
case MyCommon.TabUsageType.Profile:
//// TODO
// TODO
TabClass tb = _statuses.Tabs[_curTab.Text];
if (string.IsNullOrEmpty(tb.SearchWords)) return;
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, -1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, -1, _curTab.Text);
break;
case MyCommon.TabUsageType.UserTimeline:
- GetTimeline(MyCommon.WORKERTYPE.UserTimeline, -1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.UserTimeline, -1, _curTab.Text);
break;
case MyCommon.TabUsageType.Lists:
//// TODO
TabClass tab = _statuses.Tabs[_curTab.Text];
if (tab.ListInfo == null || tab.ListInfo.Id == 0) return;
- GetTimeline(MyCommon.WORKERTYPE.List, -1, 0, _curTab.Text);
+ GetTimeline(MyCommon.WORKERTYPE.List, -1, _curTab.Text);
break;
default:
- GetTimeline(MyCommon.WORKERTYPE.Timeline, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, -1, "");
break;
}
}
else
{
- GetTimeline(MyCommon.WORKERTYPE.Timeline, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, -1, "");
}
}
{
lock (_syncObject)
{
- tw.TinyUrlResolve = SettingDialog.TinyUrlResolve;
tw.RestrictFavCheck = SettingDialog.RestrictFavCheck;
tw.ReadOwnPost = SettingDialog.ReadOwnPost;
ShortUrl.Instance.DisableExpanding = !SettingDialog.TinyUrlResolve;
ShortUrl.Instance.BitlyKey = SettingDialog.BitlyPwd;
HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl;
- HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut,
- SettingDialog.SelectedProxyType,
- SettingDialog.ProxyAddress,
- SettingDialog.ProxyPort,
- SettingDialog.ProxyUser,
- SettingDialog.ProxyPassword);
+ Networking.DefaultTimeout = TimeSpan.FromSeconds(this.SettingDialog.DefaultTimeOut);
+ Networking.SetWebProxy(this.SettingDialog.SelectedProxyType,
+ this.SettingDialog.ProxyAddress, this.SettingDialog.ProxyPort,
+ this.SettingDialog.ProxyUser, this.SettingDialog.ProxyPassword);
ImageSelector.Reset(tw, SettingDialog.TwitterConfiguration);
foreach (TabPage tab in ListTab.TabPages)
{
DetailsListView lst = (DetailsListView)tab.Tag;
+ TabClass tabInfo = _statuses.Tabs[tab.Text];
using (ControlTransaction.Update(lst))
{
this.SelectListItem(lst,
- _statuses.IndexOf(tab.Text, selId[tab.Text]),
- _statuses.IndexOf(tab.Text, focusedId[tab.Text]));
+ tabInfo.IndexOf(selId[tab.Text]),
+ tabInfo.IndexOf(focusedId[tab.Text]));
}
}
}
SaveConfigsTabs();
//検索実行
- GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, tabName);
+ GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, tabName);
}
public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null)
this.itemCacheLock.EnterWriteLock();
try
{
+ var tabInfo = _statuses.Tabs[_curTab.Text];
+
//キャッシュ要求(要求範囲±30を作成)
StartIndex -= 30;
if (StartIndex < 0) StartIndex = 0;
EndIndex += 30;
- if (EndIndex >= _statuses.Tabs[_curTab.Text].AllCount) EndIndex = _statuses.Tabs[_curTab.Text].AllCount - 1;
- _postCache = _statuses[_curTab.Text, StartIndex, EndIndex]; //配列で取得
+ if (EndIndex >= tabInfo.AllCount) EndIndex = tabInfo.AllCount - 1;
+ _postCache = tabInfo[StartIndex, EndIndex]; //配列で取得
_itemCacheIndex = StartIndex;
_itemCache = new ListViewItem[0] {};
Post.Source};
itm = new ImageListViewItem(sitem, this.IconCache, Post.ImageUrl);
}
- itm.StateImageIndex = Post.StateIndex;
+ itm.StateIndex = Post.StateIndex;
bool read = Post.IsRead;
//未読管理していなかったら既読として扱う
//iconRect.Offset(0, Math.Max(0, (itemRect.Height - realIconSize.Height) / 2));
}
- if (item.StateImageIndex > -1)
+ if (item.StateIndex > -1)
{
Rectangle stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + realIconSize.Width + 2, iconRect.Y), realStateSize), itemRect);
if (stateRect.Width > 0)
{
//e.Graphics.FillRectangle(Brushes.White, stateRect);
//e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High;
- e.Graphics.DrawImage(this.PostStateImageList.Images[item.StateImageIndex], stateRect);
+ e.Graphics.DrawImage(this.PostStateImageList.Images[item.StateIndex], stateRect);
}
}
}
var versionInfoUrl = new Uri(ApplicationSettings.VersionInfoUrl + "?" +
DateTime.Now.ToString("yyMMddHHmmss") + Environment.TickCount);
- var responseText = await this.http.GetStringAsync(versionInfoUrl)
+ var responseText = await Networking.Http.GetStringAsync(versionInfoUrl)
.ConfigureAwait(false);
// 改行2つで前後パートを分割(前半がバージョン番号など、後半が詳細テキスト)
{
var oldTokenSource = this.thumbnailTokenSource;
- oldTokenSource.Cancel();
+ var cancelTask = Task.Run(() => oldTokenSource.Cancel());
- this.thumbnailTask.ContinueWith(_ => oldTokenSource.Dispose());
+ Task.WhenAll(this.thumbnailTask, cancelTask)
+ .ContinueWith(_ => oldTokenSource.Dispose(), TaskScheduler.Default);
}
this.thumbnailTokenSource = new CancellationTokenSource();
DoRefresh();
return true;
case Keys.F6:
- GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, 1, "");
return true;
case Keys.F7:
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
return true;
}
if (Focused != FocusedControl.StatusText)
DoRefreshMore();
return true;
case Keys.F6:
- GetTimeline(MyCommon.WORKERTYPE.Reply, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, -1, "");
return true;
case Keys.F7:
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, -1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, -1, "");
return true;
}
//フォーカスStatusText以外
{
ListTab.SelectedIndex = ListTab.TabPages.Count - 1;
ListTabSelect(ListTab.TabPages[ListTab.TabPages.Count - 1]);
- GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, tabName);
+ GetTimeline(MyCommon.WORKERTYPE.List, 1, tabName);
}
}
}
if (this.IsNetworkAvailable())
{
this.RefreshMuteUserIdsAsync();
- GetTimeline(MyCommon.WORKERTYPE.BlockIds, 0, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.BlockIds, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, "");
if (SettingDialog.StartupFollowers)
{
- GetTimeline(MyCommon.WORKERTYPE.Follower, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Follower, 0, "");
}
- GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
StartUserStream();
_waitTimeline = true;
- GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.Timeline, 1, "");
_waitReply = true;
- GetTimeline(MyCommon.WORKERTYPE.Reply, 1, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.Reply, 1, "");
_waitDm = true;
- GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.DirectMessegeRcv, 1, "");
if (SettingDialog.GetFav)
{
_waitFav = true;
- GetTimeline(MyCommon.WORKERTYPE.Favorites, 1, 1, "");
+ GetTimeline(MyCommon.WORKERTYPE.Favorites, 1, "");
}
_waitPubSearch = true;
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, ""); //tabname="":全タブ
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, ""); //tabname="":全タブ
_waitUserTimeline = true;
- GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, ""); //tabname="":全タブ
+ GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, ""); //tabname="":全タブ
_waitLists = true;
- GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, ""); //tabname="":全タブ
+ GetTimeline(MyCommon.WORKERTYPE.List, 1, ""); //tabname="":全タブ
var i = 0;
while (this.IsInitialRead())
// 取得失敗の場合は再試行する
if (!tw.GetFollowersSuccess && SettingDialog.StartupFollowers)
- GetTimeline(MyCommon.WORKERTYPE.Follower, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Follower, 0, "");
// 取得失敗の場合は再試行する
if (!tw.GetNoRetweetSuccess)
- GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, "");
// 取得失敗の場合は再試行する
if (SettingDialog.TwitterConfiguration.PhotoSizeLimit == 0)
- GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
// 権限チェック read/write権限(xAuthで取得したトークン)の場合は再認証を促す
if (MyCommon.TwitterApiInfo.AccessLevel == TwitterApiAccessLevel.ReadWrite)
private void doGetFollowersMenu()
{
- GetTimeline(MyCommon.WORKERTYPE.Follower, 1, 0, "");
+ GetTimeline(MyCommon.WORKERTYPE.Follower, 1, "");
DispSelectedPost(true);
}
public string id = "";
public bool isFollowing = false;
public bool isFollowed = false;
- public bool isError = false;
public FriendshipInfo(string id)
{
this.id = id;
if (!string.IsNullOrEmpty(rt))
{
if (string.IsNullOrEmpty(result)) result = rt;
- fInfo.isError = true;
}
}
e.Result = result;
TabClass tb = _statuses.Tabs[tbName];
ComboBox cmb = (ComboBox)pnl.Controls["comboSearch"];
ComboBox cmbLang = (ComboBox)pnl.Controls["comboLang"];
- ComboBox cmbusline = (ComboBox)pnl.Controls["comboUserline"];
cmb.Text = cmb.Text.Trim();
// 検索式演算子 OR についてのみ大文字しか認識しないので強制的に大文字とする
bool Quote = false;
SaveConfigsTabs(); //検索条件の保存
}
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, tbName);
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, tbName);
((DetailsListView)ListTab.SelectedTab.Tag).Focus();
}
private HookGlobalHotkey _hookGlobalHotkey;
public TweenMain()
{
- this.http = MyCommon.CreateHttpClient();
_hookGlobalHotkey = new HookGlobalHotkey(this);
// この呼び出しは、Windows フォーム デザイナで必要です。
this.gh.NotifyClicked += GrowlHelper_Callback;
// メイリオフォント指定時にタブの最小幅が広くなる問題の対策
- this.ListTab.HandleCreated += (s, e) => Win32Api.SetMinTabWidth((TabControl)s, 40);
+ this.ListTab.HandleCreated += (s, e) => NativeMethods.SetMinTabWidth((TabControl)s, 40);
this._apiGauge = new ToolStripAPIGauge();
this._apiGauge.BorderSides = ToolStripStatusLabelBorderSides.Right;
}
}
- this.GetTimeline(MyCommon.WORKERTYPE.Related, 1, 1, tabName);
+ this.GetTimeline(MyCommon.WORKERTYPE.Related, 1, tabName);
}
private void CacheInfoMenuItem_Click(object sender, EventArgs e)
#region "Userstream"
private bool _isActiveUserstream = false;
- private void tw_PostDeleted(long id)
+ private void tw_PostDeleted(object sender, PostDeletedEventArgs e)
{
try
{
{
Invoke((Action) (() =>
{
- _statuses.RemovePostReserve(id);
- if (_curTab != null && _statuses.Tabs[_curTab.Text].Contains(id))
+ _statuses.RemovePostReserve(e.StatusId);
+ if (_curTab != null && _statuses.Tabs[_curTab.Text].Contains(e.StatusId))
{
this.PurgeListViewItemCache();
((DetailsListView)_curTab.Tag).Update();
- if (_curPost != null && _curPost.StatusId == id) DispSelectedPost(true);
+ if (_curPost != null && _curPost.StatusId == e.StatusId) DispSelectedPost(true);
}
}));
return;
}
}
- private void tw_NewPostFromStream()
+ private void tw_NewPostFromStream(object sender, EventArgs e)
{
if (SettingDialog.ReadOldPosts)
{
}
}
- private void tw_UserStreamStarted()
+ private void tw_UserStreamStarted(object sender, EventArgs e)
{
this._isActiveUserstream = true;
try
{
if (InvokeRequired && !IsDisposed)
{
- Invoke(new MethodInvoker(tw_UserStreamStarted));
+ Invoke((Action)(() => this.tw_UserStreamStarted(sender, e)));
return;
}
}
StatusLabel.Text = "UserStream Started.";
}
- private void tw_UserStreamStopped()
+ private void tw_UserStreamStopped(object sender, EventArgs e)
{
this._isActiveUserstream = false;
try
{
if (InvokeRequired && !IsDisposed)
{
- Invoke(new MethodInvoker(tw_UserStreamStopped));
+ Invoke((Action)(() => this.tw_UserStreamStopped(sender, e)));
return;
}
}
StatusLabel.Text = "UserStream Stopped.";
}
- private void tw_UserStreamEventArrived(Twitter.FormattedEvent ev)
+ private void tw_UserStreamEventArrived(object sender, UserStreamEventReceivedEventArgs e)
{
try
{
if (InvokeRequired && !IsDisposed)
{
- Invoke(new Action<Twitter.FormattedEvent>(tw_UserStreamEventArrived), ev);
+ Invoke((Action)(() => this.tw_UserStreamEventArrived(sender, e)));
return;
}
}
{
return;
}
+ var ev = e.EventData;
StatusLabel.Text = "Event: " + ev.Event;
//if (ev.Event == "favorite")
//{
if (string.IsNullOrEmpty(str))
return;
- var bing = new Bing(this.http);
+ var bing = new Bing();
try
{
var translatedText = await bing.TranslateAsync(str,