// 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;
{
public partial class TweenMain : OTBaseForm
{
+ private readonly HttpClient http;
+
//各種設定
private Size _mySize; //画面サイズ
private Point _myLoc; //画面位置
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 _DoFavRetweetFlags = false;
private bool osResumed = false;
- private Dictionary<string, IMultimediaShareService> pictureService;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
private string _postBrowserStatusText = "";
public long? inReplyToId = null;
public string inReplyToName = null;
public string imageService = ""; //画像投稿サービス名
- public string imagePath = "";
+ public string[] imagePath = null;
public PostingStatus()
{
}
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();
this.IconCache.CancelAsync();
this.IconCache.Dispose();
}
+
+ this.http.Dispose();
+
// 終了時にRemoveHandlerしておかないとメモリリークする
// http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.powermodechanged.aspx
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
TraceOutToolStripMenuItem.Checked = true;
MyCommon.TraceFlag = true;
#endif
- if (!MyCommon.fileVersion.EndsWith("0"))
+ if (!MyCommon.FileVersion.EndsWith("0"))
{
TraceOutToolStripMenuItem.Checked = true;
MyCommon.TraceFlag = true;
Regex.CacheSize = 100;
- MyCommon.fileVersion = ((AssemblyFileVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]).Version;
InitializeTraceFrag();
LoadIcons(); // アイコン読み込み
////設定読み出し
LoadConfig();
- var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance.Value;
+ ThumbnailGenerator.InitializeGenerator(this.http);
+
+ var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet;
imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM;
x.Initialize(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret,
this.tw.AccessToken, this.tw.AccessTokenSecret, "", "");
- ThumbnailGenerator.InitializeGenerator();
-
//新着バルーン通知のチェック状態設定
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.EnableImgAzyobuziNet = _cfgCommon.EnableImgAzyobuziNet;
SettingDialog.ImgAzyobuziNetDisabledInDM = _cfgCommon.ImgAzyobuziNetDisabledInDM;
- SettingDialog.IsPreviewFoursquare = _cfgCommon.IsPreviewFoursquare;
SettingDialog.MapThumbnailProvider = _cfgCommon.MapThumbnailProvider;
SettingDialog.MapThumbnailHeight = _cfgCommon.MapThumbnailHeight;
SettingDialog.MapThumbnailWidth = _cfgCommon.MapThumbnailWidth;
_initial = true;
//アイコンリスト作成
- this.IconCache = new ImageCache();
+ this.IconCache = new ImageCache(this.http);
bool saveRequired = false;
bool firstRun = false;
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)
{
//////グローバルホットキーの登録
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;
+ ApplyListViewIconSize(SettingDialog.IconSz);
- //発言詳細部アイコンをリストアイコンにサイズ変更
- int sz = _iconSz;
- if (_iconSz == 0)
- {
- sz = 16;
- }
+ tw.TinyUrlResolve = SettingDialog.TinyUrlResolve;
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 Exception(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)
doGetFollowersMenu();
GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
- if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain));
}
if (osResumed)
{
GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, "");
doGetFollowersMenu();
GetTimeline(MyCommon.WORKERTYPE.Configuration, 0, 0, "");
- if (InvokeRequired && !IsDisposed) this.Invoke(new MethodInvoker(this.TrimPostChain));
}
}
}
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)
{
//Read:true=既読 false=未読
//未読管理していなかったら既読として扱う
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 = _statuses[_curTab.Text, 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)
//{
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;
{
post = _statuses[rslt.sIds[i]];
}
- ChangeCacheStyleRead(post.IsRead, idx, _curTab);
+ ChangeCacheStyleRead(post.IsRead, idx);
}
if (idx == _curItemIndex) DispSelectedPost(true); //選択アイテム再表示
}
//_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;
}
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();
}
SettingDialog.ProxyPort,
SettingDialog.ProxyUser,
SettingDialog.ProxyPassword);
- this.CreatePictureServices();
+
+ ImageSelector.Reset(tw, SettingDialog.TwitterConfiguration);
try
{
// タブの表示位置の決定
SetTabAlignment();
- var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance.Value;
+ SplitContainer1.IsPanelInverted = !SettingDialog.StatusAreaAtBottom;
+
+ var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance;
imgazyobizinet.Enabled = this.SettingDialog.EnableImgAzyobuziNet;
imgazyobizinet.DisabledInDM = this.SettingDialog.ImgAzyobuziNetDisabledInDM;
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;
+ using (ControlTransaction.Update(lst))
{
- tw.GetIcon = true;
- tw.IconSize = _iconSz;
+ this.SelectListItem(lst,
+ _statuses.IndexOf(tab.Text, selId[tab.Text]),
+ _statuses.IndexOf(tab.Text, 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;
_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)
return itm;
}
+ /// <summary>
+ /// 全てのタブの振り分けルールを反映し直します
+ /// </summary>
+ private void ApplyPostFilters()
+ {
+ 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;
{
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)
{
+ 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);
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 this.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,
+ };
+ }
- if (currentVersion.Replace(".", "").CompareTo(MyCommon.fileVersion.Replace(".", "")) > 0)
+ private async Task CheckNewVersion(bool startup = false)
+ {
+ if (ApplicationSettings.VersionInfoUrl == null)
+ return; // 更新チェック無効化
+
+ 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)
{
private static 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)
this.SplitContainer3.Panel2Collapsed = true;
if (this.IsPreviewEnable)
- this.tweetThumbnail1.ShowThumbnailAsync(_curPost);
+ {
+ if (this.thumbnailTokenSource != null)
+ {
+ var oldTokenSource = this.thumbnailTokenSource;
+
+ // TODO: キャンセルを行うとUIスレッドが阻害される問題を調査
+ //oldTokenSource.Cancel();
+
+ this.thumbnailTask.ContinueWith(_ => oldTokenSource.Dispose());
+ }
+
+ this.thumbnailTokenSource = new CancellationTokenSource();
+
+ var token = this.thumbnailTokenSource.Token;
+ this.thumbnailTask = this.tweetThumbnail1.ShowThumbnailAsync(_curPost, token);
+ }
}
}
catch (System.Runtime.InteropServices.COMException)
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.EnableImgAzyobuziNet = SettingDialog.EnableImgAzyobuziNet;
_cfgCommon.ImgAzyobuziNetDisabledInDM = SettingDialog.ImgAzyobuziNetDisabledInDM;
- _cfgCommon.IsPreviewFoursquare = SettingDialog.IsPreviewFoursquare;
_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)
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;
- }
+ this.ApplyPostFilters();
SaveConfigsTabs();
}
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 (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);
- DoTabSearch(SearchDialog.SWord,
- SearchDialog.CheckCaseSensitive,
- SearchDialog.CheckRegex,
- SEARCHTYPE.NextSearch);
+ this.SearchDialog.ResultOptions = searchOptions;
+
+ 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;
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())
{
+ this.RefreshMuteUserIdsAsync();
GetTimeline(MyCommon.WORKERTYPE.BlockIds, 0, 0, "");
GetTimeline(MyCommon.WORKERTYPE.NoRetweetIds, 0, 0, "");
if (SettingDialog.StartupFollowers)
GetTimeline(MyCommon.WORKERTYPE.UserTimeline, 1, 0, ""); //tabname="":全タブ
_waitLists = true;
GetTimeline(MyCommon.WORKERTYPE.List, 1, 0, ""); //tabname="":全タブ
- int i = 0;
- int j = 0;
- while (IsInitialRead() && !MyCommon._endingFlag)
+
+ 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
{
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);
}
cmb.Text = tb.SearchWords;
cmb.SelectAll();
DetailsListView lst = (DetailsListView)pnl.Parent.Tag;
+ this.PurgeListViewItemCache();
lst.VirtualListSize = 0;
- lst.Items.Clear();
_statuses.ClearTabIds(tbName);
SaveConfigsTabs(); //検索条件の保存
}
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;
}
}
private HookGlobalHotkey _hookGlobalHotkey;
public TweenMain()
{
+ this.http = MyCommon.CreateHttpClient();
_hookGlobalHotkey = new HookGlobalHotkey(this);
+
// この呼び出しは、Windows フォーム デザイナで必要です。
InitializeComponent();
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
+ if (ImageSelector.HasUploadableService(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]))
{
- this.AllowDrop = false;
- if (OpenFileDialog1.ShowDialog() == DialogResult.Cancel) return;
- }
- finally
- {
- 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))
- {
- idx = index ?? 0;
- }
- else
+ if (ImageSelector.Visible)
{
- 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
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(this.http);
+ 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();