private async Task FavoriteChange(bool FavAdd, bool multiFavoriteChangeDialogEnable = true)
{
TabModel tab;
if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
return;
//trueでFavAdd,falseでFavRemove
if (tab.TabType == MyCommon.TabUsageType.DirectMessage || _curList.SelectedIndices.Count == 0
|| !this.ExistCurrentPost) return;
if (this._curList.SelectedIndices.Count > 1)
{
if (FavAdd)
{
// 複数ツイートの一括ふぁぼは禁止
// https://support.twitter.com/articles/76915#favoriting
MessageBox.Show(string.Format(Properties.Resources.FavoriteLimitCountText, 1));
_DoFavRetweetFlags = false;
return;
}
else
{
if (multiFavoriteChangeDialogEnable)
{
var confirm = MessageBox.Show(Properties.Resources.FavRemoveToolStripMenuItem_ClickText1,
Properties.Resources.FavRemoveToolStripMenuItem_ClickText2,
MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (confirm == DialogResult.Cancel)
return;
}
}
}
if (FavAdd)
{
var selectedPost = this.GetCurTabPost(_curList.SelectedIndices[0]);
if (selectedPost.IsFav)
{
this.StatusLabel.Text = Properties.Resources.FavAddToolStripMenuItem_ClickText4;
return;
}
await this.FavAddAsync(selectedPost.StatusId, tab);
}
else
{
var selectedPosts = this._curList.SelectedIndices.Cast<int>()
.Select(x => this.GetCurTabPost(x))
.Where(x => x.IsFav);
var statusIds = selectedPosts.Select(x => x.StatusId).ToArray();
if (statusIds.Length == 0)
{
this.StatusLabel.Text = Properties.Resources.FavRemoveToolStripMenuItem_ClickText4;
return;
}
await this.FavRemoveAsync(statusIds, tab);
}
}