{
public partial class TweenMain : OTBaseForm
{
- private readonly HttpClient http;
-
//各種設定
private Size _mySize; //画面サイズ
private Point _myLoc; //画面位置
this.IconCache.Dispose();
}
- this.http.Dispose();
-
// 終了時にRemoveHandlerしておかないとメモリリークする
// http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.powermodechanged.aspx
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
////設定読み出し
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;
//アイコン描画不具合あり?
}
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));
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]));
}
}
}
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] {};
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();
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;
#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,