// for more details.
//
// You should have received a copy of the GNU General public License along
-// with this program. if (not, see <http://www.gnu.org/licenses/>, or write to
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.
using System.Linq;
using System.Media;
using System.Net;
+using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
-
using OpenTween.Api;
using OpenTween.Connection;
using OpenTween.OpenTweenCustomControl;
private int _mySpDis; //区切り位置
private int _mySpDis2; //発言欄区切り位置
private int _mySpDis3; //プレビュー区切り位置
- private int _myAdSpDis; //Ad区切り位置
private int _iconSz; //アイコンサイズ(現在は16、24、48の3種類。将来直接数字指定可能とする 注:24x24の場合に26と指定しているのはMSゴシック系フォントのための仕様)
private bool _iconCol; //1列表示の時true(48サイズのとき)
//サブ画面インスタンス
private AppendSettingDialog SettingDialog = AppendSettingDialog.Instance; //設定画面インスタンス
- private SearchWord SearchDialog = new SearchWord(); //検索画面インスタンス
+ private SearchWordDialog SearchDialog = new SearchWordDialog(); //検索画面インスタンス
private FilterDialog fltDialog = new FilterDialog(); //フィルター編集画面
private OpenURL UrlDialog = new OpenURL();
public AtIdSupplement AtIdSupl; //@id補助
private Icon ReplyIcon; //5g
private Icon ReplyIconBlink; //6g
+ private ImageList _listViewImageList = new ImageList(); //ListViewItemの高さ変更用
+
private PostClass _anchorPost;
private bool _anchorFlag; //true:関連発言移動中(関連移動以外のオペレーションをするとfalseへ。trueだとリスト背景色をアンカー発言選択中として描画)
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 bool _DoFavRetweetFlags = false;
private bool osResumed = false;
- private Dictionary<string, IMultimediaShareService> pictureService;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
private string _postBrowserStatusText = "";
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
public long? inReplyToId = null;
public string inReplyToName = null;
public string imageService = ""; //画像投稿サービス名
- public string imagePath = "";
+ public string[] imagePath = null;
public PostingStatus()
{
}
}
}
- private void TweenMain_Disposed(object sender, EventArgs e)
- {
- //後始末
- 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();
- _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();
+ private bool disposed = false;
+
+ /// <summary>
+ /// 使用中のリソースをすべてクリーンアップします。
+ /// </summary>
+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose(disposing);
+
+ 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)
TraceOutToolStripMenuItem.Checked = true;
MyCommon.TraceFlag = true;
#endif
- if (!MyCommon.fileVersion.EndsWith("0"))
+ if (!MyCommon.FileVersion.EndsWith("0"))
{
TraceOutToolStripMenuItem.Checked = true;
MyCommon.TraceFlag = true;
//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;
Regex.CacheSize = 100;
- MyCommon.fileVersion = ((AssemblyFileVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]).Version;
InitializeTraceFrag();
LoadIcons(); // アイコン読み込み
- ThumbnailGenerator.InitializeGenerator();
-
- Thumbnail.Services.TonTwitterCom.InitializeOAuthToken = x =>
- x.Initialize(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret,
- this.tw.AccessToken, this.tw.AccessTokenSecret, "", "");
-
//発言保持クラス
_statuses = TabInformations.GetInstance();
////設定読み出し
LoadConfig();
+ ThumbnailGenerator.InitializeGenerator();
+
+ var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
+ imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet;
+ imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM;
+
+ Thumbnail.Services.TonTwitterCom.InitializeOAuthToken = x =>
+ x.Initialize(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret,
+ this.tw.AccessToken, this.tw.AccessTokenSecret, "", "");
+
//新着バルーン通知のチェック状態設定
NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop;
this.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked;
this.Font = fontUIGlobal;
}
- _brsBackColorMine = new SolidBrush(_clSelf);
- _brsBackColorAt = new SolidBrush(_clAtSelf);
- _brsBackColorYou = new SolidBrush(_clTarget);
- _brsBackColorAtYou = new SolidBrush(_clAtTarget);
- _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget);
- _brsBackColorAtTo = new SolidBrush(_clAtTo);
- //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window));
- _brsBackColorNone = new SolidBrush(_clListBackcolor);
-
// StringFormatオブジェクトへの事前設定
//sf.Alignment = StringAlignment.Near; // Textを近くへ配置(左から右の場合は左寄せ)
//sf.LineAlignment = StringAlignment.Near; // Textを近くへ配置(上寄せ)
SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement;
SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement;
SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable;
+ SettingDialog.StatusAreaAtBottom = _cfgCommon.StatusAreaAtBottom;
AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@");
SettingDialog.IsMonospace = _cfgCommon.IsMonospace;
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader = detailHtmlFormatMono1;
- detailHtmlFormatFooter = detailHtmlFormatMono7;
- }
- else
- {
- detailHtmlFormatHeader = detailHtmlFormat1;
- detailHtmlFormatFooter = detailHtmlFormat7;
- }
- detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString();
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader += detailHtmlFormatMono6;
- }
- else
- {
- detailHtmlFormatHeader += detailHtmlFormat6;
- }
+
this.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert;
this.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText;
//Regex statregex = new Regex("^0*");
- SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(MyCommon.fileVersion.Replace(".", ""), "^0*", "") + "]";
+ SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(MyCommon.FileVersion.Replace(".", ""), "^0*", "") + "]";
//書式指定文字列エラーチェック
try
SettingDialog.UserAppointUrl = _cfgCommon.UserAppointUrl;
SettingDialog.HideDuplicatedRetweets = _cfgCommon.HideDuplicatedRetweets;
- SettingDialog.IsPreviewFoursquare = _cfgCommon.IsPreviewFoursquare;
+ SettingDialog.EnableImgAzyobuziNet = _cfgCommon.EnableImgAzyobuziNet;
+ SettingDialog.ImgAzyobuziNetDisabledInDM = _cfgCommon.ImgAzyobuziNetDisabledInDM;
SettingDialog.MapThumbnailProvider = _cfgCommon.MapThumbnailProvider;
SettingDialog.MapThumbnailHeight = _cfgCommon.MapThumbnailHeight;
SettingDialog.MapThumbnailWidth = _cfgCommon.MapThumbnailWidth;
_initial = true;
+ Networking.Initialize();
+
//アイコンリスト作成
this.IconCache = new ImageCache();
return;
}
SettingDialog.ShowInTaskbar = false;
+
//新しい設定を反映
//フォント&文字色&背景色保持
_fntUnread = SettingDialog.FontUnread;
_clInputBackcolor = SettingDialog.ColorInputBackcolor;
_clInputFont = SettingDialog.ColorInputFont;
_fntInputFont = SettingDialog.FontInputFont;
- _brsBackColorMine.Dispose();
- _brsBackColorAt.Dispose();
- _brsBackColorYou.Dispose();
- _brsBackColorAtYou.Dispose();
- _brsBackColorAtFromTarget.Dispose();
- _brsBackColorAtTo.Dispose();
- _brsBackColorNone.Dispose();
- _brsBackColorMine = new SolidBrush(_clSelf);
- _brsBackColorAt = new SolidBrush(_clAtSelf);
- _brsBackColorYou = new SolidBrush(_clTarget);
- _brsBackColorAtYou = new SolidBrush(_clAtTarget);
- _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget);
- _brsBackColorAtTo = new SolidBrush(_clAtTo);
- _brsBackColorNone = new SolidBrush(_clListBackcolor);
-
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader = detailHtmlFormatMono1;
- detailHtmlFormatFooter = detailHtmlFormatMono7;
- }
- else
- {
- detailHtmlFormatHeader = detailHtmlFormat1;
- detailHtmlFormatFooter = detailHtmlFormat7;
- }
- detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString();
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader += detailHtmlFormatMono6;
- }
- else
- {
- detailHtmlFormatHeader += detailHtmlFormat6;
- }
+
//他の設定項目は、随時設定画面で保持している値を読み出して使用
}
+ _brsBackColorMine = new SolidBrush(_clSelf);
+ _brsBackColorAt = new SolidBrush(_clAtSelf);
+ _brsBackColorYou = new SolidBrush(_clTarget);
+ _brsBackColorAtYou = new SolidBrush(_clAtTarget);
+ _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget);
+ _brsBackColorAtTo = new SolidBrush(_clAtTo);
+ //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window));
+ _brsBackColorNone = new SolidBrush(_clListBackcolor);
+
+ InitDetailHtmlFormat();
+
if (SettingDialog.HotkeyEnabled)
{
//////グローバルホットキーの登録
}
//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;
AllrepliesToolStripMenuItem.Checked = tw.AllAtReply;
//画像投稿サービス
- this.CreatePictureServices();
- SetImageServiceCombo();
- ImageSelectionPanel.Enabled = false;
-
- SelectImageServiceComboItem(_cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
+ ImageSelector.Initialize(tw, SettingDialog.TwitterConfiguration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
//ウィンドウ設定
this.ClientSize = _cfgLocal.FormSize;
if (_mySpDis3 < 1) _mySpDis3 = 50;
_cfgLocal.PreviewDistance = _mySpDis3;
}
- _myAdSpDis = _cfgLocal.AdSplitterDistance;
MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline;
//this.Tween_ClientSizeChanged(this, null);
PlaySoundMenuItem.Checked = SettingDialog.PlaySound;
// NameLabel のフォントを OTBaseForm.GlobalFont に変更
this.NameLabel.Font = this.ReplaceToGlobalFont(this.NameLabel.Font);
+ // 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える
+ SplitContainer1.IsPanelInverted = !SettingDialog.StatusAreaAtBottom;
+
//全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定)
if (SettingDialog.UnreadManage == false)
{
_statuses.SortMode = mode;
////////////////////////////////////////////////////////////////////////////////
- switch (SettingDialog.IconSz)
- {
- case MyCommon.IconSizes.IconNone:
- _iconSz = 0;
- break;
- case MyCommon.IconSizes.Icon16:
- _iconSz = 16;
- break;
- case MyCommon.IconSizes.Icon24:
- _iconSz = 26;
- break;
- case MyCommon.IconSizes.Icon48:
- _iconSz = 48;
- break;
- case MyCommon.IconSizes.Icon48_2:
- _iconSz = 48;
- _iconCol = true;
- break;
- }
- if (_iconSz == 0)
- {
- tw.GetIcon = false;
- }
- else
- {
- tw.GetIcon = true;
- tw.IconSize = _iconSz;
- }
- tw.TinyUrlResolve = SettingDialog.TinyUrlResolve;
-
- //発言詳細部アイコンをリストアイコンにサイズ変更
- int sz = _iconSz;
- if (_iconSz == 0)
- {
- sz = 16;
- }
+ ApplyListViewIconSize(SettingDialog.IconSz);
StatusLabel.Text = Properties.Resources.Form1_LoadText1; //画面右下の状態表示を変更
StatusLabelUrl.Text = ""; //画面左下のリンク先URL表示部を初期化
tab.TabType = MyCommon.TabUsageType.Favorites;
}
}
- foreach (string tn in _statuses.Tabs.Keys)
+ foreach (var tab in _statuses.Tabs.Values)
{
- if (_statuses.Tabs[tn].TabType == MyCommon.TabUsageType.Undefined)
+ if (tab.TabType == MyCommon.TabUsageType.Undefined)
{
- _statuses.Tabs[tn].TabType = MyCommon.TabUsageType.UserDefined;
+ tab.TabType = MyCommon.TabUsageType.UserDefined;
}
- if (!AddNewTab(tn, true, _statuses.Tabs[tn].TabType, _statuses.Tabs[tn].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";
SetTabAlignment();
}
- private void CreatePictureServices()
+ private void InitDetailHtmlFormat()
{
- if (this.pictureService != null) this.pictureService.Clear();
- this.pictureService = null;
- this.pictureService = new Dictionary<string, IMultimediaShareService> {
- {"TwitPic", new TwitPic(tw)},
- {"img.ly", new imgly(tw)},
- {"yfrog", new yfrog(tw)},
- {"Twitter", new TwitterPhoto(tw)},
- {"ついっぷるフォト", new TwipplePhoto(tw)},
- {"Imgur", new Imgur(tw)},
- };
+ if (SettingDialog.IsMonospace)
+ {
+ detailHtmlFormatHeader = detailHtmlFormatMono1;
+ detailHtmlFormatFooter = detailHtmlFormatMono7;
+ }
+ else
+ {
+ detailHtmlFormatHeader = detailHtmlFormat1;
+ detailHtmlFormatFooter = detailHtmlFormat7;
+ }
+ detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString();
+ if (SettingDialog.IsMonospace)
+ {
+ detailHtmlFormatHeader += detailHtmlFormatMono6;
+ }
+ else
+ {
+ detailHtmlFormatHeader += detailHtmlFormat6;
+ }
}
private void ListTab_DrawItem(object sender, DrawItemEventArgs e)
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, "");
- if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain));
+ 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, "");
- if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain));
+ GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, "");
}
}
}
//現在の選択状態を退避
Dictionary<string, long[]> selId = new Dictionary<string, long[]>();
- Dictionary<string, long> focusedId = new Dictionary<string, long>();
+ Dictionary<string, long[]> focusedId = new Dictionary<string, long[]>();
SaveSelectedStatus(selId, focusedId);
//mentionsの更新前件数を保持
//アイコン描画不具合あり?
}
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)
return topId;
}
- private void SaveSelectedStatus(Dictionary<string, long[]> selId, Dictionary<string, long> focusedId)
+ private void SaveSelectedStatus(Dictionary<string, long[]> selId, Dictionary<string, long[]> focusedId)
{
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
{
selId.Add(tab.Text, new long[1] {-2});
}
- if (lst.FocusedItem != null)
- focusedId.Add(tab.Text, _statuses.GetId(tab.Text, lst.FocusedItem.Index));
- else
- focusedId.Add(tab.Text, -2);
+
+ var fIds = new long[2]; // 0 = focus, 1 = selection mark
+ var item = lst.FocusedItem;
+ fIds[0] = (item != null) ? tabInfo.GetId(item.Index) : -2;
+ var mIdx = lst.SelectionMark;
+ 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);
}
}
if (SettingDialog.UnreadManage) _statuses.SetReadAllTab(true, _curTab.Text, _curItemIndex);
//キャッシュの書き換え
- ChangeCacheStyleRead(true, _curItemIndex, _curTab); //既読へ(フォント、文字色)
+ ChangeCacheStyleRead(true, _curItemIndex); //既読へ(フォント、文字色)
ColorizeList();
_colorize = true;
}
- private void ChangeCacheStyleRead(bool Read, int Index, TabPage Tab)
+ 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;
//対象の特定
ListViewItem itm = null;
PostClass post = null;
- if (Tab.Equals(this._curTab))
- {
- this.TryGetListViewItemCache(Index, out itm, out post);
- }
+ this.TryGetListViewItemCache(Index, out itm, out post);
if (itm == null || post == null)
{
- itm = ((DetailsListView)Tab.Tag).Items[Index];
- post = _statuses[Tab.Text, Index];
+ itm = ((DetailsListView)_curTab.Tag).Items[Index];
+ post = tabInfo[Index];
}
- ChangeItemStyleRead(Read, itm, post, ((DetailsListView)Tab.Tag));
+ ChangeItemStyleRead(Read, itm, post, ((DetailsListView)_curTab.Tag));
}
private void ChangeItemStyleRead(bool Read, ListViewItem Item, PostClass Post, DetailsListView DList)
return cl;
}
- private void PostButton_Click(object sender, EventArgs e)
+ private async void PostButton_Click(object sender, EventArgs e)
{
if (StatusText.Text.Trim().Length == 0)
{
- if (!ImageSelectionPanel.Enabled)
+ if (!ImageSelector.Enabled)
{
DoRefresh();
return;
if (SettingDialog.Nicoms)
{
StatusText.SelectionStart = StatusText.Text.Length;
- UrlConvert(MyCommon.UrlConverter.Nicoms);
+ await UrlConvertAsync(MyCommon.UrlConverter.Nicoms);
}
//if (SettingDialog.UrlConvertAuto)
//{
StatusText.SelectionStart = StatusText.Text.Length;
GetWorkerArg args = new GetWorkerArg();
args.page = 0;
- args.endPage = 0;
args.type = MyCommon.WORKERTYPE.PostMessage;
CheckReplyTo(StatusText.Text);
args.status.inReplyToId = _reply_to_id;
args.status.inReplyToName = _reply_to_name;
- if (ImageSelectionPanel.Visible)
+ if (ImageSelector.Visible)
{
//画像投稿
- if (ImageSelectedPicture.Image != ImageSelectedPicture.InitialImage &&
- ImageServiceCombo.SelectedIndex > -1 &&
- !string.IsNullOrEmpty(ImagefilePathText.Text))
- {
- if (MessageBox.Show(Properties.Resources.PostPictureConfirm1,
- Properties.Resources.PostPictureConfirm2,
- MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button1)
- == DialogResult.Cancel)
- {
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- if (_curList != null)
- _curList.Focus();
- return;
- }
- args.status.imageService = ImageServiceCombo.Text;
- args.status.imagePath = ImagefilePathText.Text;
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImagefilePathText.Text = "";
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- if (_curList != null)
- _curList.Focus();
- }
- else
- {
- MessageBox.Show(Properties.Resources.PostPictureWarn1, Properties.Resources.PostPictureWarn2);
+ if (!ImageSelector.TryGetSelectedMedia(out args.status.imageService, out args.status.imagePath))
return;
- }
}
RunAsync(args);
- //Google検索(試験実装)
- if (StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) && StatusText.Text.Trim().Length > 7)
- {
- string tmp = string.Format(Properties.Resources.SearchItem2Url, Uri.EscapeUriString(StatusText.Text.Substring(7)));
- OpenUriAsync(tmp);
- }
-
_reply_to_id = null;
_reply_to_name = null;
StatusText.Text = "";
((Control)ListTab.SelectedTab.Tag).Focus();
urlUndoBuffer = null;
UrlUndoToolStripMenuItem.Enabled = false; //Undoをできないように設定
+
+ //Google検索(試験実装)
+ if (StatusText.Text.StartsWith("Google:", StringComparison.OrdinalIgnoreCase) && StatusText.Text.Trim().Length > 7)
+ {
+ string tmp = string.Format(Properties.Resources.SearchItem2Url, Uri.EscapeUriString(StatusText.Text.Substring(7)));
+ await this.OpenUriAsync(tmp);
+ }
}
private void EndToolStripMenuItem_Click(object sender, EventArgs e)
{
for (int i = 0; i <= args.ids.Count - 1; i++)
{
- var post = tab.IsInnerStorageTabType
- ? tab.Posts[args.ids[i]]
- : _statuses[args.ids[i]];
+ var post = tab.Posts[args.ids[i]];
args.page = i + 1;
bw.ReportProgress(50, MakeStatusMessage(args, false));
{
for (int i = 0; i <= args.ids.Count - 1; i++)
{
- var post = tab.IsInnerStorageTabType
- ? tab.Posts[args.ids[i]]
- : _statuses[args.ids[i]];
+ var post = tab.Posts[args.ids[i]];
args.page = i + 1;
bw.ReportProgress(50, MakeStatusMessage(args, false));
case MyCommon.WORKERTYPE.PostMessage:
bw.ReportProgress(200);
- if (string.IsNullOrEmpty(args.status.imagePath))
+ if (args.status.imagePath == null || args.status.imagePath.Length == 0 || string.IsNullOrEmpty(args.status.imagePath[0]))
{
ret = tw.PostStatus(args.status.status, args.status.inReplyToId);
}
else
{
- ret = this.pictureService[args.status.imageService].Upload(ref args.status.imagePath,
- ref args.status.status,
- args.status.inReplyToId);
+ var service = ImageSelector.GetService(args.status.imageService);
+ try
+ {
+ service.PostStatusAsync(args.status.status, args.status.inReplyToId, args.status.imagePath)
+ .Wait();
+ }
+ catch (AggregateException ex)
+ {
+ ret = ex.InnerException.Message;
+ }
}
bw.ReportProgress(300);
rslt.status = args.status;
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:
{
post = _statuses[rslt.sIds[i]];
}
- ChangeCacheStyleRead(post.IsRead, idx, _curTab);
+ ChangeCacheStyleRead(post.IsRead, idx);
}
if (idx == _curItemIndex) DispSelectedPost(true); //選択アイテム再表示
}
{
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:
//_waitFollower = false
if (SettingDialog.TwitterConfiguration.PhotoSizeLimit != 0)
{
- pictureService["Twitter"].Configuration("MaxUploadFilesize", SettingDialog.TwitterConfiguration.PhotoSizeLimit);
+ foreach (var service in this.ImageSelector.GetServices())
+ {
+ service.UpdateTwitterConfiguration(this.SettingDialog.TwitterConfiguration);
+ }
}
this.PurgeListViewItemCache();
if (_curList != null) _curList.Refresh();
}
}
+ private async Task RefreshMuteUserIdsAsync()
+ {
+ this.StatusLabel.Text = Properties.Resources.UpdateMuteUserIds_Start;
+
+ try
+ {
+ await tw.RefreshMuteUserIdsAsync();
+ }
+ catch (WebApiException ex)
+ {
+ this.StatusLabel.Text = string.Format(Properties.Resources.UpdateMuteUserIds_Error, ex.Message);
+ return;
+ }
+
+ this.StatusLabel.Text = Properties.Resources.UpdateMuteUserIds_Finish;
+ }
+
private void RemovePostFromFavTab(Int64[] ids)
{
string favTabName = _statuses.GetTabByType(MyCommon.TabUsageType.Favorites).TabName;
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;
}
foreach (int idx in _curList.SelectedIndices)
{
- ChangeCacheStyleRead(true, idx, _curTab);
+ ChangeCacheStyleRead(true, idx);
}
ColorizeList();
}
}
foreach (int idx in _curList.SelectedIndices)
{
- ChangeCacheStyleRead(false, idx, _curTab);
+ ChangeCacheStyleRead(false, idx);
}
ColorizeList();
}
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);
- this.CreatePictureServices();
+ 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);
try
{
// タブの表示位置の決定
SetTabAlignment();
+ SplitContainer1.IsPanelInverted = !SettingDialog.StatusAreaAtBottom;
+
+ var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
+ imgazyobizinet.Enabled = this.SettingDialog.EnableImgAzyobuziNet;
+ imgazyobizinet.DisabledInDM = this.SettingDialog.ImgAzyobuziNetDisabledInDM;
+
PlaySoundMenuItem.Checked = SettingDialog.PlaySound;
this.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound;
_fntUnread = SettingDialog.FontUnread;
try
{
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader = detailHtmlFormatMono1;
- detailHtmlFormatFooter = detailHtmlFormatMono7;
- }
- else
- {
- detailHtmlFormatHeader = detailHtmlFormat1;
- detailHtmlFormatFooter = detailHtmlFormat7;
- }
- detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString();
- if (SettingDialog.IsMonospace)
- {
- detailHtmlFormatHeader += detailHtmlFormatMono6;
- }
- else
- {
- detailHtmlFormatHeader += detailHtmlFormat6;
- }
+ InitDetailHtmlFormat();
}
catch (Exception ex)
{
try
{
+ var oldIconCol = _iconCol;
+
+ if (SettingDialog.IconSz != oldIconSz)
+ ApplyListViewIconSize(SettingDialog.IconSz);
+
foreach (TabPage tp in ListTab.TabPages)
{
DetailsListView lst = (DetailsListView)tp.Tag;
lst.Font = _fntReaded;
lst.BackColor = _clListBackcolor;
- if (SettingDialog.IconSz != oldIconSz)
- ApplyListViewIconSize(lst);
+ if (_iconCol != oldIconCol)
+ ResetColumns(lst);
}
}
}
if (uid != tw.Username) this.doGetFollowersMenu();
- SetImageServiceCombo();
if (SettingDialog.IsNotifyUseGrowl) gh.RegisterGrowl();
try
{
/// </summary>
private void SetTabAlignment()
{
- ListTab.Alignment = (SettingDialog.ViewTabBottom ? TabAlignment.Bottom : TabAlignment.Top);
- }
+ var newAlignment = SettingDialog.ViewTabBottom ? TabAlignment.Bottom : TabAlignment.Top;
+ if (ListTab.Alignment == newAlignment) return;
- private void ApplyListViewIconSize(DetailsListView list)
- {
- using (ControlTransaction.Update(list))
- using (ControlTransaction.Layout(list, false))
+ //現在の選択状態を退避
+ Dictionary<string, long[]> selId = new Dictionary<string, long[]>();
+ Dictionary<string, long[]> focusedId = new Dictionary<string, long[]>();
+ SaveSelectedStatus(selId, focusedId);
+
+ ListTab.Alignment = newAlignment;
+
+ //選択状態を復帰
+ foreach (TabPage tab in ListTab.TabPages)
{
- // アイコンサイズの再設定
- _iconCol = false;
- switch (SettingDialog.IconSz)
- {
- case MyCommon.IconSizes.IconNone:
- _iconSz = 0;
- break;
- case MyCommon.IconSizes.Icon16:
- _iconSz = 16;
- break;
- case MyCommon.IconSizes.Icon24:
- _iconSz = 26;
- break;
- case MyCommon.IconSizes.Icon48:
- _iconSz = 48;
- break;
- case MyCommon.IconSizes.Icon48_2:
- _iconSz = 48;
- _iconCol = true;
- break;
- }
- if (_iconSz == 0)
- {
- tw.GetIcon = false;
- }
- else
+ DetailsListView lst = (DetailsListView)tab.Tag;
+ TabClass tabInfo = _statuses.Tabs[tab.Text];
+ using (ControlTransaction.Update(lst))
{
- tw.GetIcon = true;
- tw.IconSize = _iconSz;
+ this.SelectListItem(lst,
+ tabInfo.IndexOf(selId[tab.Text]),
+ tabInfo.IndexOf(focusedId[tab.Text]));
}
+ }
+ }
- if (_iconSz > 0)
- {
- // ディスプレイの DPI 設定を考慮したサイズを設定する
- list.SmallImageList.ImageSize = new Size(
- (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Width),
- (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Height));
- }
- else
- {
- list.SmallImageList.ImageSize = new Size(1, 1);
- }
+ private void ApplyListViewIconSize(MyCommon.IconSizes iconSz)
+ {
+ // アイコンサイズの再設定
+ _iconCol = false;
+ switch (iconSz)
+ {
+ case MyCommon.IconSizes.IconNone:
+ _iconSz = 0;
+ break;
+ case MyCommon.IconSizes.Icon16:
+ _iconSz = 16;
+ break;
+ case MyCommon.IconSizes.Icon24:
+ _iconSz = 26;
+ break;
+ case MyCommon.IconSizes.Icon48:
+ _iconSz = 48;
+ break;
+ case MyCommon.IconSizes.Icon48_2:
+ _iconSz = 48;
+ _iconCol = true;
+ break;
+ }
+
+ if (_iconSz > 0)
+ {
+ // ディスプレイの DPI 設定を考慮したサイズを設定する
+ _listViewImageList.ImageSize = new Size(
+ 1,
+ (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Height));
+ }
+ else
+ {
+ _listViewImageList.ImageSize = new Size(1, 1);
+ }
+ }
+ private void ResetColumns(DetailsListView list)
+ {
+ using (ControlTransaction.Update(list))
+ using (ControlTransaction.Layout(list, false))
+ {
// カラムヘッダの再設定
list.ColumnClick -= MyList_ColumnClick;
list.DrawColumnHeader -= MyList_DrawColumnHeader;
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)
_listCustom.GridLines = SettingDialog.ShowGrid;
_listCustom.AllowDrop = true;
- _listCustom.SmallImageList = new ImageList();
- if (_iconSz > 0)
- {
- // ディスプレイの DPI 設定を考慮したサイズを設定する
- _listCustom.SmallImageList.ImageSize = new Size(
- (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Width),
- (int)Math.Ceiling(this._iconSz * this.currentScaleFactor.Height));
- }
- else
- {
- _listCustom.SmallImageList.ImageSize = new Size(1, 1);
- }
+ _listCustom.SmallImageList = _listViewImageList;
InitColumns(_listCustom, startup);
_listCustom.ColumnClick += MyList_ColumnClick;
_listCustom.DrawColumnHeader += MyList_DrawColumnHeader;
_listCustom.DragDrop += TweenMain_DragDrop;
+ _listCustom.DragEnter += TweenMain_DragEnter;
_listCustom.DragOver += TweenMain_DragOver;
_listCustom.DrawItem += MyList_DrawItem;
_listCustom.MouseClick += MyList_MouseClick;
_listCustom.ColumnClick -= MyList_ColumnClick;
_listCustom.DrawColumnHeader -= MyList_DrawColumnHeader;
_listCustom.DragDrop -= TweenMain_DragDrop;
+ _listCustom.DragEnter -= TweenMain_DragEnter;
_listCustom.DragOver -= TweenMain_DragOver;
_listCustom.DrawItem -= MyList_DrawItem;
_listCustom.MouseClick -= MyList_MouseClick;
_listCustom.ColumnHeaderContextMenuStrip = null;
_listCustom.Font = null;
- _listCustom.SmallImageList.Dispose();
_listCustom.SmallImageList = null;
_listCustom.ListViewItemSorter = null;
// pLen += m.Result("${url}").Length - SettingDialog.TwitterConfiguration.ShortUrlLength;
//}
}
- if (ImageSelectionPanel.Visible && ImageSelectedPicture.Tag != null && !string.IsNullOrEmpty(this.ImageService))
+ if (ImageSelector.Visible && !string.IsNullOrEmpty(ImageSelector.ServiceName))
{
pLen -= SettingDialog.TwitterConfiguration.CharactersReservedPerMedia;
}
finally { this.itemCacheLock.ExitUpgradeableReadLock(); }
}
- private void MyList_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
+ private async void MyList_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
- ListViewItem cacheItem = null;
+ ListViewItem item = null;
PostClass cacheItemPost = null;
- this.TryGetListViewItemCache(e.ItemIndex, out cacheItem, out cacheItemPost);
+ if (_curList.Equals(sender))
+ this.TryGetListViewItemCache(e.ItemIndex, out item, out cacheItemPost);
- if (cacheItem != null)
- {
- e.Item = cacheItem;
- }
- else
+ if (item == null)
{
//A cache miss, so create a new ListViewItem and pass it back.
TabPage tb = (TabPage)((DetailsListView)sender).Parent;
try
{
- e.Item = CreateItem(tb,
- _statuses[tb.Text, e.ItemIndex],
- e.ItemIndex);
+ item = this.CreateItem(tb, _statuses[tb.Text, e.ItemIndex], e.ItemIndex);
}
catch (Exception)
{
//不正な要求に対する間に合わせの応答
string[] sitem = {"", "", "", "", "", "", "", ""};
- e.Item = new ImageListViewItem(sitem);
+ item = new ImageListViewItem(sitem);
}
}
+
+ // e.Item に値をセットする前に await しないこと
+ e.Item = item;
+
+ await ((ImageListViewItem)item).GetImageAsync();
}
private void CreateCache(int StartIndex, int EndIndex)
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;
//未読管理していなかったら既読として扱う
return itm;
}
- private void MyList_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
+ /// <summary>
+ /// 全てのタブの振り分けルールを反映し直します
+ /// </summary>
+ private void ApplyPostFilters()
{
- e.DrawDefault = true;
- }
+ try
+ {
+ this.Cursor = Cursors.WaitCursor;
+
+ this.PurgeListViewItemCache();
+ this._curPost = null;
+ this._curItemIndex = -1;
+ this._statuses.FilterAll();
+
+ foreach (TabPage tabPage in this.ListTab.TabPages)
+ {
+ var tab = this._statuses.Tabs[tabPage.Text];
+
+ var listview = (DetailsListView)tabPage.Tag;
+ listview.VirtualListSize = tab.AllCount;
+
+ if (this.SettingDialog.TabIconDisp)
+ {
+ if (tab.UnreadCount > 0)
+ tabPage.ImageIndex = 0;
+ else
+ tabPage.ImageIndex = -1;
+ }
+ }
+
+ if (!this.SettingDialog.TabIconDisp)
+ this.ListTab.Refresh();
+ }
+ finally
+ {
+ this.Cursor = Cursors.Default;
+ }
+ }
+
+ private void MyList_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
+ {
+ e.DrawDefault = true;
+ }
private void MyList_HScrolled(object sender, EventArgs e)
{
{
if (e.State == 0) return;
e.DrawDefault = false;
+
+ SolidBrush brs2 = null;
if (!e.Item.Selected) //e.ItemStateでうまく判定できない???
{
- SolidBrush brs2 = null;
-
if (e.Item.BackColor == _clSelf)
brs2 = _brsBackColorMine;
else if (e.Item.BackColor == _clAtSelf)
brs2 = _brsBackColorAtTo;
else
brs2 = _brsBackColorNone;
-
- e.Graphics.FillRectangle(brs2, e.Bounds);
}
else
{
//選択中の行
if (((Control)sender).Focused)
- e.Graphics.FillRectangle(_brsHighLight, e.Bounds);
+ brs2 = _brsHighLight;
else
- e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds);
+ brs2 = _brsDeactiveSelection;
}
- if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused) e.DrawFocusRectangle();
+ e.Graphics.FillRectangle(brs2, e.Bounds);
+ e.DrawFocusRectangle();
this.DrawListViewItemIcon(e);
}
//アイコン以外の列
RectangleF rct = e.Bounds;
rct.Width = e.Header.Width;
+ int fontHeight = e.Item.Font.Height;
if (_iconCol)
{
- rct.Y += e.Item.Font.Height;
- rct.Height -= e.Item.Font.Height;
+ rct.Y += fontHeight;
+ rct.Height -= fontHeight;
}
int heightDiff;
- int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, e.Item.Font.Height, out heightDiff));
+ int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, fontHeight, out heightDiff));
- //if (heightDiff > e.Item.Font.Height * 0.7)
+ //if (heightDiff > fontHeight * 0.7)
//{
- // rct.Height += e.Item.Font.Height;
+ // rct.Height += fontHeight;
// drawLineCount += 1;
//}
if (!_iconCol && drawLineCount <= 1)
{
//rct.Inflate(0, heightDiff / -2);
- //rct.Height += e.Item.Font.Height / 2;
+ //rct.Height += fontHeight / 2;
}
- else if (heightDiff < e.Item.Font.Height * 0.7)
+ else if (heightDiff < fontHeight * 0.7)
{
//最終行が70%以上欠けていたら、最終行は表示しない
- //rct.Height = (float)((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2));
- rct.Height = (e.Item.Font.Height * drawLineCount) - 1;
+ //rct.Height = (float)((fontHeight * drawLineCount) + (fontHeight / 2));
+ rct.Height = (fontHeight * drawLineCount) - 1;
}
else
{
//if (!_iconCol && drawLineCount > 1)
//{
- // rct.Y += e.Item.Font.Height * 0.2;
- // if (heightDiff >= e.Item.Font.Height * 0.8) rct.Height -= e.Item.Font.Height * 0.2;
+ // rct.Y += fontHeight * 0.2;
+ // if (heightDiff >= fontHeight * 0.8) rct.Height -= fontHeight * 0.2;
//}
if (rct.Width > 0)
if (_iconCol)
{
- RectangleF rctB = e.Bounds;
+ Rectangle rctB = e.Bounds;
rctB.Width = e.Header.Width;
- rctB.Height = e.Item.Font.Height;
+ rctB.Height = fontHeight;
using (Font fnt = new Font(e.Item.Font, FontStyle.Bold))
{
TextRenderer.DrawText(e.Graphics,
e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
fnt,
- Rectangle.Round(rctB),
+ rctB,
color,
TextFormatFlags.SingleLine |
TextFormatFlags.EndEllipsis |
private void DrawListViewItemIcon(DrawListViewItemEventArgs e)
{
+ if (_iconSz == 0) return;
+
ImageListViewItem item = (ImageListViewItem)e.Item;
//e.Bounds.Leftが常に0を指すから自前で計算
Rectangle itemRect = item.Bounds;
- itemRect.Width = e.Item.ListView.Columns[0].Width;
+ var col0 = e.Item.ListView.Columns[0];
+ itemRect.Width = col0.Width;
- foreach (ColumnHeader clm in e.Item.ListView.Columns)
+ if (col0.DisplayIndex > 0)
{
- if (clm.DisplayIndex < e.Item.ListView.Columns[0].DisplayIndex)
- itemRect.X += clm.Width;
+ foreach (ColumnHeader clm in e.Item.ListView.Columns)
+ {
+ if (clm.DisplayIndex < col0.DisplayIndex)
+ itemRect.X += clm.Width;
+ }
}
// ディスプレイの DPI 設定を考慮したアイコンサイズ
var realStateSize = new SizeF(16 * this.currentScaleFactor.Width, 16 * this.currentScaleFactor.Height).ToSize();
Rectangle iconRect;
- Rectangle stateRect;
- if (item.Image != null)
+ var img = item.Image;
+ if (img != null)
{
iconRect = Rectangle.Intersect(new Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, realIconSize), itemRect);
iconRect.Offset(0, Math.Max(0, (itemRect.Height - realIconSize.Height) / 2));
- stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + iconRect.Width + 2, iconRect.Y), realStateSize), itemRect);
+
+ if (iconRect.Width > 0)
+ {
+ e.Graphics.FillRectangle(Brushes.White, iconRect);
+ e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
+ try
+ {
+ e.Graphics.DrawImage(img.Image, iconRect);
+ }
+ catch (ArgumentException)
+ {
+ item.RefreshImageAsync();
+ }
+ }
}
else
{
iconRect = Rectangle.Intersect(new Rectangle(e.Item.GetBounds(ItemBoundsPortion.Icon).Location, new Size(1, 1)), itemRect);
//iconRect.Offset(0, Math.Max(0, (itemRect.Height - realIconSize.Height) / 2));
- stateRect = Rectangle.Intersect(new Rectangle(new Point(iconRect.X + iconRect.Width + 2, iconRect.Y), realStateSize), itemRect);
- }
-
- var img = item.Image;
- if (img != null && iconRect.Width > 0)
- {
- e.Graphics.FillRectangle(Brushes.White, iconRect);
- e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
- try
- {
- e.Graphics.DrawImage(img.Image, iconRect);
- }
- catch (ArgumentException)
- {
- item.RefreshImage();
- }
}
- 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);
}
}
}
private void MenuItemSubSearch_Click(object sender, EventArgs e)
{
- //検索メニュー
- SearchDialog.Owner = this;
- if (SearchDialog.ShowDialog() == DialogResult.Cancel)
+ // 検索メニュー
+ this.ShowSearchDialog();
+ }
+
+ private void MenuItemSearchNext_Click(object sender, EventArgs e)
+ {
+ var previousSearch = this.SearchDialog.ResultOptions;
+ if (previousSearch == null || previousSearch.Type != SearchWordDialog.SearchType.Timeline)
{
- this.TopMost = SettingDialog.AlwaysTop;
+ this.SearchDialog.Reset();
+ this.ShowSearchDialog();
return;
}
- this.TopMost = SettingDialog.AlwaysTop;
- if (!string.IsNullOrEmpty(SearchDialog.SWord))
- {
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.DialogSearch);
- }
+ // 次を検索
+ this.DoTabSearch(
+ previousSearch.Query,
+ previousSearch.CaseSensitive,
+ previousSearch.UseRegex,
+ SEARCHTYPE.NextSearch);
}
- private void MenuItemSearchNext_Click(object sender, EventArgs e)
+ private void MenuItemSearchPrev_Click(object sender, EventArgs e)
{
- //次を検索
- if (string.IsNullOrEmpty(SearchDialog.SWord))
+ var previousSearch = this.SearchDialog.ResultOptions;
+ if (previousSearch == null || previousSearch.Type != SearchWordDialog.SearchType.Timeline)
{
- if (SearchDialog.ShowDialog() == DialogResult.Cancel)
- {
- this.TopMost = SettingDialog.AlwaysTop;
- return;
- }
- this.TopMost = SettingDialog.AlwaysTop;
- if (string.IsNullOrEmpty(SearchDialog.SWord)) return;
-
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.DialogSearch);
+ this.SearchDialog.Reset();
+ this.ShowSearchDialog();
+ return;
}
+
+ // 前を検索
+ this.DoTabSearch(
+ previousSearch.Query,
+ previousSearch.CaseSensitive,
+ previousSearch.UseRegex,
+ SEARCHTYPE.PrevSearch);
+ }
+
+ /// <summary>
+ /// 検索ダイアログを表示し、検索を実行します
+ /// </summary>
+ private void ShowSearchDialog()
+ {
+ // Recentタブの検索時以外では「新規タブに表示」ボタンを無効化する
+ if (this._statuses.Tabs[this._curTab.Text].TabType == MyCommon.TabUsageType.Home)
+ this.SearchDialog.DisableNewTabButton = false;
else
+ this.SearchDialog.DisableNewTabButton = true;
+
+ if (this.SearchDialog.ShowDialog(this) != DialogResult.OK)
{
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.NextSearch);
+ this.TopMost = this.SettingDialog.AlwaysTop;
+ return;
}
- }
+ this.TopMost = this.SettingDialog.AlwaysTop;
- private void MenuItemSearchPrev_Click(object sender, EventArgs e)
- {
- //前を検索
- if (string.IsNullOrEmpty(SearchDialog.SWord))
+ var searchOptions = this.SearchDialog.ResultOptions;
+ if (searchOptions.Type == SearchWordDialog.SearchType.Timeline)
{
- if (SearchDialog.ShowDialog() == DialogResult.Cancel)
+ if (searchOptions.NewTab)
{
- this.TopMost = SettingDialog.AlwaysTop;
- return;
+ var tabName = searchOptions.Query;
+
+ try
+ {
+ tabName = this._statuses.MakeTabName(tabName);
+ }
+ catch (TabException ex)
+ {
+ MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ this.AddNewTab(tabName, false, MyCommon.TabUsageType.UserDefined);
+ this._statuses.AddTab(tabName, MyCommon.TabUsageType.UserDefined, null);
+
+ var filter = new PostFilterRule
+ {
+ FilterBody = new[] { searchOptions.Query },
+ UseRegex = searchOptions.UseRegex,
+ CaseSensitive = searchOptions.CaseSensitive,
+ };
+ this._statuses.Tabs[tabName].AddFilter(filter);
+
+ var tabPage = this.ListTab.TabPages.Cast<TabPage>()
+ .First(x => x.Text == tabName);
+
+ this.ListTab.SelectedTab = tabPage;
+ this.ListTabSelect(tabPage);
+
+ this.ApplyPostFilters();
+ this.SaveConfigsTabs();
+ }
+ else
+ {
+ this.DoTabSearch(
+ searchOptions.Query,
+ searchOptions.CaseSensitive,
+ searchOptions.UseRegex,
+ SEARCHTYPE.DialogSearch);
}
- this.TopMost = SettingDialog.AlwaysTop;
- if (string.IsNullOrEmpty(SearchDialog.SWord)) return;
}
-
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.PrevSearch);
+ else if (searchOptions.Type == SearchWordDialog.SearchType.Public)
+ {
+ this.AddNewTabForSearch(searchOptions.Query);
+ }
}
private void AboutMenuItem_Click(object sender, EventArgs e)
int idx = -1;
DetailsListView lst = null;
- if (ImageSelectionPanel.Enabled)
+ if (ImageSelector.Enabled)
return;
//現在タブから最終タブまで探索
}
}
- private void VerUpMenuItem_Click(object sender, EventArgs e)
+ private async void VerUpMenuItem_Click(object sender, EventArgs e)
{
- CheckNewVersion();
+ await this.CheckNewVersion(false);
}
private void RunTweenUp()
}
}
- private void CheckNewVersion(bool startup = false)
+ public class VersionInfo
{
- if (ApplicationSettings.VersionInfoUrl == null)
- return; // 更新チェック無効化
-
- if (string.IsNullOrEmpty(MyCommon.fileVersion))
- {
- return;
- }
+ public Version Version { get; set; }
+ public Uri DownloadUri { get; set; }
+ public string ReleaseNote { get; set; }
+ }
- string retMsg;
- try
- {
- retMsg = tw.GetVersionInfo();
- }
- catch
- {
- retMsg = "";
- }
+ /// <summary>
+ /// OpenTween の最新バージョンの情報を取得します
+ /// </summary>
+ public async Task<VersionInfo> GetVersionInfoAsync()
+ {
+ var versionInfoUrl = new Uri(ApplicationSettings.VersionInfoUrl + "?" +
+ DateTime.Now.ToString("yyMMddHHmmss") + Environment.TickCount);
- if (string.IsNullOrEmpty(retMsg))
- {
- StatusLabel.Text = Properties.Resources.CheckNewVersionText9;
- if (!startup) MessageBox.Show(Properties.Resources.CheckNewVersionText10, MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2), MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
- return;
- }
+ var responseText = await Networking.Http.GetStringAsync(versionInfoUrl)
+ .ConfigureAwait(false);
// 改行2つで前後パートを分割(前半がバージョン番号など、後半が詳細テキスト)
- string[] msgPart = retMsg.Split(new string[] {"\n\n", "\r\n\r\n"}, 2, StringSplitOptions.None);
+ var msgPart = responseText.Split(new[] { "\n\n", "\r\n\r\n" }, 2, StringSplitOptions.None);
- string[] msgHeader = msgPart[0].Split(new string[] {"\n", "\r\n"}, StringSplitOptions.None);
- string msgBody = msgPart.Length == 2 ? msgPart[1] : "";
+ var msgHeader = msgPart[0].Split(new[] { "\n", "\r\n" }, StringSplitOptions.None);
+ var msgBody = msgPart.Length == 2 ? msgPart[1] : "";
msgBody = Regex.Replace(msgBody, "(?<!\r)\n", "\r\n"); // LF -> CRLF
- string currentVersion = msgHeader[0];
- string downloadUrl = msgHeader[1];
+ return new VersionInfo
+ {
+ Version = Version.Parse(msgHeader[0]),
+ DownloadUri = new Uri(msgHeader[1]),
+ ReleaseNote = msgBody,
+ };
+ }
+
+ private async Task CheckNewVersion(bool startup = false)
+ {
+ if (ApplicationSettings.VersionInfoUrl == null)
+ return; // 更新チェック無効化
- if (currentVersion.Replace(".", "").CompareTo(MyCommon.fileVersion.Replace(".", "")) > 0)
+ try
{
+ var versionInfo = await this.GetVersionInfoAsync();
+
+ if (versionInfo.Version <= Version.Parse(MyCommon.FileVersion))
+ {
+ // 更新不要
+ if (!startup)
+ {
+ var msgtext = string.Format(Properties.Resources.CheckNewVersionText7,
+ MyCommon.GetReadableVersion(), MyCommon.GetReadableVersion(versionInfo.Version));
+ msgtext = MyCommon.ReplaceAppName(msgtext);
+
+ MessageBox.Show(msgtext,
+ MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2),
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ return;
+ }
+
using (var dialog = new UpdateDialog())
{
- dialog.SummaryText = string.Format(Properties.Resources.CheckNewVersionText3, MyCommon.GetReadableVersion(currentVersion));
- dialog.DetailsText = msgBody;
+ dialog.SummaryText = string.Format(Properties.Resources.CheckNewVersionText3,
+ MyCommon.GetReadableVersion(versionInfo.Version));
+ dialog.DetailsText = versionInfo.ReleaseNote;
+
if (dialog.ShowDialog(this) == DialogResult.Yes)
{
- this.OpenUriAsync(downloadUrl);
+ await this.OpenUriAsync(versionInfo.DownloadUri.OriginalString);
}
}
}
- else
+ catch (Exception)
{
+ this.StatusLabel.Text = Properties.Resources.CheckNewVersionText9;
if (!startup)
{
- var msgtext = MyCommon.ReplaceAppName(string.Format(Properties.Resources.CheckNewVersionText7, MyCommon.GetReadableVersion(), MyCommon.GetReadableVersion(currentVersion)));
- MessageBox.Show(msgtext, MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2), MessageBoxButtons.OK, MessageBoxIcon.Information);
+ MessageBox.Show(Properties.Resources.CheckNewVersionText10,
+ MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2),
+ MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
}
}
}
return detailHtmlFormatHeader + orgdata + detailHtmlFormatFooter;
}
- private void DisplayItemImage_Downloaded(object sender, EventArgs e)
+ private async void DisplayItemImage_Downloaded(object sender, EventArgs e)
{
if (sender.Equals(displayItem))
{
var img = displayItem.Image;
try
{
- UserPicture.Image = img != null ? img.Clone() : null;
+ if (img != null)
+ img = await img.CloneAsync();
+
+ UserPicture.Image = img;
}
catch (Exception)
{
DispSelectedPost(false);
}
- private static PostClass displaypost = new PostClass();
+ private PostClass displayPost = new PostClass();
+
+ /// <summary>
+ /// サムネイルの表示処理を表すタスク
+ /// </summary>
+ private Task thumbnailTask = null;
+
+ /// <summary>
+ /// サムネイル表示に使用する CancellationToken の生成元
+ /// </summary>
+ private CancellationTokenSource thumbnailTokenSource = null;
private void DispSelectedPost(bool forceupdate)
{
if (_curList.SelectedIndices.Count == 0 || _curPost == null)
return;
- if (!forceupdate && _curPost.Equals(displaypost))
+ var oldDisplayPost = this.displayPost;
+ this.displayPost = this._curPost;
+
+ if (!forceupdate && this._curPost.Equals(oldDisplayPost))
return;
- displaypost = _curPost;
if (displayItem != null)
{
displayItem.ImageDownloaded -= this.DisplayItemImage_Downloaded;
displayItem = (ImageListViewItem)_curList.Items[_curList.SelectedIndices[0]];
displayItem.ImageDownloaded += this.DisplayItemImage_Downloaded;
- string dTxt = createDetailHtml(_curPost.IsDeleted ? "(DELETED)" : _curPost.Text);
- if (_curPost.IsDm)
- {
- SourceLinkLabel.Tag = null;
- SourceLinkLabel.Text = "";
- }
- else
+ using (ControlTransaction.Update(this.TableLayoutPanel1))
{
- Match mc = Regex.Match(_curPost.SourceHtml, "<a href=\"(?<sourceurl>.+?)\"");
- if (mc.Success)
+ var sourceText = "";
+ string sourceUrl = null;
+ if (!_curPost.IsDm)
{
- string src = mc.Groups["sourceurl"].Value;
- SourceLinkLabel.Tag = mc.Groups["sourceurl"].Value;
- mc = Regex.Match(src, "^https?://");
- if (!mc.Success)
+ var mc = Regex.Match(_curPost.SourceHtml, "<a href=\"(?<sourceurl>.+?)\"");
+ if (mc.Success)
{
- src = src.Insert(0, "https://twitter.com");
+ var src = mc.Groups["sourceurl"].Value;
+ if (Regex.IsMatch(src, "^https?://"))
+ sourceUrl = src;
+ else
+ sourceUrl = "https://twitter.com/" + src;
}
- SourceLinkLabel.Tag = src;
- }
- else
- {
- SourceLinkLabel.Tag = null;
+
+ if (_curPost.Source != null)
+ sourceText = _curPost.Source;
}
- if (string.IsNullOrEmpty(_curPost.Source))
+ SourceLinkLabel.Text = sourceText;
+ SourceLinkLabel.Tag = sourceUrl;
+ SourceLinkLabel.TabStop = false; // Text を更新すると勝手に true にされる
+
+ string nameText;
+ if (_curPost.IsDm)
{
- SourceLinkLabel.Text = "";
- //SourceLinkLabel.Visible = false;
+ if (_curPost.IsOwl)
+ nameText = "DM FROM <- ";
+ else
+ nameText = "DM TO -> ";
}
else
{
- SourceLinkLabel.Text = _curPost.Source;
- //SourceLinkLabel.Visible = true;
+ nameText = "";
}
- }
- SourceLinkLabel.TabStop = false;
+ nameText += _curPost.ScreenName + "/" + _curPost.Nickname;
+ if (_curPost.RetweetedId != null)
+ nameText += " (RT:" + _curPost.RetweetedBy + ")";
- if (_statuses.Tabs[_curTab.Text].TabType == MyCommon.TabUsageType.DirectMessage && !_curPost.IsOwl)
- {
- NameLabel.Text = "DM TO -> ";
- }
- else if (_statuses.Tabs[_curTab.Text].TabType == MyCommon.TabUsageType.DirectMessage)
- {
- NameLabel.Text = "DM FROM <- ";
- }
- else
- {
- NameLabel.Text = "";
- }
- NameLabel.Text += _curPost.ScreenName + "/" + _curPost.Nickname;
- NameLabel.Tag = _curPost.ScreenName;
- if (!string.IsNullOrEmpty(_curPost.RetweetedBy))
- {
- NameLabel.Text += " (RT:" + _curPost.RetweetedBy + ")";
- }
+ NameLabel.Text = nameText;
+ NameLabel.Tag = _curPost.ScreenName;
- this.ClearUserPicture();
+ var nameForeColor = SystemColors.ControlText;
+ if (_curPost.IsOwl && (this.SettingDialog.OneWayLove || _curPost.IsDm))
+ nameForeColor = this._clOWL;
+ if (_curPost.RetweetedId != null)
+ nameForeColor = this._clRetweet;
+ if (_curPost.IsFav)
+ nameForeColor = this._clFav;
+ NameLabel.ForeColor = nameForeColor;
- if (!string.IsNullOrEmpty(_curPost.ImageUrl))
- {
- var image = IconCache.TryGetFromCache(_curPost.ImageUrl);
- try
+ this.ClearUserPicture();
+
+ if (!string.IsNullOrEmpty(_curPost.ImageUrl))
{
- UserPicture.Image = image != null ? image.Clone() : null;
+ var image = IconCache.TryGetFromCache(_curPost.ImageUrl);
+ try
+ {
+ UserPicture.Image = image != null ? image.Clone() : null;
+ }
+ catch (Exception)
+ {
+ UserPicture.ShowErrorImage();
+ }
}
- catch (Exception)
+
+ DateTimeLabel.Text = _curPost.CreatedAt.ToString();
+
+ if (DumpPostClassToolStripMenuItem.Checked)
{
- UserPicture.ShowErrorImage();
- }
- }
+ StringBuilder sb = new StringBuilder(512);
- NameLabel.ForeColor = System.Drawing.SystemColors.ControlText;
- DateTimeLabel.Text = _curPost.CreatedAt.ToString();
- if (_curPost.IsOwl && (SettingDialog.OneWayLove || _statuses.Tabs[_curTab.Text].TabType == MyCommon.TabUsageType.DirectMessage)) NameLabel.ForeColor = _clOWL;
- if (_curPost.RetweetedId != null) NameLabel.ForeColor = _clRetweet;
- if (_curPost.IsFav) NameLabel.ForeColor = _clFav;
-
- if (DumpPostClassToolStripMenuItem.Checked)
- {
- StringBuilder sb = new StringBuilder(512);
-
- sb.Append("-----Start PostClass Dump<br>");
- sb.AppendFormat("TextFromApi : {0}<br>", _curPost.TextFromApi);
- sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.TextFromApi);
- sb.AppendFormat("StatusId : {0}<br>", _curPost.StatusId.ToString());
- //sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString());
- sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl);
- sb.AppendFormat("InReplyToStatusId : {0}<br>", _curPost.InReplyToStatusId.ToString());
- sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser);
- sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString());
- sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString());
- sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString());
- sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString());
- sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString());
- sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString());
- sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString());
- sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString());
-
- foreach (string nm in _curPost.ReplyToList)
- {
- sb.AppendFormat("ReplyToList : {0}<br>", nm);
- }
-
- sb.AppendFormat("ScreenName : {0}<br>", _curPost.ScreenName);
- sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname);
- sb.AppendFormat("Text : {0}<br>", _curPost.Text);
- sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Text);
- sb.AppendFormat("CreatedAt : {0}<br>", _curPost.CreatedAt.ToString());
- sb.AppendFormat("Source : {0}<br>", _curPost.Source);
- sb.AppendFormat("UserId : {0}<br>", _curPost.UserId);
- sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit);
- sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy);
- sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId);
- sb.AppendFormat("SearchTabName : {0}<br>", _curPost.RelTabName);
- sb.Append("-----End PostClass Dump<br>");
-
- PostBrowser.Visible = false;
- PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString() + detailHtmlFormatFooter;
- PostBrowser.Visible = true;
- }
- else
- {
- try
+ sb.Append("-----Start PostClass Dump<br>");
+ sb.AppendFormat("TextFromApi : {0}<br>", _curPost.TextFromApi);
+ sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.TextFromApi);
+ sb.AppendFormat("StatusId : {0}<br>", _curPost.StatusId.ToString());
+ //sb.AppendFormat("ImageIndex : {0}<br>", _curPost.ImageIndex.ToString());
+ sb.AppendFormat("ImageUrl : {0}<br>", _curPost.ImageUrl);
+ sb.AppendFormat("InReplyToStatusId : {0}<br>", _curPost.InReplyToStatusId.ToString());
+ sb.AppendFormat("InReplyToUser : {0}<br>", _curPost.InReplyToUser);
+ sb.AppendFormat("IsDM : {0}<br>", _curPost.IsDm.ToString());
+ sb.AppendFormat("IsFav : {0}<br>", _curPost.IsFav.ToString());
+ sb.AppendFormat("IsMark : {0}<br>", _curPost.IsMark.ToString());
+ sb.AppendFormat("IsMe : {0}<br>", _curPost.IsMe.ToString());
+ sb.AppendFormat("IsOwl : {0}<br>", _curPost.IsOwl.ToString());
+ sb.AppendFormat("IsProtect : {0}<br>", _curPost.IsProtect.ToString());
+ sb.AppendFormat("IsRead : {0}<br>", _curPost.IsRead.ToString());
+ sb.AppendFormat("IsReply : {0}<br>", _curPost.IsReply.ToString());
+
+ foreach (string nm in _curPost.ReplyToList)
+ {
+ sb.AppendFormat("ReplyToList : {0}<br>", nm);
+ }
+
+ sb.AppendFormat("ScreenName : {0}<br>", _curPost.ScreenName);
+ sb.AppendFormat("NickName : {0}<br>", _curPost.Nickname);
+ sb.AppendFormat("Text : {0}<br>", _curPost.Text);
+ sb.AppendFormat("(PlainText) : <xmp>{0}</xmp><br>", _curPost.Text);
+ sb.AppendFormat("CreatedAt : {0}<br>", _curPost.CreatedAt.ToString());
+ sb.AppendFormat("Source : {0}<br>", _curPost.Source);
+ sb.AppendFormat("UserId : {0}<br>", _curPost.UserId);
+ sb.AppendFormat("FilterHit : {0}<br>", _curPost.FilterHit);
+ sb.AppendFormat("RetweetedBy : {0}<br>", _curPost.RetweetedBy);
+ sb.AppendFormat("RetweetedId : {0}<br>", _curPost.RetweetedId);
+ sb.AppendFormat("SearchTabName : {0}<br>", _curPost.RelTabName);
+ sb.Append("-----End PostClass Dump<br>");
+
+ PostBrowser.DocumentText = detailHtmlFormatHeader + sb.ToString() + detailHtmlFormatFooter;
+ }
+ else
{
- if (PostBrowser.DocumentText != dTxt)
+ // 同じIDのツイートであれば WebBrowser とサムネイルの更新を行わない
+ // (同一ツイートの RT は文面が同じであるため同様に更新しない)
+ if (_curPost.StatusId != oldDisplayPost.StatusId)
{
- PostBrowser.Visible = false;
- PostBrowser.DocumentText = dTxt;
+ this.PostBrowser.DocumentText =
+ this.createDetailHtml(_curPost.IsDeleted ? "(DELETED)" : _curPost.Text);
+
+ this.PostBrowser.Document.Window.ScrollTo(0, 0);
this.SplitContainer3.Panel2Collapsed = true;
if (this.IsPreviewEnable)
- this.tweetThumbnail1.ShowThumbnailAsync(_curPost);
+ {
+ if (this.thumbnailTokenSource != null)
+ {
+ var oldTokenSource = this.thumbnailTokenSource;
+
+ var cancelTask = Task.Run(() => oldTokenSource.Cancel());
+
+ Task.WhenAll(this.thumbnailTask, cancelTask)
+ .ContinueWith(_ => oldTokenSource.Dispose(), TaskScheduler.Default);
+ }
+
+ this.thumbnailTokenSource = new CancellationTokenSource();
+
+ var token = this.thumbnailTokenSource.Token;
+ this.thumbnailTask = this.tweetThumbnail1.ShowThumbnailAsync(_curPost, token);
+ }
}
}
- catch (System.Runtime.InteropServices.COMException)
- {
- //原因不明
- }
- catch (UriFormatException)
- {
- PostBrowser.DocumentText = dTxt;
- }
- finally
- {
- PostBrowser.Visible = true;
- }
}
}
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以外
string inReplyToTabName;
long inReplyToId = _curPost.InReplyToStatusId.Value;
string inReplyToUser = _curPost.InReplyToUser;
- Dictionary<long, PostClass> curTabPosts;
-
- if (_statuses.Tabs[_curTab.Text].IsInnerStorageTabType)
- curTabPosts = curTabClass.Posts;
- else
- curTabPosts = _statuses.Posts;
+ //Dictionary<long, PostClass> curTabPosts = curTabClass.Posts;
var inReplyToPosts = from tab in _statuses.Tabs.Values
orderby tab != curTabClass
- from post in ((Dictionary<long, PostClass>)(tab.IsInnerStorageTabType ? tab.Posts : _statuses.Posts)).Values
+ from post in tab.Posts.Values
where post.StatusId == inReplyToId
let index = tab.IndexOf(post.StatusId)
where index != -1
if (_curPost == null) return;
TabClass curTabClass = _statuses.Tabs[_curTab.Text];
- Dictionary<long, PostClass> curTabPosts = curTabClass.IsInnerStorageTabType ? curTabClass.Posts : _statuses.Posts;
+ //Dictionary<long, PostClass> curTabPosts = curTabClass.Posts;
if (parallel)
{
if (_curPost.InReplyToStatusId != null)
{
var posts = from t in _statuses.Tabs
- from p in t.Value.IsInnerStorageTabType ? t.Value.Posts : _statuses.Posts
+ from p in t.Value.Posts
where p.Value.StatusId != _curPost.StatusId && p.Value.InReplyToStatusId == _curPost.InReplyToStatusId
let indexOf = t.Value.IndexOf(p.Value.StatusId)
where indexOf > -1
if (replyChains == null || replyChains.Count < 1)
{
var posts = from t in _statuses.Tabs
- from p in t.Value.IsInnerStorageTabType ? t.Value.Posts : _statuses.Posts
+ from p in t.Value.Posts
where p.Value.InReplyToStatusId == _curPost.StatusId
let indexOf = t.Value.IndexOf(p.Value.StatusId)
where indexOf > -1
private void GoBackSelectPostChain()
{
- try
+ if (this.selectPostChains.Count > 1)
{
- this.selectPostChains.Pop();
- Tuple<TabPage, PostClass> 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
{
- 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));
+ 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;
}
- }
- catch (InvalidOperationException)
- {
+ while (this.selectPostChains.Count > 1);
+
+ if (tp == null)
+ {
+ //状態がおかしいので処理を中断
+ //履歴が残り1つであればクリアしておく
+ if (this.selectPostChains.Count == 1)
+ this.selectPostChains.Clear();
+ return;
+ }
+
+ 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<Tuple<TabPage, PostClass>> p = new Stack<Tuple<TabPage, PostClass>>();
+ if (this.selectPostChains.Count <= 2000) return;
+ var p = new Stack<Tuple<TabPage, PostClass>>(2000);
for (int i = 0; i < 2000; i++)
{
p.Push(this.selectPostChains.Pop());
_cfgCommon.UseAtIdSupplement = SettingDialog.UseAtIdSupplement;
_cfgCommon.UseHashSupplement = SettingDialog.UseHashSupplement;
_cfgCommon.PreviewEnable = SettingDialog.PreviewEnable;
+ _cfgCommon.StatusAreaAtBottom = SettingDialog.StatusAreaAtBottom;
_cfgCommon.Language = SettingDialog.Language;
_cfgCommon.SortOrder = (int)_statuses.SortOrder;
_cfgCommon.AllAtReply = tw.AllAtReply;
_cfgCommon.OpenUserTimeline = SettingDialog.OpenUserTimeline;
_cfgCommon.ListCountApi = SettingDialog.ListCountApi;
- _cfgCommon.UseImageService = ImageServiceCombo.SelectedIndex;
- _cfgCommon.UseImageServiceName = this.ImageService;
+ _cfgCommon.UseImageService = ImageSelector.ServiceIndex;
+ _cfgCommon.UseImageServiceName = ImageSelector.ServiceName;
_cfgCommon.ListDoubleClickAction = SettingDialog.ListDoubleClickAction;
_cfgCommon.UserAppointUrl = SettingDialog.UserAppointUrl;
_cfgCommon.HideDuplicatedRetweets = SettingDialog.HideDuplicatedRetweets;
- _cfgCommon.IsPreviewFoursquare = SettingDialog.IsPreviewFoursquare;
+ _cfgCommon.EnableImgAzyobuziNet = SettingDialog.EnableImgAzyobuziNet;
+ _cfgCommon.ImgAzyobuziNetDisabledInDM = SettingDialog.ImgAzyobuziNetDisabledInDM;
_cfgCommon.MapThumbnailProvider = SettingDialog.MapThumbnailProvider;
_cfgCommon.MapThumbnailHeight = SettingDialog.MapThumbnailHeight;
_cfgCommon.MapThumbnailWidth = SettingDialog.MapThumbnailWidth;
_cfgLocal.PreviewDistance = _mySpDis3;
_cfgLocal.StatusMultiline = StatusText.Multiline;
_cfgLocal.StatusTextHeight = _mySpDis2;
- _cfgLocal.AdSplitterDistance = _myAdSpDis;
_cfgLocal.StatusText = SettingDialog.Status;
_cfgLocal.FontUnread = _fntUnread;
tabSetting.Save();
}
- private /* async */ void OpenURLFileMenuItem_Click(object sender, EventArgs e)
+ private async void OpenURLFileMenuItem_Click(object sender, EventArgs e)
{
string inputText;
var ret = InputDialog.Show(this, Properties.Resources.OpenURL_InputText, Properties.Resources.OpenURL_Caption, out inputText);
}
var statusId = long.Parse(match.Groups["StatusId"].Value);
- var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
- Task.Factory.StartNew(() =>
+ var post = this._statuses[statusId];
+ if (post == null)
+ {
+ try
{
- var post = this._statuses[statusId];
- if (post == null)
+ post = await Task.Run(() =>
{
- var err = this.tw.GetStatusApi(false, statusId, ref post);
+ PostClass newPost = null;
+
+ var err = this.tw.GetStatusApi(false, statusId, ref newPost);
if (!string.IsNullOrEmpty(err))
throw new WebApiException(err);
- }
- return post;
- }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
- .ContinueWith(t =>
- {
- if (t.IsFaulted)
- {
- t.Exception.Flatten().Handle(x => x is WebApiException);
- var message = t.Exception.InnerException.Message;
- MessageBox.Show(this, string.Format(Properties.Resources.OpenURL_LoadFailed, message),
- Properties.Resources.OpenURL_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return newPost;
+ });
+ }
+ catch (WebApiException ex)
+ {
+ var message = ex.Message;
+ MessageBox.Show(this, string.Format(Properties.Resources.OpenURL_LoadFailed, message),
+ Properties.Resources.OpenURL_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
- return;
- }
- try
- {
- this.OpenRelatedTab(t.Result);
- }
- catch (TabException ex)
- {
- MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }, uiScheduler);
+ try
+ {
+ this.OpenRelatedTab(post);
+ }
+ catch (TabException ex)
+ {
+ MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
private void SaveLogMenuItem_Click(object sender, EventArgs e)
_statuses.Tabs[_rclickTabName].SoundFile = (string)((ToolStripComboBox)sender).SelectedItem;
SaveConfigsTabs();
- }
-
- private void DeleteTabMenuItem_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(_rclickTabName) || sender == this.DeleteTbMenuItem) _rclickTabName = ListTab.SelectedTab.Text;
-
- RemoveSpecifiedTab(_rclickTabName, true);
- SaveConfigsTabs();
- }
-
- private void FilterEditMenuItem_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.GetTabByType(MyCommon.TabUsageType.Home).TabName;
- fltDialog.SetCurrent(_rclickTabName);
- fltDialog.ShowDialog(this);
- this.TopMost = SettingDialog.AlwaysTop;
-
- try
- {
- this.Cursor = Cursors.WaitCursor;
- this.PurgeListViewItemCache();
- _curPost = null;
- _curItemIndex = -1;
- _statuses.FilterAll();
- foreach (TabPage tb in ListTab.TabPages)
- {
- ((DetailsListView)tb.Tag).VirtualListSize = _statuses.Tabs[tb.Text].AllCount;
- if (_statuses.Tabs[tb.Text].UnreadCount > 0)
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = 0;
- }
- else
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = -1;
- }
- }
- if (!SettingDialog.TabIconDisp) ListTab.Refresh();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
+ }
+
+ private void DeleteTabMenuItem_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(_rclickTabName) || sender == this.DeleteTbMenuItem) _rclickTabName = ListTab.SelectedTab.Text;
+
+ RemoveSpecifiedTab(_rclickTabName, true);
+ SaveConfigsTabs();
+ }
+
+ private void FilterEditMenuItem_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.GetTabByType(MyCommon.TabUsageType.Home).TabName;
+ fltDialog.SetCurrent(_rclickTabName);
+ fltDialog.ShowDialog(this);
+ this.TopMost = SettingDialog.AlwaysTop;
+
+ this.ApplyPostFilters();
SaveConfigsTabs();
}
{
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);
}
}
}
this.TopMost = SettingDialog.AlwaysTop;
}
- try
- {
- this.Cursor = Cursors.WaitCursor;
- this.PurgeListViewItemCache();
- _curPost = null;
- _curItemIndex = -1;
- _statuses.FilterAll();
- foreach (TabPage tb in ListTab.TabPages)
- {
- ((DetailsListView)tb.Tag).VirtualListSize = _statuses.Tabs[tb.Text].AllCount;
- if (_statuses.Tabs[tb.Text].UnreadCount > 0)
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = 0;
- }
- else
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = -1;
- }
- }
- if (!SettingDialog.TabIconDisp) ListTab.Refresh();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
+ this.ApplyPostFilters();
SaveConfigsTabs();
if (this.ListTab.SelectedTab != null &&
((DetailsListView)this.ListTab.SelectedTab.Tag).SelectedIndices.Count > 0)
if (AtIdSupl.ItemCount != cnt) _modifySettingAtId = true;
}
- try
- {
- this.Cursor = Cursors.WaitCursor;
- this.PurgeListViewItemCache();
- _curPost = null;
- _curItemIndex = -1;
- _statuses.FilterAll();
- foreach (TabPage tb in ListTab.TabPages)
- {
- ((DetailsListView)tb.Tag).VirtualListSize = _statuses.Tabs[tb.Text].AllCount;
- if (_statuses.ContainsTab(tb.Text))
- {
- if (_statuses.Tabs[tb.Text].UnreadCount > 0)
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = 0;
- }
- else
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = -1;
- }
- }
- }
- if (!SettingDialog.TabIconDisp) ListTab.Refresh();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
+ this.ApplyPostFilters();
SaveConfigsTabs();
}
SettingDialog.DispLatestPost != MyCommon.DispTitleEnum.Ver &&
SettingDialog.DispLatestPost != MyCommon.DispTitleEnum.OwnStatus)
{
- foreach (string key in _statuses.Tabs.Keys)
+ foreach (var tab in _statuses.Tabs.Values)
{
- ur += _statuses.Tabs[key].UnreadCount;
- al += _statuses.Tabs[key].AllCount;
+ ur += tab.UnreadCount;
+ al += tab.AllCount;
}
}
StringBuilder slbl = new StringBuilder(256);
try
{
- foreach (string key in _statuses.Tabs.Keys)
+ foreach (var tab in _statuses.Tabs.Values)
{
- ur += _statuses.Tabs[key].UnreadCount;
- al += _statuses.Tabs[key].AllCount;
- if (key.Equals(_curTab.Text))
+ ur += tab.UnreadCount;
+ al += tab.AllCount;
+ if (_curTab != null && tab.TabName.Equals(_curTab.Text))
{
- tur = _statuses.Tabs[key].UnreadCount;
- tal = _statuses.Tabs[key].AllCount;
+ tur = tab.UnreadCount;
+ tal = tab.AllCount;
}
}
}
//_mySize = this.ClientSize; //サイズ保持(最小化・最大化されたまま終了した場合の対応用)
this.DesktopLocation = _cfgLocal.FormLocation;
//_myLoc = this.DesktopLocation; //位置保持(最小化・最大化されたまま終了した場合の対応用)
- //if (_cfgLocal.AdSplitterDistance > this.SplitContainer4.Panel1MinSize &&
- // _cfgLocal.AdSplitterDistance < this.SplitContainer4.Height - this.SplitContainer4.Panel2MinSize - this.SplitContainer4.SplitterWidth)
- //{
- // this.SplitContainer4.SplitterDistance = _cfgLocal.AdSplitterDistance; //Splitterの位置設定
- //}
if (_cfgLocal.SplitterDistance > this.SplitContainer1.Panel1MinSize &&
_cfgLocal.SplitterDistance < this.SplitContainer1.Height - this.SplitContainer1.Panel2MinSize - this.SplitContainer1.SplitterWidth)
{
OpenUriAsync(name.Remove(name.LastIndexOf("_normal"), 7)); // "_normal".Length
}
- private /* async */ void ReloadIconToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void ReloadIconToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this._curPost == null) return;
- var imageUrl = this._curPost.ImageUrl;
- var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
+ await this.UserPicture.SetImageFromTask(async () =>
+ {
+ var imageUrl = this._curPost.ImageUrl;
- this.IconCache.DownloadImageAsync(imageUrl, force: true)
- .ContinueWith(t =>
- {
- this.ClearUserPicture();
+ var image = await this.IconCache.DownloadImageAsync(imageUrl, force: true)
+ .ConfigureAwait(false);
- if (t.IsFaulted)
- {
- t.Exception.Flatten().Handle(x => x is WebException || x is InvalidImageException || x is TaskCanceledException);
- this.UserPicture.ShowErrorImage();
- }
- else
- {
- this.UserPicture.Image = t.Result.Clone() ;
- }
- }, uiScheduler);
+ return await image.CloneAsync()
+ .ConfigureAwait(false);
+ });
}
private void SaveOriginalSizeIconPictureToolStripMenuItem_Click(object sender, EventArgs e)
_modifySettingLocal = true;
}
- private bool UrlConvert(MyCommon.UrlConverter Converter_Type)
+ private async Task<bool> UrlConvertAsync(MyCommon.UrlConverter Converter_Type)
{
//t.coで投稿時自動短縮する場合は、外部サービスでの短縮禁止
//if (SettingDialog.UrlConvertAuto && SettingDialog.ShortenTco) return;
//短縮URL変換 日本語を含むかもしれないのでURLエンコードする
try
{
- result = ShortUrl.Instance.ShortenUrl(Converter_Type, tmp);
+ var srcUri = new Uri(MyCommon.urlEncodeMultibyteChar(tmp));
+ var resultUri = await ShortUrl.Instance.ShortenUrlAsync(Converter_Type, srcUri);
+ result = resultUri.ToString();
}
catch (WebApiException e)
{
//短縮URL変換 日本語を含むかもしれないのでURLエンコードする
try
{
- result = ShortUrl.Instance.ShortenUrl(Converter_Type, tmp);
+ var srcUri = new Uri(MyCommon.urlEncodeMultibyteChar(tmp));
+ var resultUri = await ShortUrl.Instance.ShortenUrlAsync(Converter_Type, srcUri);
+ result = resultUri.ToString();
+ }
+ catch (HttpRequestException e)
+ {
+ // 例外のメッセージが「Response status code does not indicate success: 500 (Internal Server Error).」
+ // のように長いので「:」が含まれていればそれ以降のみを抽出する
+ var message = e.Message.Split(new[] { ':' }, count: 2).Last();
+
+ this.StatusLabel.Text = Converter_Type + ":" + message;
+ continue;
}
catch (WebApiException e)
{
}
}
- private void TinyURLToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void TinyURLToolStripMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.TinyUrl);
+ await UrlConvertAsync(MyCommon.UrlConverter.TinyUrl);
}
- private void IsgdToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void IsgdToolStripMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.Isgd);
+ await UrlConvertAsync(MyCommon.UrlConverter.Isgd);
}
- private void TwurlnlToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void TwurlnlToolStripMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.Twurl);
+ await UrlConvertAsync(MyCommon.UrlConverter.Twurl);
}
- private void UxnuMenuItem_Click(object sender, EventArgs e)
+ private async void UxnuMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.Uxnu);
+ await UrlConvertAsync(MyCommon.UrlConverter.Uxnu);
}
- private void UrlConvertAutoToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void UrlConvertAutoToolStripMenuItem_Click(object sender, EventArgs e)
{
- if (!UrlConvert(SettingDialog.AutoShortUrlFirst))
+ if (!await UrlConvertAsync(SettingDialog.AutoShortUrlFirst))
{
MyCommon.UrlConverter svc = SettingDialog.AutoShortUrlFirst;
Random rnd = new Random();
svc = (MyCommon.UrlConverter)rnd.Next(System.Enum.GetNames(typeof(MyCommon.UrlConverter)).Length);
}
while (svc == SettingDialog.AutoShortUrlFirst || svc == MyCommon.UrlConverter.Nicoms || svc == MyCommon.UrlConverter.Unu);
- UrlConvert(svc);
+ await UrlConvertAsync(svc);
}
}
if (_selText != null)
{
- SearchDialog.SWord = _selText;
- SearchDialog.CheckCaseSensitive = false;
- SearchDialog.CheckRegex = false;
+ var searchOptions = new SearchWordDialog.SearchOptions(
+ SearchWordDialog.SearchType.Timeline,
+ _selText,
+ newTab: false,
+ caseSensitive: false,
+ useRegex: false);
+
+ this.SearchDialog.ResultOptions = searchOptions;
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.NextSearch);
+ this.DoTabSearch(
+ searchOptions.Query,
+ searchOptions.CaseSensitive,
+ searchOptions.UseRegex,
+ SEARCHTYPE.NextSearch);
}
}
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
- ImageSelectionPanel.Visible = true;
- ImageSelectionPanel.Enabled = true;
- TimelinePanel.Visible = false;
- TimelinePanel.Enabled = false;
- ImagefilePathText.Text = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
- ImageFromSelectedFile();
- this.Activate();
- this.BringToFront();
- StatusText.Focus();
+ SelectMedia_DragDrop(e);
}
else if (e.Data.GetDataPresent("UniformResourceLocatorW"))
{
throw new NotSupportedException("サポートされていないデータ形式です: " + data.GetFormats()[0]);
}
- private void TweenMain_DragOver(object sender, DragEventArgs e)
+ private void TweenMain_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
- string filename = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
- FileInfo fl = new FileInfo(filename);
- string ext = fl.Extension;
+ SelectMedia_DragEnter(e);
+ }
+ }
- if (!string.IsNullOrEmpty(this.ImageService) && this.pictureService[this.ImageService].CheckValidFilesize(ext, fl.Length))
- {
- e.Effect = DragDropEffects.Copy;
- return;
- }
- foreach (string svc in ImageServiceCombo.Items)
- {
- if (string.IsNullOrEmpty(svc)) continue;
- if (this.pictureService[svc].CheckValidFilesize(ext, fl.Length))
- {
- ImageServiceCombo.SelectedItem = svc;
- e.Effect = DragDropEffects.Copy;
- return;
- }
- }
- e.Effect = DragDropEffects.None;
+ private void TweenMain_DragOver(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ SelectMedia_DragOver(e);
}
else if (e.Data.GetDataPresent("UniformResourceLocatorW"))
{
public Task OpenUriAsync(string UriString)
{
- return Task.Factory.StartNew(() =>
+ return Task.Run(() =>
{
string myPath = UriString;
//単一
Rectangle bnd = new Rectangle();
bool flg = false;
- if (LView.FocusedItem != null)
+ var item = LView.FocusedItem;
+ if (item != null)
{
- bnd = LView.FocusedItem.Bounds;
+ bnd = item.Bounds;
flg = true;
}
LView.SelectedIndices.Clear();
}
while (LView.SelectedIndices.Count > 0);
- LView.Items[Index].Selected = true;
- //LView.SelectedIndices.Add(Index);
- LView.Items[Index].Focused = true;
+ item = LView.Items[Index];
+ item.Selected = true;
+ item.Focused = true;
if (flg) LView.Invalidate(bnd);
}
- private void SelectListItem(DetailsListView LView , int[] Index, int FocusedIndex)
+ private void SelectListItem(DetailsListView LView , int[] Index, int[] FocusedIndex)
{
//複数
Rectangle bnd = new Rectangle();
bool flg = false;
- if (LView.FocusedItem != null)
+ var item = LView.FocusedItem;
+ if (item != null)
{
- bnd = LView.FocusedItem.Bounds;
+ bnd = item.Bounds;
flg = true;
}
}
}
}
- if (FocusedIndex > -1 && LView.VirtualListSize > FocusedIndex)
+ if (FocusedIndex[1] > -1 && LView.VirtualListSize > FocusedIndex[1])
+ {
+ LView.SelectionMark = FocusedIndex[1];
+ }
+ if (FocusedIndex[0] > -1 && LView.VirtualListSize > FocusedIndex[0])
{
- LView.Items[FocusedIndex].Focused = true;
+ LView.Items[FocusedIndex[0]].Focused = true;
}
else if (fIdx > -1)
{
LView.Items[fIdx].Focused = true;
}
+
if (flg) LView.Invalidate(bnd);
}
if (SettingDialog.UserstreamStartup) tw.StartUserStream();
}
- private void TweenMain_Shown(object sender, EventArgs e)
+ private async void TweenMain_Shown(object sender, EventArgs e)
{
try
{
if (this.IsNetworkAvailable())
{
- GetTimeline(MyCommon.WORKERTYPE.BlockIds, 0, 0, "");
- GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
+ this.RefreshMuteUserIdsAsync();
+ 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="":全タブ
- int i = 0;
- int j = 0;
- while (IsInitialRead() && !MyCommon._endingFlag)
+ GetTimeline(MyCommon.WORKERTYPE.List, 1, ""); //tabname="":全タブ
+
+ var i = 0;
+ while (this.IsInitialRead())
{
- System.Threading.Thread.Sleep(100);
- Application.DoEvents();
+ await Task.Delay(5000);
+
i += 1;
- j += 1;
- if (j > 1200) break; // 120秒間初期処理が終了しなかったら強制的に打ち切る
- if (i > 50)
- {
- if (MyCommon._endingFlag)
- return;
- i = 0;
- }
+ if (i > 24) break; // 120秒間初期処理が終了しなかったら強制的に打ち切る
+
+ if (MyCommon._endingFlag)
+ return;
}
if (MyCommon._endingFlag) return;
{
//バージョンチェック(引数:起動時チェックの場合はtrue・・・チェック結果のメッセージを表示しない)
if (SettingDialog.StartupVersion)
- CheckNewVersion(true);
+ await this.CheckNewVersion(true);
}
else
{
// 取得失敗の場合は再試行する
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);
}
TabRename(ref _rclickTabName);
}
- private void BitlyToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void BitlyToolStripMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.Bitly);
+ await UrlConvertAsync(MyCommon.UrlConverter.Bitly);
}
- private void JmpToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void JmpToolStripMenuItem_Click(object sender, EventArgs e)
{
- UrlConvert(MyCommon.UrlConverter.Jmp);
+ await UrlConvertAsync(MyCommon.UrlConverter.Jmp);
}
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;
cmb.Text = tb.SearchWords;
cmb.SelectAll();
DetailsListView lst = (DetailsListView)pnl.Parent.Tag;
+ this.PurgeListViewItemCache();
lst.VirtualListSize = 0;
- lst.Items.Clear();
_statuses.ClearTabIds(tbName);
SaveConfigsTabs(); //検索条件の保存
}
- GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, 0, tbName);
+ GetTimeline(MyCommon.WORKERTYPE.PublicSearch, 1, tbName);
((DetailsListView)ListTab.SelectedTab.Tag).Focus();
}
fc.FilterByUrl = false;
_statuses.Tabs[tabName].AddFilter(fc);
- try
- {
- this.Cursor = Cursors.WaitCursor;
- this.PurgeListViewItemCache();
- _curPost = null;
- _curItemIndex = -1;
- _statuses.FilterAll();
- foreach (TabPage tb in ListTab.TabPages)
- {
- ((DetailsListView)tb.Tag).VirtualListSize = _statuses.Tabs[tb.Text].AllCount;
- if (_statuses.Tabs[tb.Text].UnreadCount > 0)
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = 0;
- }
- else
- {
- if (SettingDialog.TabIconDisp)
- tb.ImageIndex = -1;
- }
- }
- if (!SettingDialog.TabIconDisp) ListTab.Refresh();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
+ this.ApplyPostFilters();
SaveConfigsTabs();
}
}
Match m = Regex.Match(this._postBrowserStatusText, @"^https?://twitter.com/search\?q=%23(?<hash>.+)$");
if (m.Success)
{
- HashMgr.SetPermanentHash("#" + m.Result("${hash}"));
+ HashMgr.SetPermanentHash("#" + Uri.UnescapeDataString(m.Result("${hash}")));
HashStripSplitButton.Text = HashMgr.UseHash;
HashToggleMenuItem.Checked = true;
HashToggleToolStripMenuItem.Checked = true;
{
public Twitter tw;
public string id;
- public TwitterDataModel.User user;
+ public TwitterUser user;
}
private void GetUserInfo_DoWork(object sender, DoWorkEventArgs e)
private void doShowUserStatus(string id, bool ShowInputDialog)
{
- TwitterDataModel.User user = null;
+ TwitterUser user = null;
GetUserInfoArgs args = new GetUserInfoArgs();
if (ShowInputDialog)
{
}
}
- private void doShowUserStatus(TwitterDataModel.User user)
+ private async void doShowUserStatus(TwitterUser user)
{
- using (ShowUserInfo userinfo = new ShowUserInfo())
+ using (var userDialog = new UserInfoDialog(this, this.tw))
{
- userinfo.Owner = this;
- userinfo.User = user;
- userinfo.ShowDialog(this);
+ var showUserTask = userDialog.ShowUserAsync(user);
+ userDialog.ShowDialog(this);
+
this.Activate();
this.BringToFront();
+
+ // ユーザー情報の表示が完了するまで userDialog を破棄しない
+ await showUserTask;
}
}
public TweenMain()
{
_hookGlobalHotkey = new HookGlobalHotkey(this);
+
// この呼び出しは、Windows フォーム デザイナで必要です。
InitializeComponent();
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.StatusStrip1.Items.Insert(2, this._apiGauge);
+ this.ImageSelector.Visible = false;
+ this.ImageSelector.Enabled = false;
+ this.ImageSelector.FilePickDialog = OpenFileDialog1;
+
this.ReplaceAppName();
}
#region "画像投稿"
private void ImageSelectMenuItem_Click(object sender, EventArgs e)
{
- if (ImageSelectionPanel.Visible == true)
- {
- ImagefilePathText.CausesValidation = false;
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
- ImagefilePathText.CausesValidation = true;
- }
+ if (ImageSelector.Visible)
+ ImageSelector.EndSelection();
else
- {
- ImageSelectionPanel.Visible = true;
- ImageSelectionPanel.Enabled = true;
- TimelinePanel.Visible = false;
- TimelinePanel.Enabled = false;
- ImagefilePathText.Focus();
- }
+ ImageSelector.BeginSelection();
}
- private void FilePickButton_Click(object sender, EventArgs e)
+ private void SelectMedia_DragEnter(DragEventArgs e)
{
- if (string.IsNullOrEmpty(this.ImageService)) return;
- OpenFileDialog1.Filter = this.pictureService[this.ImageService].GetFileOpenDialogFilter();
- OpenFileDialog1.Title = Properties.Resources.PickPictureDialog1;
- OpenFileDialog1.FileName = "";
-
- try
- {
- this.AllowDrop = false;
- if (OpenFileDialog1.ShowDialog() == DialogResult.Cancel) return;
- }
- finally
+ if (ImageSelector.HasUploadableService(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]))
{
- this.AllowDrop = true;
+ e.Effect = DragDropEffects.Copy;
+ return;
}
-
- ImagefilePathText.Text = OpenFileDialog1.FileName;
- ImageFromSelectedFile();
+ e.Effect = DragDropEffects.None;
}
- private void ImagefilePathText_Validating(object sender, CancelEventArgs e)
+ private void SelectMedia_DragOver(DragEventArgs e)
{
- if (ImageCancelButton.Focused)
- {
- ImagefilePathText.CausesValidation = false;
- return;
- }
- ImagefilePathText.Text = ImagefilePathText.Text.Trim();
- if (string.IsNullOrEmpty(ImagefilePathText.Text))
- {
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- }
- else
- {
- ImageFromSelectedFile();
- }
+ //何も触らない
}
- private void ImageFromSelectedFile()
+ private void SelectMedia_DragDrop(DragEventArgs e)
{
- try
- {
- if (string.IsNullOrEmpty(ImagefilePathText.Text.Trim()) || string.IsNullOrEmpty(this.ImageService))
- {
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- return;
- }
-
- FileInfo fl = new FileInfo(ImagefilePathText.Text.Trim());
- if (!this.pictureService[this.ImageService].CheckValidExtension(fl.Extension))
- {
- //画像以外の形式
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- return;
- }
-
- if (!this.pictureService[this.ImageService].CheckValidFilesize(fl.Extension, fl.Length))
- {
- // ファイルサイズが大きすぎる
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- MessageBox.Show("File is too large.");
- return;
- }
-
- switch (this.pictureService[this.ImageService].GetFileType(fl.Extension))
- {
- case MyCommon.UploadFileType.Invalid:
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- break;
- case MyCommon.UploadFileType.Picture:
- Image img = null;
- using (FileStream fs = new FileStream(ImagefilePathText.Text, FileMode.Open, FileAccess.Read))
- {
- img = Image.FromStream(fs);
- }
- ImageSelectedPicture.Image = (new HttpVarious()).CheckValidImage(
- img,
- img.Width,
- img.Height);
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Picture;
- break;
- case MyCommon.UploadFileType.MultiMedia:
- ImageSelectedPicture.Image = Properties.Resources.MultiMediaImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.MultiMedia;
- break;
- default:
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- break;
- }
- }
- catch (FileNotFoundException)
- {
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- MessageBox.Show("File not found.");
- }
- catch (Exception)
- {
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- ImagefilePathText.Text = "";
- MessageBox.Show("The type of this file is not image.");
- }
+ this.Activate();
+ this.BringToFront();
+ ImageSelector.BeginSelection(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]);
+ StatusText.Focus();
}
- private void ImageSelection_KeyDown(object sender, KeyEventArgs e)
+ private void ImageSelector_BeginSelecting(object sender, EventArgs e)
{
- if (e.KeyCode == Keys.Escape)
- {
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
- ImagefilePathText.CausesValidation = true;
- }
+ TimelinePanel.Visible = false;
+ TimelinePanel.Enabled = false;
}
- private void ImageSelection_KeyPress(object sender, KeyPressEventArgs e)
+ private void ImageSelector_EndSelecting(object sender, EventArgs e)
{
- if (Convert.ToInt32(e.KeyChar) == 0x1B)
- {
- ImagefilePathText.CausesValidation = false;
- e.Handled = true;
- }
+ TimelinePanel.Visible = true;
+ TimelinePanel.Enabled = true;
+ ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
}
- private void ImageSelection_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ private void ImageSelector_FilePickDialogOpening(object sender, EventArgs e)
{
- if (e.KeyCode == Keys.Escape)
- {
- ImagefilePathText.CausesValidation = false;
- }
+ this.AllowDrop = false;
}
- private void SetImageServiceCombo()
+ private void ImageSelector_FilePickDialogClosed(object sender, EventArgs e)
{
- string svc = "";
- if (ImageServiceCombo.SelectedIndex > -1) svc = ImageServiceCombo.SelectedItem.ToString();
- ImageServiceCombo.Items.Clear();
-
- // Add service names to combobox
- foreach (var key in pictureService.Keys)
- {
- ImageServiceCombo.Items.Add(key);
- }
-
- SelectImageServiceComboItem(svc);
+ this.AllowDrop = true;
}
- private void SelectImageServiceComboItem(string svc, int? index = null)
+ private void ImageSelector_SelectedServiceChanged(object sender, EventArgs e)
{
- int idx;
- if (string.IsNullOrEmpty(svc))
+ if (ImageSelector.Visible)
{
- idx = index ?? 0;
- }
- else
- {
- idx = ImageServiceCombo.Items.IndexOf(svc);
- if (idx == -1) idx = index ?? 0;
- }
+ _modifySettingCommon = true;
+ SaveConfigsAll(true);
- try
- {
- ImageServiceCombo.SelectedIndex = idx;
- }
- catch (ArgumentOutOfRangeException)
- {
- ImageServiceCombo.SelectedIndex = 0;
+ if (ImageSelector.ServiceName.Equals("Twitter"))
+ this.StatusText_TextChanged(null, null);
}
}
- private string ImageService
- {
- get { return ImageServiceCombo.SelectedItem.ToString(); }
- }
-
- private void ImageCancelButton_Click(object sender, EventArgs e)
- {
- ImagefilePathText.CausesValidation = false;
- TimelinePanel.Visible = true;
- TimelinePanel.Enabled = true;
- ImageSelectionPanel.Visible = false;
- ImageSelectionPanel.Enabled = false;
- ((DetailsListView)ListTab.SelectedTab.Tag).Focus();
- ImagefilePathText.CausesValidation = true;
- }
-
- private void ImageServiceCombo_SelectedIndexChanged(object sender, EventArgs e)
+ private void ImageSelector_VisibleChanged(object sender, EventArgs e)
{
- if (ImageSelectedPicture.Tag != null && !string.IsNullOrEmpty(this.ImageService))
- {
- try
- {
- FileInfo fi = new FileInfo(ImagefilePathText.Text.Trim());
- if (!this.pictureService[this.ImageService].CheckValidFilesize(fi.Extension, fi.Length))
- {
- ImagefilePathText.Text = "";
- ImageSelectedPicture.Image = ImageSelectedPicture.InitialImage;
- ImageSelectedPicture.Tag = MyCommon.UploadFileType.Invalid;
- }
- }
- catch (Exception)
- {
- }
- _modifySettingCommon = true;
- SaveConfigsAll(false);
- if (this.ImageService == "Twitter")
- {
- this.StatusText_TextChanged(null, null);
- }
- }
+ this.StatusText_TextChanged(null, null);
}
#endregion
}
}
- 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")
//{
OpenUriAsync(MyCommon.TwitterUrl + tw.Username);
}
- private void doTranslation(string str)
+ private async Task doTranslation(string str)
{
- Bing _bing = new Bing();
- string buf = "";
- if (string.IsNullOrEmpty(str)) return;
- string srclng = "";
- string dstlng = SettingDialog.TranslateLanguage;
- string msg = "";
- if (srclng != dstlng && _bing.Translate("", dstlng, str, out buf))
+ if (string.IsNullOrEmpty(str))
+ return;
+
+ var bing = new Bing();
+ try
{
- PostBrowser.DocumentText = createDetailHtml(buf);
+ var translatedText = await bing.TranslateAsync(str,
+ langFrom: null,
+ langTo: this.SettingDialog.TranslateLanguage);
+
+ this.PostBrowser.DocumentText = translatedText;
}
- else
+ catch (HttpRequestException e)
{
- if (msg.StartsWith("Err:"))
- StatusLabel.Text = msg;
+ this.StatusLabel.Text = "Err:" + e.Message;
}
}
- private void TranslationToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void TranslationToolStripMenuItem_Click(object sender, EventArgs e)
{
- if (!this.ExistCurrentPost) return;
- doTranslation(_curPost.TextFromApi);
+ if (!this.ExistCurrentPost)
+ return;
+
+ await this.doTranslation(this._curPost.TextFromApi);
}
- private void SelectionTranslationToolStripMenuItem_Click(object sender, EventArgs e)
+ private async void SelectionTranslationToolStripMenuItem_Click(object sender, EventArgs e)
{
- doTranslation(WebBrowser_GetSelectionText(ref PostBrowser));
+ var text = this.WebBrowser_GetSelectionText(ref this.PostBrowser);
+ await this.doTranslation(text);
}
private bool ExistCurrentPost
OpenUserAppointUrl();
}
- private void ImageSelectionPanel_VisibleChanged(object sender, EventArgs e)
- {
- this.StatusText_TextChanged(null, null);
- }
-
private void SourceCopyMenuItem_Click(object sender, EventArgs e)
{
string selText = SourceLinkLabel.Text;
private void tweetThumbnail1_ThumbnailLoading(object sender, EventArgs e)
{
this.SplitContainer3.Panel2Collapsed = false;
+
+ // PreviewDistance が起動のたびに広がっていく問題の回避策
+ // FixedPanel が Panel2 に設定された状態で Panel2 を開くと、初回だけ SplitterDistance が再計算されておかしくなるため、
+ // None で開いた後に設定するようにする
+ if (this.SplitContainer3.FixedPanel == FixedPanel.None)
+ this.SplitContainer3.FixedPanel = FixedPanel.Panel2;
}
private void tweetThumbnail1_ThumbnailDoubleClick(object sender, ThumbnailDoubleClickEventArgs e)
{
if (SettingDialog.IconSz == iconSize) return;
+ var oldIconCol = _iconCol;
+
SettingDialog.IconSz = iconSize;
+ ApplyListViewIconSize(iconSize);
- foreach (TabPage tp in ListTab.TabPages)
+ if (_iconCol != oldIconCol)
{
- ApplyListViewIconSize((DetailsListView)tp.Tag);
+ foreach (TabPage tp in ListTab.TabPages)
+ {
+ ResetColumns((DetailsListView)tp.Tag);
+ }
}
if (_curList != null) _curList.Refresh();
- SaveConfigsCommon();
+ _modifySettingCommon = true;
}
private void LockListSortToolStripMenuItem_Click(object sender, EventArgs e)
SettingDialog.SortOrderLock = state;
- SaveConfigsCommon();
+ _modifySettingCommon = true;
}
}
}