private readonly object syncObject = new(); // ロック用
private const string DetailHtmlFormatHead =
- "<head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\">"
- + "<style type=\"text/css\"><!-- "
+ """<head><meta http-equiv="X-UA-Compatible" content="IE=8">"""
+ + """<style type="text/css"><!-- """
+ "body, p, pre {margin: 0;} "
- + "body {font-family: \"%FONT_FAMILY%\", sans-serif; font-size: %FONT_SIZE%pt; background-color:rgb(%BG_COLOR%); word-wrap: break-word; color:rgb(%FONT_COLOR%);} "
+ + """body {font-family: "%FONT_FAMILY%", "Segoe UI Emoji", sans-serif; font-size: %FONT_SIZE%pt; background-color:rgb(%BG_COLOR%); word-wrap: break-word; color:rgb(%FONT_COLOR%);} """
+ "pre {font-family: inherit;} "
+ "a:link, a:visited, a:active, a:hover {color:rgb(%LINK_COLOR%); } "
+ "img.emoji {width: 1em; height: 1em; margin: 0 .05em 0 .1em; vertical-align: -0.1em; border: none;} "
// 発言投稿時のAPI引数(発言編集時に設定。手書きreplyでは設定されない)
/// <summary>リプライ先のステータスID・スクリーン名</summary>
- private (long StatusId, string ScreenName)? inReplyTo = null;
+ private (PostId StatusId, string ScreenName)? inReplyTo = null;
// 時速表示用
private readonly List<DateTimeUtc> postTimestamps = new();
private List<UrlUndo>? urlUndoBuffer = null;
private readonly record struct ReplyChain(
- long OriginalId,
- long InReplyToId,
+ PostId OriginalId,
+ PostId InReplyToId,
TabModel OriginalTab
);
private readonly record struct StatusTextHistory(
string Status,
- (long StatusId, string ScreenName)? InReplyTo = null
+ (PostId StatusId, string ScreenName)? InReplyTo = null
);
private readonly HookGlobalHotkey hookGlobalHotkey;
var configScaleFactor = this.settings.Local.GetConfigScaleFactor(this.CurrentAutoScaleDimensions);
// 認証関連
- this.tw.Initialize(this.settings.Common.Token, this.settings.Common.TokenSecret, this.settings.Common.UserName, this.settings.Common.UserId);
+ var account = this.settings.Common.SelectedAccount;
+ if (account != null)
+ this.tw.Initialize(account.GetTwitterAppToken(), account.Token, account.TokenSecret, account.Username, account.UserId);
+ else
+ this.tw.Initialize(TwitterAppToken.GetDefault(), "", "", "", 0L);
this.initial = true;
Thumbnail.Services.TonTwitterCom.GetApiConnection = () => this.tw.Api.Connection;
// 画像投稿サービス
- this.ImageSelector.Initialize(this.tw, this.tw.Configuration, this.settings.Common.UseImageServiceName, this.settings.Common.UseImageService);
+ this.ImageSelector.Model.InitializeServices(this.tw, this.tw.Configuration);
+ this.ImageSelector.Model.SelectMediaService(this.settings.Common.UseImageServiceName, this.settings.Common.UseImageService);
- this.tweetThumbnail1.Initialize(this.thumbGenerator);
+ this.tweetThumbnail1.Model.Initialize(this.thumbGenerator);
// ハッシュタグ/@id関連
this.AtIdSupl = new AtIdSupplement(this.settings.AtIdList.AtIdList, "@");
if (MyCommon.IsNullOrEmpty(bText)) return;
var image = this.iconCache.TryGetFromCache(post.ImageUrl);
- this.gh.Notify(nt, post.StatusId.ToString(), title.ToString(), bText, image?.Image, post.ImageUrl);
+ this.gh.Notify(nt, post.StatusId.Id, title.ToString(), bText, image?.Image, post.ImageUrl);
}
}
else
var status = new PostStatusParams();
var statusTextCompat = this.FormatStatusText(this.StatusText.Text);
- if (this.GetRestStatusCount(statusTextCompat) >= 0)
+ if (this.GetRestStatusCount(statusTextCompat) >= 0 && this.tw.Api.AppToken.AuthType == APIAuthType.OAuth1)
{
// auto_populate_reply_metadata や attachment_url を使用しなくても 140 字以内に
// 収まる場合はこれらのオプションを使用せずに投稿する
if (!this.ImageSelector.TryGetSelectedMedia(out var serviceName, out uploadItems))
return;
- uploadService = this.ImageSelector.GetService(serviceName);
+ this.ImageSelector.EndSelection();
+ uploadService = this.ImageSelector.Model.GetService(serviceName);
}
this.inReplyTo = null;
}
}
- private async Task FavAddAsync(long statusId, TabModel tab)
+ private async Task FavAddAsync(PostId statusId, TabModel tab)
{
await this.workerSemaphore.WaitAsync();
}
}
- private async Task FavAddAsyncInternal(IProgress<string> p, CancellationToken ct, long statusId, TabModel tab)
+ private async Task FavAddAsyncInternal(IProgress<string> p, CancellationToken ct, PostId statusId, TabModel tab)
{
if (ct.IsCancellationRequested)
return;
try
{
+ var twitterStatusId = (post.RetweetedId ?? post.StatusId).ToTwitterStatusId();
try
{
- await this.tw.Api.FavoritesCreate(post.RetweetedId ?? post.StatusId)
+ await this.tw.Api.FavoritesCreate(twitterStatusId)
.IgnoreResponse()
.ConfigureAwait(false);
}
if (this.settings.Common.RestrictFavCheck)
{
- var status = await this.tw.Api.StatusesShow(post.RetweetedId ?? post.StatusId)
+ var status = await this.tw.Api.StatusesShow(twitterStatusId)
.ConfigureAwait(false);
if (status.Favorited != true)
}
}
- private async Task FavRemoveAsync(IReadOnlyList<long> statusIds, TabModel tab)
+ private async Task FavRemoveAsync(IReadOnlyList<PostId> statusIds, TabModel tab)
{
await this.workerSemaphore.WaitAsync();
}
}
- private async Task FavRemoveAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<long> statusIds, TabModel tab)
+ private async Task FavRemoveAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<PostId> statusIds, TabModel tab)
{
if (ct.IsCancellationRequested)
return;
if (!CheckAccountValid())
throw new WebApiException("Auth error. Check your account");
- var successIds = new List<long>();
+ var successIds = new List<PostId>();
await Task.Run(async () =>
{
if (!post.IsFav)
continue;
+ var twitterStatusId = (post.RetweetedId ?? post.StatusId).ToTwitterStatusId();
+
try
{
- await this.tw.Api.FavoritesDestroy(post.RetweetedId ?? post.StatusId)
+ await this.tw.Api.FavoritesDestroy(twitterStatusId)
.IgnoreResponse()
.ConfigureAwait(false);
}
await this.RefreshTabAsync<HomeTabModel>();
}
- private async Task RetweetAsync(IReadOnlyList<long> statusIds)
+ private async Task RetweetAsync(IReadOnlyList<PostId> statusIds)
{
await this.workerSemaphore.WaitAsync();
}
}
- private async Task RetweetAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<long> statusIds)
+ private async Task RetweetAsyncInternal(IProgress<string> p, CancellationToken ct, IReadOnlyList<PostId> statusIds)
{
if (ct.IsCancellationRequested)
return;
if (this.tw.Configuration.PhotoSizeLimit != 0)
{
- foreach (var service in this.ImageSelector.GetServices())
+ foreach (var (_, service) in this.ImageSelector.Model.MediaServices)
{
service.UpdateTwitterConfiguration(this.tw.Configuration);
}
try
{
- if (post.IsDm)
+ if (post.StatusId is TwitterDirectMessageId dmId)
{
- await this.tw.Api.DirectMessagesEventsDestroy(post.StatusId.ToString(CultureInfo.InvariantCulture));
+ await this.tw.Api.DirectMessagesEventsDestroy(dmId);
}
else
{
{
// 自分が RT したツイート (自分が RT した自分のツイートも含む)
// => RT を取り消し
- await this.tw.Api.StatusesDestroy(post.StatusId)
- .IgnoreResponse();
+ await this.tw.DeleteRetweet(post);
}
else
{
{
// 他人に RT された自分のツイート
// => RT 元の自分のツイートを削除
- await this.tw.Api.StatusesDestroy(post.RetweetedId.Value)
- .IgnoreResponse();
+ await this.tw.DeleteTweet(post.RetweetedId.ToTwitterStatusId());
}
else
{
// 自分のツイート
// => ツイートを削除
- await this.tw.Api.StatusesDestroy(post.StatusId)
- .IgnoreResponse();
+ await this.tw.DeleteTweet(post.StatusId.ToTwitterStatusId());
}
}
}
if (MyCommon.IsNullOrEmpty(this.settings.Common.Token))
this.tw.ClearAuthInfo();
- this.tw.Initialize(this.settings.Common.Token, this.settings.Common.TokenSecret, this.settings.Common.UserName, this.settings.Common.UserId);
+ var account = this.settings.Common.SelectedAccount;
+ if (account != null)
+ this.tw.Initialize(account.GetTwitterAppToken(), account.Token, account.TokenSecret, account.Username, account.UserId);
+ else
+ this.tw.Initialize(TwitterAppToken.GetDefault(), "", "", "", 0L);
+
this.tw.RestrictFavCheck = this.settings.Common.RestrictFavCheck;
this.tw.ReadOwnPost = this.settings.Common.ReadOwnPost;
- this.ImageSelector.Reset(this.tw, this.tw.Configuration);
+ this.ImageSelector.Model.InitializeServices(this.tw, this.tw.Configuration);
try
{
this.ListTab.Alignment = newAlignment;
- currentListViewState.Restore();
+ currentListViewState.Restore(forceScroll: true);
}
private void ApplyListViewIconSize(MyCommon.IconSizes iconSz)
{
// アイコンサイズの再設定
if (this.listDrawer != null)
+ {
this.listDrawer.IconSize = iconSz;
+ this.listDrawer.UpdateItemHeight();
+ }
this.listCache?.PurgeCache();
}
attachmentUrl = null;
// attachment_url は media_id と同時に使用できない
- if (this.ImageSelector.Visible && this.ImageSelector.SelectedService is TwitterPhoto)
+ if (this.ImageSelector.Visible && this.ImageSelector.Model.SelectedMediaService is TwitterPhoto)
return statusText;
var match = Twitter.AttachmentUrlRegex.Match(statusText);
}
private IMediaUploadService? GetSelectedImageService()
- => this.ImageSelector.Visible ? this.ImageSelector.SelectedService : null;
+ => this.ImageSelector.Visible ? this.ImageSelector.Model.SelectedMediaService : null;
/// <summary>
/// 全てのタブの振り分けルールを反映し直します
if (dialog.ShowDialog(this) == DialogResult.Yes)
{
- await MyCommon.OpenInBrowserAsync(this, versionInfo.DownloadUri.OriginalString);
+ await MyCommon.OpenInBrowserAsync(this, versionInfo.DownloadUri);
}
else if (dialog.SkipButtonPressed)
{
this.tweetDetailsView.ShowPostDetails(currentPost),
};
- this.SplitContainer3.Panel2Collapsed = true;
-
if (this.settings.Common.PreviewEnable)
{
var oldTokenSource = Interlocked.Exchange(ref this.thumbnailTokenSource, new CancellationTokenSource());
oldTokenSource?.Cancel();
var token = this.thumbnailTokenSource!.Token;
- loadTasks.Add(this.tweetThumbnail1.ShowThumbnailAsync(currentPost, token));
+ loadTasks.Add(this.PrepareThumbnailControl(currentPost, token));
+ }
+ else
+ {
+ this.SplitContainer3.Panel2Collapsed = true;
}
async Task DelayedTasks()
_ = DelayedTasks();
}
+ private async Task PrepareThumbnailControl(PostClass post, CancellationToken token)
+ {
+ var prepareTask = this.tweetThumbnail1.Model.PrepareThumbnails(post, token);
+
+ var timeout = Task.Delay(100);
+ if ((await Task.WhenAny(prepareTask, timeout)) == timeout)
+ {
+ token.ThrowIfCancellationRequested();
+
+ // サムネイル情報の読み込みに時間が掛かっている場合は一旦サムネイル領域を非表示にする
+ this.SplitContainer3.Panel2Collapsed = true;
+ }
+
+ await prepareTask;
+ token.ThrowIfCancellationRequested();
+
+ this.SplitContainer3.Panel2Collapsed = !this.tweetThumbnail1.Model.ThumbnailAvailable;
+ }
+
private async void MatomeMenuItem_Click(object sender, EventArgs e)
=> await this.OpenApplicationWebsite();
.OnlyWhen(() => this.CurrentTab.TabType == MyCommon.TabUsageType.PublicSearch)
.Do(() => this.CurrentTabPage.Controls["panelSearch"].Controls["comboSearch"].Focus()),
+ ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.L)
+ .Do(() => this.DoQuoteOfficial()),
+
ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.S)
.Do(() => this.FavoriteChange(favAdd: false)),
.Do(() => this.CopyUserId()),
ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Up)
- .Do(() => this.tweetThumbnail1.ScrollUp()),
+ .Do(() => this.tweetThumbnail1.Model.ScrollUp()),
ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Down)
- .Do(() => this.tweetThumbnail1.ScrollDown()),
+ .Do(() => this.tweetThumbnail1.Model.ScrollDown()),
ShortcutCommand.Create(Keys.Alt | Keys.Shift | Keys.Enter)
.FocusedOn(FocusedControl.ListTab)
.OnlyWhen(() => !this.SplitContainer3.Panel2Collapsed)
- .Do(() => this.OpenThumbnailPicture(this.tweetThumbnail1.Thumbnail)),
+ .Do(() => this.tweetThumbnail1.OpenImageInBrowser()),
};
}
return;
var selectedStatusId = tab.SelectedStatusId;
- if (selectedStatusId == -1)
+ if (selectedStatusId == null)
return;
int fIdx, toIdx, stp;
if (anchorStatusId == null)
return;
- var idx = this.CurrentTab.IndexOf(anchorStatusId.Value);
+ var idx = this.CurrentTab.IndexOf(anchorStatusId);
if (idx == -1)
return;
{
try
{
- var post = await this.tw.GetStatusApi(false, currentPost.StatusId);
+ var post = await this.tw.GetStatusApi(false, currentPost.StatusId.ToTwitterStatusId());
- currentPost.InReplyToStatusId = post.InReplyToStatusId;
- currentPost.InReplyToUser = post.InReplyToUser;
- currentPost.IsReply = post.IsReply;
+ currentPost = currentPost with
+ {
+ InReplyToStatusId = post.InReplyToStatusId,
+ InReplyToUser = post.InReplyToUser,
+ IsReply = post.IsReply,
+ };
+ curTabClass.ReplacePost(currentPost);
this.listCache?.PurgeCache();
var index = curTabClass.SelectedIndex;
{
this.replyChains = new Stack<ReplyChain>();
}
- this.replyChains.Push(new ReplyChain(currentPost.StatusId, currentPost.InReplyToStatusId.Value, curTabClass));
+ this.replyChains.Push(new ReplyChain(currentPost.StatusId, currentPost.InReplyToStatusId, curTabClass));
int inReplyToIndex;
string inReplyToTabName;
- var inReplyToId = currentPost.InReplyToStatusId.Value;
+ var inReplyToId = currentPost.InReplyToStatusId;
var inReplyToUser = currentPost.InReplyToUser;
var inReplyToPosts = from tab in this.statuses.Tabs
{
await Task.Run(async () =>
{
- var post = await this.tw.GetStatusApi(false, currentPost.InReplyToStatusId.Value)
+ var post = await this.tw.GetStatusApi(false, currentPost.InReplyToStatusId.ToTwitterStatusId())
.ConfigureAwait(false);
post.IsRead = true;
catch (WebApiException ex)
{
this.StatusLabel.Text = $"Err:{ex.Message}(GetStatus)";
- await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(inReplyToUser, inReplyToId));
+ await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(inReplyToUser, inReplyToId.ToTwitterStatusId()));
return;
}
inReplyPost = inReplyToPosts.FirstOrDefault();
if (inReplyPost == null)
{
- await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(inReplyToUser, inReplyToId));
+ await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(inReplyToUser, inReplyToId.ToTwitterStatusId()));
return;
}
}
}
}
- private bool GoStatus(long statusId)
+ private bool GoStatus(PostId statusId)
{
- if (statusId == 0) return false;
-
var tab = this.statuses.Tabs
.Where(x => x.TabType != MyCommon.TabUsageType.DirectMessage)
.Where(x => x.Contains(statusId))
return true;
}
- private bool GoDirectMessage(long statusId)
+ private bool GoDirectMessage(PostId statusId)
{
- if (statusId == 0) return false;
-
var tab = this.statuses.DirectMessageTab;
var index = tab.IndexOf(statusId);
this.settings.Common.HashIsHead = this.HashMgr.IsHead;
this.settings.Common.HashIsPermanent = this.HashMgr.IsPermanent;
this.settings.Common.HashIsNotAddToAtReply = this.HashMgr.IsNotAddToAtReply;
- this.settings.Common.UseImageService = this.ImageSelector.ServiceIndex;
- this.settings.Common.UseImageServiceName = this.ImageSelector.ServiceName;
+ this.settings.Common.UseImageService = this.ImageSelector.Model.SelectedMediaServiceIndex;
+ this.settings.Common.UseImageServiceName = this.ImageSelector.Model.SelectedMediaServiceName;
this.settings.SaveCommon();
}
try
{
- var statusId = long.Parse(match.Groups["StatusId"].Value);
+ var statusId = new TwitterStatusId(match.Groups["StatusId"].Value);
await this.OpenRelatedTab(statusId);
}
catch (OverflowException)
"\"" + post.TextFromApi.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
post.CreatedAt.ToLocalTimeString() + "\t" +
post.ScreenName + "\t" +
- post.StatusId + "\t" +
+ post.StatusId.Id + "\t" +
post.ImageUrl + "\t" +
"\"" + post.Text.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
protect);
"\"" + post.TextFromApi.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
post.CreatedAt.ToLocalTimeString() + "\t" +
post.ScreenName + "\t" +
- post.StatusId + "\t" +
+ post.StatusId.Id + "\t" +
post.ImageUrl + "\t" +
"\"" + post.Text.Replace("\n", "").Replace("\"", "\"\"") + "\"" + "\t" +
protect);
this.statuses.RenameTab(origTabName, newTabName);
+ var state = this.listViewState[origTabName];
+ this.listViewState.Remove(origTabName);
+ this.listViewState[newTabName] = state;
+
this.SaveConfigsCommon();
this.SaveConfigsTabs();
this.rclickTabName = newTabName;
{
if (MyCommon.IsKeyDown(Keys.Shift))
{
- await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(currentPost.InReplyToUser, currentPost.InReplyToStatusId.Value));
+ await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(currentPost.InReplyToUser, currentPost.InReplyToStatusId.ToTwitterStatusId()));
return;
}
- if (this.statuses.Posts.TryGetValue(currentPost.InReplyToStatusId.Value, out var repPost))
+ if (this.statuses.Posts.TryGetValue(currentPost.InReplyToStatusId, out var repPost))
{
MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt.ToLocalTimeString()})" + Environment.NewLine + repPost.TextFromApi);
}
{
foreach (var tb in this.statuses.GetTabsByType(MyCommon.TabUsageType.Lists | MyCommon.TabUsageType.PublicSearch))
{
- if (tb == null || !tb.Contains(currentPost.InReplyToStatusId.Value)) break;
- repPost = tb.Posts[currentPost.InReplyToStatusId.Value];
+ if (tb == null || !tb.Contains(currentPost.InReplyToStatusId)) break;
+ repPost = tb.Posts[currentPost.InReplyToStatusId];
MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt.ToLocalTimeString()})" + Environment.NewLine + repPost.TextFromApi);
return;
}
- await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(currentPost.InReplyToUser, currentPost.InReplyToStatusId.Value));
+ await MyCommon.OpenInBrowserAsync(this, MyCommon.GetStatusUrl(currentPost.InReplyToUser, currentPost.InReplyToStatusId.ToTwitterStatusId()));
}
}
}
var match = Regex.Match(uri.AbsolutePath, @"^/status/(\d+)$");
if (match.Success)
{
- var statusId = long.Parse(match.Groups[1].Value);
+ var statusId = new TwitterStatusId(match.Groups[1].Value);
await this.OpenRelatedTab(statusId);
return;
}
var listView = this.CurrentListView;
var currentListViewState = this.listViewState[tab.TabName];
- currentListViewState.Restore();
+ currentListViewState.Restore(forceScroll: true);
if (this.Use2ColumnsMode)
{
(this.listCache, var oldCache) = (newCache, this.listCache);
oldCache?.Dispose();
- var newDrawer = new TimelineListViewDrawer(listView, tab, this.listCache, this.iconCache, this.themeManager)
- {
- IconSize = this.settings.Common.IconSize,
- };
+ var newDrawer = new TimelineListViewDrawer(listView, tab, this.listCache, this.iconCache, this.themeManager);
(this.listDrawer, var oldDrawer) = (newDrawer, this.listDrawer);
oldDrawer?.Dispose();
+
+ newDrawer.IconSize = this.settings.Common.IconSize;
+ newDrawer.UpdateItemHeight();
}
private void ListTab_Selecting(object sender, TabControlCancelEventArgs e)
// TweetFormatterクラスによって整形された状態のHTMLを元のツイートに復元します
// 通常の URL
- statusHtml = Regex.Replace(statusHtml, "<a href=\"(?<href>.+?)\" title=\"(?<title>.+?)\">(?<text>.+?)</a>", "${title}");
+ statusHtml = Regex.Replace(statusHtml, """<a href="(?<href>.+?)" title="(?<title>.+?)">(?<text>.+?)</a>""", "${title}");
// メンション
- statusHtml = Regex.Replace(statusHtml, "<a class=\"mention\" href=\"(?<href>.+?)\">(?<text>.+?)</a>", "${text}");
+ statusHtml = Regex.Replace(statusHtml, """<a class="mention" href="(?<href>.+?)">(?<text>.+?)</a>""", "${text}");
// ハッシュタグ
- statusHtml = Regex.Replace(statusHtml, "<a class=\"hashtag\" href=\"(?<href>.+?)\">(?<text>.+?)</a>", "${text}");
+ statusHtml = Regex.Replace(statusHtml, """<a class="hashtag" href="(?<href>.+?)">(?<text>.+?)</a>""", "${text}");
// 絵文字
- statusHtml = Regex.Replace(statusHtml, "<img class=\"emoji\" src=\".+?\" alt=\"(?<text>.+?)\" />", "${text}");
+ statusHtml = Regex.Replace(statusHtml, """<img class="emoji" src=".+?" alt="(?<text>.+?)" />""", "${text}");
// <br> 除去
if (multiline)
private void UndoRemoveTabMenuItem_Click(object sender, EventArgs e)
{
- if (this.statuses.RemovedTab.Count == 0)
- {
- MessageBox.Show("There isn't removed tab.", "Undo", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- else
+ try
{
- var tb = this.statuses.RemovedTab.Pop();
- if (tb.TabType == MyCommon.TabUsageType.Related)
- {
- var relatedTab = this.statuses.GetTabByType(MyCommon.TabUsageType.Related);
- if (relatedTab != null)
- {
- // 関連発言なら既存のタブを置き換える
- tb.TabName = relatedTab.TabName;
- this.ClearTab(tb.TabName, false);
-
- this.statuses.ReplaceTab(tb);
+ var restoredTab = this.statuses.UndoRemovedTab();
+ this.AddNewTab(restoredTab, startup: false);
- var tabIndex = this.statuses.Tabs.IndexOf(tb);
- this.ListTab.SelectedIndex = tabIndex;
- }
- else
- {
- const string TabName = "Related Tweets";
- var renamed = TabName;
- for (var i = 2; i <= 100; i++)
- {
- if (!this.statuses.ContainsTab(renamed))
- break;
- renamed = TabName + i;
- }
- tb.TabName = renamed;
-
- this.statuses.AddTab(tb);
- this.AddNewTab(tb, startup: false);
-
- var tabIndex = this.statuses.Tabs.Count - 1;
- this.ListTab.SelectedIndex = tabIndex;
- }
- }
- else
- {
- var renamed = tb.TabName;
- for (var i = 1; i < int.MaxValue; i++)
- {
- if (!this.statuses.ContainsTab(renamed))
- break;
- renamed = tb.TabName + "(" + i + ")";
- }
- tb.TabName = renamed;
-
- this.statuses.AddTab(tb);
- this.AddNewTab(tb, startup: false);
+ var tabIndex = this.statuses.Tabs.Count - 1;
+ this.ListTab.SelectedIndex = tabIndex;
- var tabIndex = this.statuses.Tabs.Count - 1;
- this.ListTab.SelectedIndex = tabIndex;
- }
this.SaveConfigsTabs();
}
+ catch (TabException ex)
+ {
+ MessageBox.Show(this, ex.Message, ApplicationSettings.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
private async Task DoMoveToRTHome()
private void MenuItemEdit_DropDownOpening(object sender, EventArgs e)
{
- if (this.statuses.RemovedTab.Count == 0)
- {
- this.UndoRemoveTabMenuItem.Enabled = false;
- }
- else
- {
- this.UndoRemoveTabMenuItem.Enabled = true;
- }
+ this.UndoRemoveTabMenuItem.Enabled = this.statuses.CanUndoRemovedTab;
if (this.CurrentTab.TabType == MyCommon.TabUsageType.PublicSearch)
this.PublicSearchQueryMenuItem.Enabled = true;
try
{
- var task = this.tw.Api.StatusesShow(statusId);
+ var task = this.tw.Api.StatusesShow(statusId.ToTwitterStatusId());
status = await dialog.WaitForAsync(this, task);
}
catch (WebApiException ex)
private void SelectMedia_DragEnter(DragEventArgs e)
{
- if (this.ImageSelector.HasUploadableService(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0], true))
+ if (this.ImageSelector.Model.HasUploadableService(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0], true))
{
e.Effect = DragDropEffects.Copy;
return;
{
this.Activate();
this.BringToFront();
- this.ImageSelector.BeginSelection((string[])e.Data.GetData(DataFormats.FileDrop, false));
+
+ var filePathArray = (string[])e.Data.GetData(DataFormats.FileDrop, false);
+ this.ImageSelector.BeginSelection();
+ this.ImageSelector.Model.AddMediaItemFromFilePath(filePathArray);
this.StatusText.Focus();
}
}
else if (Clipboard.ContainsImage())
{
- // 画像があるので投稿処理を行う
- if (MessageBox.Show(Properties.Resources.PostPictureConfirm3,
- Properties.Resources.PostPictureWarn4,
- MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button2)
- == DialogResult.OK)
- {
- // clipboardから画像を取得
- using var image = Clipboard.GetImage();
- this.ImageSelector.BeginSelection(image);
- }
+ // clipboardから画像を取得
+ using var image = Clipboard.GetImage();
+ this.ImageSelector.BeginSelection();
+ this.ImageSelector.Model.AddMediaItemFromImage(image);
}
else if (Clipboard.ContainsFileDropList())
{
var files = Clipboard.GetFileDropList().Cast<string>().ToArray();
- this.ImageSelector.BeginSelection(files);
+ this.ImageSelector.BeginSelection();
+ this.ImageSelector.Model.AddMediaItemFromFilePath(files);
}
}
catch (ExternalException ex)
/// </summary>
/// <param name="statusId">表示するツイートのID</param>
/// <exception cref="TabException">名前の重複が多すぎてタブを作成できない場合</exception>
- public async Task OpenRelatedTab(long statusId)
+ public async Task OpenRelatedTab(PostId statusId)
{
var post = this.statuses[statusId];
if (post == null)
{
try
{
- post = await this.tw.GetStatusApi(false, statusId);
+ post = await this.tw.GetStatusApi(false, statusId.ToTwitterStatusId());
}
catch (WebApiException ex)
{
private async Task OpenUserAppointUrl()
{
- if (this.settings.Common.UserAppointUrl != null)
+ if (!MyCommon.IsNullOrEmpty(this.settings.Common.UserAppointUrl))
{
if (this.settings.Common.UserAppointUrl.Contains("{ID}") || this.settings.Common.UserAppointUrl.Contains("{STATUS}"))
{
xUrl = xUrl.Replace("{ID}", post.ScreenName);
var statusId = post.RetweetedId ?? post.StatusId;
- xUrl = xUrl.Replace("{STATUS}", statusId.ToString());
+ xUrl = xUrl.Replace("{STATUS}", statusId.Id);
await MyCommon.OpenInBrowserAsync(this, xUrl);
}
this.BringToFront();
if (e.NotifyType == GrowlHelper.NotifyType.DirectMessage)
{
- if (!this.GoDirectMessage(e.StatusId)) this.StatusText.Focus();
+ if (!this.GoDirectMessage(new TwitterStatusId(e.StatusId))) this.StatusText.Focus();
}
else
{
- if (!this.GoStatus(e.StatusId)) this.StatusText.Focus();
+ if (!this.GoStatus(new TwitterStatusId(e.StatusId))) this.StatusText.Focus();
}
});
}
this.AboutMenuItem.Text = MyCommon.ReplaceAppName(this.AboutMenuItem.Text);
}
- private void TweetThumbnail_ThumbnailLoading(object sender, EventArgs e)
- => this.SplitContainer3.Panel2Collapsed = false;
-
- private async void TweetThumbnail_ThumbnailDoubleClick(object sender, ThumbnailDoubleClickEventArgs e)
- => await this.OpenThumbnailPicture(e.Thumbnail);
-
- private async void TweetThumbnail_ThumbnailImageSearchClick(object sender, ThumbnailImageSearchEventArgs e)
- => await MyCommon.OpenInBrowserAsync(this, e.ImageUrl);
-
- private async Task OpenThumbnailPicture(ThumbnailInfo thumbnail)
- {
- var url = thumbnail.FullSizeImageUrl ?? thumbnail.MediaPageUrl;
-
- await MyCommon.OpenInBrowserAsync(this, url);
- }
-
private async void TwitterApiStatusToolStripMenuItem_Click(object sender, EventArgs e)
=> await MyCommon.OpenInBrowserAsync(this, Twitter.ServiceAvailabilityStatusUrl);