{
public partial class TweenMain : OTBaseForm
{
- private 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;
!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);
}
}
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);
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 = HttpConnection.CreateHttpClient(new HttpClientHandler());
- HttpConnection.WebProxyChanged += (o, e) =>
- {
- var newClient = HttpConnection.CreateHttpClient(new HttpClientHandler());
- var oldClient = Interlocked.Exchange(ref this.http, newClient);
- oldClient.Dispose();
- };
-
_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,