// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.
+#nullable enable
+
//コンパイル後コマンド
//"c:\Program Files\Microsoft.NET\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
//"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /f /a:"$(TargetPath)"
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Globalization;
using System.IO;
/// <summary>タブドラッグ中フラグ(DoDragDropを実行するかの判定用)</summary>
private bool _tabDrag;
- private TabPage _beforeSelectedTab; // タブが削除されたときに前回選択されていたときのタブを選択する為に保持
+ private TabPage? _beforeSelectedTab; // タブが削除されたときに前回選択されていたときのタブを選択する為に保持
private Point _tabMouseDownPoint;
/// <summary>右クリックしたタブの名前(Tabコントロール機能不足対応)</summary>
- private string _rclickTabName;
+ private string? _rclickTabName;
private readonly object _syncObject = new object(); // ロック用
+ "--></style>"
+ "</head><body><p>";
private const string detailHtmlFormatFooterColor = "</p></body></html>";
- private string detailHtmlFormatHeader;
- private string detailHtmlFormatFooter;
+ private string detailHtmlFormatHeader = null!;
+ private string detailHtmlFormatFooter = null!;
private bool _myStatusError = false;
private bool _myStatusOnline = false;
//twitter解析部
private readonly TwitterApi twitterApi = new TwitterApi();
- private Twitter tw;
+ private Twitter tw = null!;
//Growl呼び出し部
private readonly GrowlHelper gh = new GrowlHelper(ApplicationSettings.ApplicationName);
private readonly OpenURL UrlDialog = new OpenURL();
/// <summary>@id補助</summary>
- public AtIdSupplement AtIdSupl;
+ public AtIdSupplement AtIdSupl = null!;
/// <summary>Hashtag補助</summary>
- public AtIdSupplement HashSupl;
+ public AtIdSupplement HashSupl = null!;
- public HashtagManage HashMgr;
- private EventViewerDialog evtDialog;
+ public HashtagManage HashMgr = null!;
+ private EventViewerDialog evtDialog = null!;
//表示フォント、色、アイコン
/// <summary>未読用フォント</summary>
- private Font _fntUnread;
+ private Font _fntUnread = null!;
/// <summary>未読用文字色</summary>
private Color _clUnread;
/// <summary>既読用フォント</summary>
- private Font _fntReaded;
+ private Font _fntReaded = null!;
/// <summary>既読用文字色</summary>
private Color _clReaded;
private readonly Color _clHighLight = Color.FromKnownColor(KnownColor.HighlightText);
/// <summary>発言詳細部用フォント</summary>
- private Font _fntDetail;
+ private Font _fntDetail = null!;
/// <summary>発言詳細部用色</summary>
private Color _clDetail;
private Color _clInputFont;
/// <summary>入力欄フォント</summary>
- private Font _fntInputFont;
+ private Font _fntInputFont = null!;
/// <summary>アイコン画像リスト</summary>
- private ImageCache IconCache;
+ private ImageCache IconCache = null!;
/// <summary>タスクトレイアイコン:通常時 (At.ico)</summary>
- private Icon NIconAt;
+ private Icon NIconAt = null!;
/// <summary>タスクトレイアイコン:通信エラー時 (AtRed.ico)</summary>
- private Icon NIconAtRed;
+ private Icon NIconAtRed = null!;
/// <summary>タスクトレイアイコン:オフライン時 (AtSmoke.ico)</summary>
- private Icon NIconAtSmoke;
+ private Icon NIconAtSmoke = null!;
/// <summary>タスクトレイアイコン:更新中 (Refresh.ico)</summary>
private Icon[] NIconRefresh = new Icon[4];
/// <summary>未読のあるタブ用アイコン (Tab.ico)</summary>
- private Icon TabIcon;
+ private Icon TabIcon = null!;
/// <summary>画面左上のアイコン (Main.ico)</summary>
- private Icon MainIcon;
+ private Icon MainIcon = null!;
- private Icon ReplyIcon;
- private Icon ReplyIconBlink;
+ private Icon ReplyIcon = null!;
+ private Icon ReplyIconBlink = null!;
- private readonly ImageList _listViewImageList = new ImageList(); // ListViewItemの高さ変更用
+ private readonly ImageList _listViewImageList = new ImageList(); //ListViewItemの高さ変更用
- private PostClass _anchorPost;
- private bool _anchorFlag; // true:関連発言移動中(関連移動以外のオペレーションをするとfalseへ。trueだとリスト背景色をアンカー発言選択中として描画)
+ private PostClass? _anchorPost;
+ private bool _anchorFlag; //true:関連発言移動中(関連移動以外のオペレーションをするとfalseへ。trueだとリスト背景色をアンカー発言選択中として描画)
/// <summary>発言履歴</summary>
private readonly List<StatusTextHistory> _history = new List<StatusTextHistory>();
// 以下DrawItem関連
private readonly SolidBrush _brsHighLight = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
- private SolidBrush _brsBackColorMine;
- private SolidBrush _brsBackColorAt;
- private SolidBrush _brsBackColorYou;
- private SolidBrush _brsBackColorAtYou;
- private SolidBrush _brsBackColorAtFromTarget;
- private SolidBrush _brsBackColorAtTo;
- private SolidBrush _brsBackColorNone;
+ private SolidBrush _brsBackColorMine = null!;
+ private SolidBrush _brsBackColorAt = null!;
+ private SolidBrush _brsBackColorYou = null!;
+ private SolidBrush _brsBackColorAtYou = null!;
+ private SolidBrush _brsBackColorAtFromTarget = null!;
+ private SolidBrush _brsBackColorAtTo = null!;
+ private SolidBrush _brsBackColorNone = null!;
/// <summary>Listにフォーカスないときの選択行の背景色</summary>
private readonly SolidBrush _brsDeactiveSelection = new SolidBrush(Color.FromKnownColor(KnownColor.ButtonFace));
private readonly StringFormat sfTab = new StringFormat();
//////////////////////////////////////////////////////////////////////////////////////////////////////////
- private TabInformations _statuses;
+ private TabInformations _statuses = null!;
/// <summary>
/// 現在表示している発言一覧の <see cref="ListView"/> に対するキャッシュ
/// 使用する場合には <see cref="_listItemCache"/> に対して直接メソッド等を呼び出さずに
/// 一旦ローカル変数に代入してから参照すること。
/// </remarks>
- private ListViewItemCache _listItemCache = null;
+ private ListViewItemCache? _listItemCache = null;
internal class ListViewItemCache
{
/// <summary>アイテムをキャッシュする対象の <see cref="ListView"/></summary>
- public ListView TargetList { get; set; }
+ public ListView TargetList { get; set; } = null!;
/// <summary>キャッシュする範囲の開始インデックス</summary>
public int StartIndex { get; set; }
public int EndIndex { get; set; }
/// <summary>キャッシュされた範囲に対応する <see cref="ListViewItem"/> と <see cref="PostClass"/> の組</summary>
- public (ListViewItem, PostClass)[] Cache { get; set; }
+ public (ListViewItem, PostClass)[] Cache { get; set; } = null!;
/// <summary>キャッシュされたアイテムの件数</summary>
public int Count
/// <summary>指定されたインデックスの <see cref="ListViewItem"/> と <see cref="PostClass"/> をキャッシュから取得することを試みます</summary>
/// <returns>取得に成功すれば true、それ以外は false</returns>
- public bool TryGetValue(int index, out ListViewItem item, out PostClass post)
+ public bool TryGetValue(int index, [NotNullWhen(true)] out ListViewItem? item, [NotNullWhen(true)] out PostClass? post)
{
if (this.Contains(index))
{
private const int MAX_WORKER_THREADS = 20;
private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
private readonly CancellationTokenSource workerCts = new CancellationTokenSource();
- private readonly IProgress<string> workerProgress;
+ private readonly IProgress<string> workerProgress = null!;
private int UnreadCounter = -1;
private int UnreadAtCounter = -1;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
private readonly TimelineScheduler timelineScheduler = new TimelineScheduler();
- private ThrottlingTimer RefreshThrottlingTimer;
- private ThrottlingTimer colorizeDebouncer;
- private ThrottlingTimer selectionDebouncer;
- private ThrottlingTimer saveConfigDebouncer;
+ private ThrottlingTimer RefreshThrottlingTimer = null!;
+ private ThrottlingTimer colorizeDebouncer = null!;
+ private ThrottlingTimer selectionDebouncer = null!;
+ private ThrottlingTimer saveConfigDebouncer = null!;
- private string recommendedStatusFooter;
+ private string recommendedStatusFooter = null!;
private bool urlMultibyteSplit = false;
private bool preventSmsCommand = true;
public string After;
}
- private List<urlUndo> urlUndoBuffer = null;
+ private List<urlUndo>? urlUndoBuffer = null;
private readonly struct ReplyChain
{
}
/// <summary>[, ]でのリプライ移動の履歴</summary>
- private Stack<ReplyChain> replyChains;
+ private Stack<ReplyChain>? replyChains;
/// <summary>ポスト選択履歴</summary>
- private readonly Stack<(TabModel, PostClass)> selectPostChains = new Stack<(TabModel, PostClass)>();
+ private readonly Stack<(TabModel, PostClass?)> selectPostChains = new Stack<(TabModel, PostClass?)>();
public TabModel CurrentTab
=> this._statuses.SelectedTab;
public DetailsListView CurrentListView
=> (DetailsListView)this.CurrentTabPage.Tag;
- public PostClass CurrentPost
+ public PostClass? CurrentPost
=> this.CurrentTab.SelectedPost;
/// <summary>検索処理タイプ</summary>
/// <summary>画像投稿サービス名</summary>
public string imageService = "";
- public IMediaItem[] mediaItems = null;
+ public IMediaItem[]? mediaItems = null;
public StatusTextHistory()
{
}
}
}
- private Icon LoadIcon(string filePath)
+ private Icon? LoadIcon(string filePath)
{
if (!File.Exists(filePath))
return null;
{
this.InitColumnText();
- ColumnHeader[] columns = null;
+ ColumnHeader[]? columns = null;
try
{
if (this._iconCol)
TimerRefreshIcon.Enabled = false;
_ignoreConfigSave = false;
- this.TweenMain_Resize(null, null);
+ this.TweenMain_Resize(this, EventArgs.Empty);
if (saveRequired) SaveConfigsAll(false);
foreach (var ua in SettingManager.Common.UserAccounts)
tab = new FilterTabModel(tabSetting.TabName);
break;
case MyCommon.TabUsageType.UserTimeline:
- tab = new UserTimelineTabModel(tabSetting.TabName, tabSetting.User);
+ tab = new UserTimelineTabModel(tabSetting.TabName, tabSetting.User!);
break;
case MyCommon.TabUsageType.PublicSearch:
tab = new PublicSearchTabModel(tabSetting.TabName)
};
break;
case MyCommon.TabUsageType.Lists:
- tab = new ListTimelineTabModel(tabSetting.TabName, tabSetting.ListInfo);
+ tab = new ListTimelineTabModel(tabSetting.TabName, tabSetting.ListInfo!);
break;
case MyCommon.TabUsageType.Mute:
tab = new MuteTabModel(tabSetting.TabName);
internal struct ListViewSelection
{
- public long[] SelectedStatusIds { get; set; }
+ public long[]? SelectedStatusIds { get; set; }
public long? SelectionMarkStatusId { get; set; }
public long? FocusedStatusId { get; set; }
}
private void RestoreListViewSelection(DetailsListView listView, TabModel tab, ListViewSelection listSelection)
{
// status_id から ListView 上のインデックスに変換
- int[] selectedIndices = null;
+ int[]? selectedIndices = null;
if (listSelection.SelectedStatusIds != null)
selectedIndices = tab.IndexOf(listSelection.SelectedStatusIds).Where(x => x != -1).ToArray();
this.PushSelectPostChain();
- var post = this.CurrentPost;
+ var post = this.CurrentPost!;
this._statuses.SetReadAllTab(post.StatusId, read: true);
//キャッシュの書き換え
ChangeItemStyleRead(Read, itm, post, (DetailsListView)listCache.TargetList);
}
- private void ChangeItemStyleRead(bool Read, ListViewItem Item, PostClass Post, DetailsListView DList)
+ private void ChangeItemStyleRead(bool Read, ListViewItem Item, PostClass Post, DetailsListView? DList)
{
Font fnt;
string star;
{
//Index:更新対象のListviewItem.Index。Colorを返す。
//-1は全キャッシュ。Colorは返さない(ダミーを戻す)
- PostClass _post;
+ PostClass? _post;
if (_anchorFlag)
_post = _anchorPost;
else
{
//Index:更新対象のListviewItem.Index。Colorを返す。
//-1は全キャッシュ。Colorは返さない(ダミーを戻す)
- PostClass _post;
+ PostClass? _post;
if (_anchorFlag)
_post = _anchorPost;
else
}
var currentPost = this.CurrentPost;
- if (this.ExistCurrentPost && StatusText.Text.Trim() == string.Format("RT @{0}: {1}", currentPost.ScreenName, currentPost.TextFromApi))
+ if (this.ExistCurrentPost && currentPost != null && StatusText.Text.Trim() == string.Format("RT @{0}: {1}", currentPost.ScreenName, currentPost.TextFromApi))
{
var rtResult = MessageBox.Show(string.Format(Properties.Resources.PostButton_Click1, Environment.NewLine),
"Retweet",
return;
}
- IMediaUploadService uploadService = null;
- IMediaItem[] uploadItems = null;
+ IMediaUploadService? uploadService = null;
+ IMediaItem[]? uploadItems = null;
if (ImageSelector.Visible)
{
//画像投稿
.ConfigureAwait(false);
}
catch (TwitterApiException ex)
- when (ex.ErrorResponse.Errors.All(x => x.Code == TwitterErrorCode.AlreadyFavorited))
+ when (ex.Errors.All(x => x.Code == TwitterErrorCode.AlreadyFavorited))
{
// エラーコード 139 のみの場合は成功と見なす
}
this._favTimestamps.Add(DateTimeUtc.Now);
// TLでも取得済みならfav反映
- if (this._statuses.ContainsKey(statusId))
+ if (this._statuses.Posts.TryGetValue(statusId, out var postTl))
{
- var postTl = this._statuses[statusId];
postTl.IsFav = true;
- var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
+ var favTab = this._statuses.FavoriteTab;
favTab.AddPostQueue(postTl);
}
successIds.Add(statusId);
post.IsFav = false; // リスト再描画必要
- if (this._statuses.ContainsKey(statusId))
- {
- this._statuses[statusId].IsFav = false;
- }
+ if (this._statuses.Posts.TryGetValue(statusId, out var tabinfoPost))
+ tabinfoPost.IsFav = false;
// 検索,リスト,UserTimeline,Relatedの各タブに反映
foreach (var tb in this._statuses.GetTabsInnerStorageType())
if (ct.IsCancellationRequested)
return;
- var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
+ var favTab = this._statuses.FavoriteTab;
foreach (var statusId in successIds)
{
// ツイートが削除された訳ではないので IsDeleted はセットしない
}
}
- private async Task PostMessageAsync(PostStatusParams postParams, IMediaUploadService uploadService, IMediaItem[] uploadItems)
+ private async Task PostMessageAsync(PostStatusParams postParams, IMediaUploadService? uploadService, IMediaItem[]? uploadItems)
{
await this.workerSemaphore.WaitAsync();
this.RefreshTasktrayIcon();
}
private async Task PostMessageAsyncInternal(IProgress<string> p, CancellationToken ct, PostStatusParams postParams,
- IMediaUploadService uploadService, IMediaItem[] uploadItems)
+ IMediaUploadService? uploadService, IMediaItem[]? uploadItems)
{
if (ct.IsCancellationRequested)
return;
p.Report("Posting...");
- PostClass post = null;
+ PostClass? post = null;
var errMsg = "";
try
await ShowUserTimeline();
break;
case 4:
- ShowRelatedStatusesMenuItem_Click(null, null);
+ ShowRelatedStatusesMenuItem_Click(this.ShowRelatedStatusesMenuItem, EventArgs.Empty);
break;
case 5:
- MoveToHomeToolStripMenuItem_Click(null, null);
+ MoveToHomeToolStripMenuItem_Click(this.MoveToHomeToolStripMenuItem, EventArgs.Empty);
break;
case 6:
- StatusOpenMenuItem_Click(null, null);
+ StatusOpenMenuItem_Click(this.StatusOpenMenuItem, EventArgs.Empty);
break;
case 7:
//動作なし
}
var tab = this.CurrentTab;
var post = this.CurrentPost;
- if (tab.TabType == MyCommon.TabUsageType.DirectMessage || !this.ExistCurrentPost || post.IsDm)
+ if (tab.TabType == MyCommon.TabUsageType.DirectMessage || !this.ExistCurrentPost || post == null || post.IsDm)
{
FavAddToolStripMenuItem.Enabled = false;
FavRemoveToolStripMenuItem.Enabled = false;
//{
// RefreshMoreStripMenuItem.Enabled = false;
//}
- if (!this.ExistCurrentPost || post.InReplyToStatusId == null)
+ if (!this.ExistCurrentPost || post == null || post.InReplyToStatusId == null)
{
RepliedStatusOpenMenuItem.Enabled = false;
}
{
RepliedStatusOpenMenuItem.Enabled = true;
}
- if (!this.ExistCurrentPost || string.IsNullOrEmpty(post.RetweetedBy))
+ if (!this.ExistCurrentPost || post == null || string.IsNullOrEmpty(post.RetweetedBy))
{
MoveToRTHomeMenuItem.Enabled = false;
}
MoveToRTHomeMenuItem.Enabled = true;
}
- if (this.ExistCurrentPost)
+ if (this.ExistCurrentPost && post != null)
{
this.DeleteStripMenuItem.Enabled = post.CanDeleteBy(this.tw.UserId);
if (post.RetweetedByUserId == this.tw.UserId)
using (ControlTransaction.Cursor(this, Cursors.WaitCursor))
{
- Exception lastException = null;
+ Exception? lastException = null;
foreach (var post in posts)
{
if (!post.CanDeleteBy(this.tw.UserId))
if (SettingManager.Common.IsUseNotifyGrowl) gh.RegisterGrowl();
try
{
- StatusText_TextChanged(null, null);
+ StatusText_TextChanged(this.StatusText, EventArgs.Empty);
}
catch (Exception)
{
cmb.Text = searchWord;
SaveConfigsTabs();
//検索実行
- this.SearchButton_Click(tabPage.Controls["panelSearch"].Controls["comboSearch"], null);
+ this.SearchButton_Click(tabPage.Controls["panelSearch"].Controls["comboSearch"], EventArgs.Empty);
}
private async Task ShowUserTimeline()
{
- if (!this.ExistCurrentPost) return;
- await this.AddNewTabForUserTimeline(this.CurrentPost.ScreenName);
+ var post = this.CurrentPost;
+ if (post == null || !this.ExistCurrentPost) return;
+ await this.AddNewTabForUserTimeline(post.ScreenName);
}
private void SearchComboBox_KeyDown(object sender, KeyEventArgs e)
public bool RemoveSpecifiedTab(string TabName, bool confirm)
{
var tabInfo = _statuses.GetTabByName(TabName);
- if (tabInfo.IsDefaultTabType || tabInfo.Protected) return false;
+ if (tabInfo == null || tabInfo.IsDefaultTabType || tabInfo.Protected)
+ return false;
if (confirm)
{
{
e.Handled = true;
StatusText.Text = "";
- JumpUnreadMenuItem_Click(null, null);
+ JumpUnreadMenuItem_Click(this.JumpUnreadMenuItem, EventArgs.Empty);
}
}
}
- this.StatusText_TextChanged(null, null);
+ this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
}
private void StatusText_TextChanged(object sender, EventArgs e)
/// <summary>
/// attachment_url に指定可能な URL が含まれていれば除去
/// </summary>
- private string RemoveAttachmentUrl(string statusText, out string attachmentUrl)
+ private string RemoveAttachmentUrl(string statusText, out string? attachmentUrl)
{
attachmentUrl = null;
/// <summary>
/// <see cref="FormatStatusText"/> に加えて、拡張モードで140字にカウントされない文字列の除去を行います
/// </summary>
- private string FormatStatusTextExtended(string statusText, out long[] autoPopulatedUserIds, out string attachmentUrl)
+ private string FormatStatusTextExtended(string statusText, out long[] autoPopulatedUserIds, out string? attachmentUrl)
{
statusText = this.RemoveAutoPopuratedMentions(statusText, out autoPopulatedUserIds);
return remainCount;
}
- private IMediaUploadService GetSelectedImageService()
+ private IMediaUploadService? GetSelectedImageService()
=> this.ImageSelector.Visible ? this.ImageSelector.SelectedService : null;
private void MyList_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e)
}
this.TopMost = SettingManager.Common.AlwaysTop;
- var searchOptions = this.SearchDialog.ResultOptions;
+ var searchOptions = this.SearchDialog.ResultOptions!;
if (searchOptions.Type == SearchWordDialog.SearchType.Timeline)
{
if (searchOptions.NewTab)
if (ImageSelector.Enabled)
return;
- TabModel foundTab = null;
+ TabModel? foundTab = null;
var foundIndex = 0;
- DetailsListView lst = null;
-
//現在タブから最終タブまで探索
foreach (var (tab, index) in this._statuses.Tabs.WithIndex().Skip(bgnIdx))
{
ListTab.SelectedIndex = index;
foundTab = tab;
foundIndex = unreadIndex;
- lst = (DetailsListView)this.ListTab.TabPages[index].Tag;
break;
}
}
ListTab.SelectedIndex = index;
foundTab = tab;
foundIndex = unreadIndex;
- lst = (DetailsListView)this.ListTab.TabPages[index].Tag;
break;
}
}
}
+ DetailsListView lst;
+
if (foundTab == null)
{
//全部調べたが未読見つからず→先頭タブの最新発言へ
lst = (DetailsListView)tabPage.Tag;
}
+ else
+ {
+ var foundTabIndex = this._statuses.Tabs.IndexOf(foundTab);
+ lst = (DetailsListView)this.ListTab.TabPages[foundTabIndex].Tag;
+ }
SelectListItem(lst, foundIndex);
public class VersionInfo
{
- public Version Version { get; set; }
- public Uri DownloadUri { get; set; }
- public string ReleaseNote { get; set; }
+ public Version Version { get; }
+ public Uri DownloadUri { get; }
+ public string ReleaseNote { get; }
+
+ public VersionInfo(Version version, Uri downloadUri, string releaseNote)
+ => (this.Version, this.DownloadUri, this.ReleaseNote) = (version, downloadUri, releaseNote);
}
/// <summary>
msgBody = Regex.Replace(msgBody, "(?<!\r)\n", "\r\n"); // LF -> CRLF
- return new VersionInfo
- {
- Version = Version.Parse(msgHeader[0]),
- DownloadUri = new Uri(msgHeader[1]),
- ReleaseNote = msgBody,
- };
+ return new VersionInfo(
+ version: Version.Parse(msgHeader[0]),
+ downloadUri: new Uri(msgHeader[1]),
+ releaseNote: msgBody
+ );
}
private async Task CheckNewVersion(bool startup = false)
/// <summary>
/// サムネイル表示に使用する CancellationToken の生成元
/// </summary>
- private CancellationTokenSource thumbnailTokenSource = null;
+ private CancellationTokenSource? thumbnailTokenSource = null;
private void DispSelectedPost(bool forceupdate)
{
var oldTokenSource = Interlocked.Exchange(ref this.thumbnailTokenSource, new CancellationTokenSource());
oldTokenSource?.Cancel();
- var token = this.thumbnailTokenSource.Token;
+ var token = this.thumbnailTokenSource!.Token;
loadTasks.Add(this.tweetThumbnail1.ShowThumbnailAsync(currentPost, token));
}
.Do(() => this.OpenApplicationWebsite()),
ShortcutCommand.Create(Keys.F3)
- .Do(() => this.MenuItemSearchNext_Click(null, null)),
+ .Do(() => this.MenuItemSearchNext_Click(this.MenuItemSearchNext, EventArgs.Empty)),
ShortcutCommand.Create(Keys.F5)
.Do(() => this.DoRefresh()),
ShortcutCommand.Create(Keys.Space, Keys.ProcessKey)
.NotFocusedOn(FocusedControl.StatusText)
- .Do(() => { this._anchorFlag = false; this.JumpUnreadMenuItem_Click(null, null); }),
+ .Do(() => { this._anchorFlag = false; this.JumpUnreadMenuItem_Click(this.JumpUnreadMenuItem, EventArgs.Empty); }),
ShortcutCommand.Create(Keys.G)
.NotFocusedOn(FocusedControl.StatusText)
- .Do(() => { this._anchorFlag = false; this.ShowRelatedStatusesMenuItem_Click(null, null); }),
+ .Do(() => { this._anchorFlag = false; this.ShowRelatedStatusesMenuItem_Click(this.ShowRelatedStatusesMenuItem, EventArgs.Empty); }),
ShortcutCommand.Create(Keys.Right, Keys.N)
.FocusedOn(FocusedControl.ListTab)
.Do(() => this.doQuoteOfficial()),
ShortcutCommand.Create(Keys.Control | Keys.B)
- .Do(() => this.ReadedStripMenuItem_Click(null, null)),
+ .Do(() => this.ReadedStripMenuItem_Click(this.ReadedStripMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.T)
- .Do(() => this.HashManageMenuItem_Click(null, null)),
+ .Do(() => this.HashManageMenuItem_Click(this.HashManageMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.L)
- .Do(() => this.UrlConvertAutoToolStripMenuItem_Click(null, null)),
+ .Do(() => this.UrlConvertAutoToolStripMenuItem_Click(this.UrlConvertAutoToolStripMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.Y)
.NotFocusedOn(FocusedControl.PostBrowser)
- .Do(() => this.MultiLineMenuItem_Click(null, null)),
+ .Do(() => this.MultiLineMenuItem_Click(this.MultiLineMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.F)
- .Do(() => this.MenuItemSubSearch_Click(null, null)),
+ .Do(() => this.MenuItemSubSearch_Click(this.MenuItemSubSearch, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.U)
.Do(() => this.ShowUserTimeline()),
ShortcutCommand.Create(Keys.Control | Keys.H)
- .Do(() => this.MoveToHomeToolStripMenuItem_Click(null, null)),
+ .Do(() => this.MoveToHomeToolStripMenuItem_Click(this.MoveToHomeToolStripMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.G)
- .Do(() => this.MoveToFavToolStripMenuItem_Click(null, null)),
+ .Do(() => this.MoveToFavToolStripMenuItem_Click(this.MoveToFavToolStripMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.O)
- .Do(() => this.StatusOpenMenuItem_Click(null, null)),
+ .Do(() => this.StatusOpenMenuItem_Click(this.StatusOpenMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.E)
- .Do(() => this.OpenURLMenuItem_Click(null, null)),
+ .Do(() => this.OpenURLMenuItem_Click(this.OpenURLMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.Home, Keys.Control | Keys.End)
.FocusedOn(FocusedControl.ListTab)
}),
ShortcutCommand.Create(Keys.Shift | Keys.F3)
- .Do(() => this.MenuItemSearchPrev_Click(null, null)),
+ .Do(() => this.MenuItemSearchPrev_Click(this.MenuItemSearchPrev, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Shift | Keys.F5)
.Do(() => this.DoRefreshMore()),
ShortcutCommand.Create(Keys.Alt | Keys.P)
.OnlyWhen(() => this.CurrentPost != null)
- .Do(() => this.doShowUserStatus(this.CurrentPost.ScreenName, ShowInputDialog: false)),
+ .Do(() => this.doShowUserStatus(this.CurrentPost!.ScreenName, ShowInputDialog: false)),
ShortcutCommand.Create(Keys.Alt | Keys.Up)
.Do(() => this.tweetDetailsView.ScrollDownPostBrowser(forward: false)),
.Do(() => this.FavoriteChange(FavAdd: false)),
ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.B)
- .Do(() => this.UnreadStripMenuItem_Click(null, null)),
+ .Do(() => this.UnreadStripMenuItem_Click(this.UnreadStripMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.T)
- .Do(() => this.HashToggleMenuItem_Click(null, null)),
+ .Do(() => this.HashToggleMenuItem_Click(this.HashToggleMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.P)
- .Do(() => this.ImageSelectMenuItem_Click(null, null)),
+ .Do(() => this.ImageSelectMenuItem_Click(this.ImageSelectMenuItem, EventArgs.Empty)),
ShortcutCommand.Create(Keys.Control | Keys.Shift | Keys.H)
.Do(() => this.doMoveToRTHome()),
};
}
- internal bool CommonKeyDown(Keys keyData, FocusedControl focusedOn, out Task asyncTask)
+ internal bool CommonKeyDown(Keys keyData, FocusedControl focusedOn, out Task? asyncTask)
{
// Task を返す非同期処理があれば asyncTask に代入する
asyncTask = null;
}
string name;
- if (currentPost.RetweetedId == null)
+ if (currentPost.RetweetedBy == null)
{
name = currentPost.ScreenName;
}
if (this.selectPostChains.Count > 1)
{
var idx = -1;
- TabModel foundTab = null;
+ TabModel? foundTab = null;
do
{
private void TrimPostChain()
{
if (this.selectPostChains.Count <= 2000) return;
- var p = new Stack<(TabModel, PostClass)>(2000);
+ var p = new Stack<(TabModel, PostClass?)>(2000);
for (var i = 0; i < 2000; i++)
{
p.Push(this.selectPostChains.Pop());
{
if (statusId == 0) return false;
- var tab = this._statuses.GetTabByType<DirectMessagesTabModel>();
+ var tab = this._statuses.DirectMessageTab;
var index = tab.IndexOf(statusId);
if (index == -1)
e.SuppressKeyPress = true;
}
- this.StatusText_TextChanged(null, null);
+ this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
if (asyncTask != null)
await asyncTask;
this.TopMost = SettingManager.Common.AlwaysTop;
}
- public bool TabRename(string origTabName, out string newTabName)
+ public bool TabRename(string origTabName, [NotNullWhen(true)] out string? newTabName)
{
//タブ名変更
newTabName = null;
private void TabMenuControl(string tabName)
{
- var tabInfo = _statuses.GetTabByName(tabName);
+ var tabInfo = _statuses.GetTabByName(tabName)!;
this.FilterEditMenuItem.Enabled = true;
this.EditRuleTbMenuItem.Enabled = true;
private void FilterEditMenuItem_Click(object sender, EventArgs e)
{
- if (string.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.GetTabByType(MyCommon.TabUsageType.Home).TabName;
+ if (string.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.HomeTab.TabName;
using (var fltDialog = new FilterDialog())
{
private async void AddTabMenuItem_Click(object sender, EventArgs e)
{
- string tabName = null;
+ string? tabName = null;
MyCommon.TabUsageType tabUsage;
using (var inputName = new InputTabName())
{
if (!string.IsNullOrEmpty(tabName))
{
//List対応
- ListElement list = null;
+ ListElement? list = null;
if (tabUsage == MyCommon.TabUsageType.Lists)
{
using var listAvail = new ListAvailable();
tab = new PublicSearchTabModel(tabName);
break;
case MyCommon.TabUsageType.Lists:
- tab = new ListTimelineTabModel(tabName, list);
+ tab = new ListTimelineTabModel(tabName, list!);
break;
default:
return;
fltDialog.SetCurrent(tabName);
- if (post.RetweetedId == null)
+ if (post.RetweetedBy == null)
{
fltDialog.AddNewFilter(post.ScreenName, post.TextFromApi);
}
}
else if (_Post)
{
- PostButton_Click(null, null);
+ PostButton_Click(this.PostButton, EventArgs.Empty);
return true;
}
}
if (tabPage.Controls["panelSearch"].Controls["comboSearch"].Focused ||
tabPage.Controls["panelSearch"].Controls["comboLang"].Focused)
{
- this.SearchButton_Click(tabPage.Controls["panelSearch"].Controls["comboSearch"], null);
+ this.SearchButton_Click(tabPage.Controls["panelSearch"].Controls["comboSearch"], EventArgs.Empty);
return true;
}
}
return;
var screenNameArray = selectedPosts
- .Select(x => x.RetweetedId != null ? x.RetweetedBy : x.ScreenName)
+ .Select(x => x.RetweetedBy ?? x.ScreenName)
.ToArray();
this.AddFilterRuleByScreenName(screenNameArray);
this.SaveConfigsTabs();
}
- private bool SelectTab(out string tabName)
+ private bool SelectTab([NotNullWhen(true)] out string? tabName)
{
do
{
ttl.Append(_history[_history.Count - 2].status.Replace("\r\n", " "));
break;
case MyCommon.DispTitleEnum.UnreadRepCount:
- ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText1, _statuses.GetTabByType(MyCommon.TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage).UnreadCount);
+ ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText1, _statuses.MentionTab.UnreadCount + _statuses.DirectMessageTab.UnreadCount);
break;
case MyCommon.DispTitleEnum.UnreadAllCount:
ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText2, ur);
break;
case MyCommon.DispTitleEnum.UnreadAllRepCount:
- ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText3, ur, _statuses.GetTabByType(MyCommon.TabUsageType.Mentions).UnreadCount + _statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage).UnreadCount);
+ ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText3, ur, _statuses.MentionTab.UnreadCount + _statuses.DirectMessageTab.UnreadCount);
break;
case MyCommon.DispTitleEnum.UnreadCountAllCount:
ttl.AppendFormat(Properties.Resources.SetMainWindowTitleText4, ur, al);
//ステータス欄にカウント表示
//タブ未読数/タブ発言数 全未読数/総発言数 (未読@+未読DM数)
if (_statuses == null) return "";
- var tbRep = _statuses.GetTabByType(MyCommon.TabUsageType.Mentions);
- var tbDm = _statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage);
+ var tbRep = _statuses.MentionTab;
+ var tbDm = _statuses.DirectMessageTab;
if (tbRep == null || tbDm == null) return "";
var urat = tbRep.UnreadCount + tbDm.UnreadCount;
var ur = 0;
UnreadCounter = ur;
UnreadAtCounter = urat;
- var homeTab = this._statuses.GetTabByType<HomeTabModel>();
+ var homeTab = this._statuses.HomeTab;
slbl.AppendFormat(Properties.Resources.SetStatusLabelText1, tur, tal, ur, al, urat, _postTimestamps.Count, _favTimestamps.Count, homeTab.TweetsPerHour);
if (SettingManager.Common.TimelinePeriod == 0)
}
else
{
- var endpointName = (e as TwitterApiStatus.AccessLimitUpdatedEventArgs).EndpointName;
+ var endpointName = ((TwitterApiStatus.AccessLimitUpdatedEventArgs)e).EndpointName;
SetApiStatusLabel(endpointName);
}
}
}
}
- private void SetApiStatusLabel(string endpointName = null)
+ private void SetApiStatusLabel(string? endpointName = null)
{
var tabType = this.CurrentTab.TabType;
private async Task doRepliedStatusOpen()
{
var currentPost = this.CurrentPost;
- if (this.ExistCurrentPost && currentPost.InReplyToUser != null && currentPost.InReplyToStatusId != null)
+ if (this.ExistCurrentPost && currentPost != null && currentPost.InReplyToUser != null && currentPost.InReplyToStatusId != null)
{
if (MyCommon.IsKeyDown(Keys.Shift))
{
await this.OpenUriInBrowserAsync(MyCommon.GetStatusUrl(currentPost.InReplyToUser, currentPost.InReplyToStatusId.Value));
return;
}
- if (_statuses.ContainsKey(currentPost.InReplyToStatusId.Value))
+ if (this._statuses.Posts.TryGetValue(currentPost.InReplyToStatusId.Value, out var repPost))
{
- var repPost = _statuses[currentPost.InReplyToStatusId.Value];
MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt.ToLocalTimeString()})" + Environment.NewLine + repPost.TextFromApi);
}
else
foreach (var tb in _statuses.GetTabsByType(MyCommon.TabUsageType.Lists | MyCommon.TabUsageType.PublicSearch))
{
if (tb == null || !tb.Contains(currentPost.InReplyToStatusId.Value)) break;
- var repPost = _statuses[currentPost.InReplyToStatusId.Value];
+ repPost = tb.Posts[currentPost.InReplyToStatusId.Value];
MessageBox.Show($"{repPost.ScreenName} / {repPost.Nickname} ({repPost.CreatedAt.ToLocalTimeString()})" + Environment.NewLine + repPost.TextFromApi);
return;
}
/// </remarks>
/// <exception cref="ArgumentException">不正なフォーマットが入力された場合</exception>
/// <exception cref="NotSupportedException">サポートされていないデータが入力された場合</exception>
- internal static (string Url, string Title) GetUrlFromDataObject(IDataObject data)
+ internal static (string Url, string? Title) GetUrlFromDataObject(IDataObject data)
{
if (data.GetDataPresent("text/x-moz-url"))
{
if (flg) LView.Invalidate(bnd);
}
- private void SelectListItem(DetailsListView LView , int[] Index, int focusedIndex, int selectionMarkIndex)
+ private void SelectListItem(DetailsListView LView , int[]? Index, int focusedIndex, int selectionMarkIndex)
{
//複数
var bnd = new Rectangle();
if (MyCommon.TwitterApiInfo.AccessLevel == TwitterApiAccessLevel.ReadWrite)
{
MessageBox.Show(Properties.Resources.ReAuthorizeText);
- SettingStripMenuItem_Click(null, null);
+ SettingStripMenuItem_Click(this.SettingStripMenuItem, EventArgs.Empty);
}
// 取得失敗の場合は再試行する
private async Task FavoritesRetweetUnofficial()
{
var post = this.CurrentPost;
- if (this.ExistCurrentPost && !post.IsDm)
+ if (this.ExistCurrentPost && post != null && !post.IsDm)
{
_DoFavRetweetFlags = true;
var favoriteTask = this.FavoriteChange(true);
private async void ApiUsageInfoMenuItem_Click(object sender, EventArgs e)
{
- TwitterApiStatus apiStatus;
+ TwitterApiStatus? apiStatus;
using (var dialog = new WaitingDialog(Properties.Resources.ApiInfo6))
{
private void doQuoteOfficial()
{
- if (this.ExistCurrentPost)
+ var post = this.CurrentPost;
+ if (this.ExistCurrentPost && post != null)
{
- var post = this.CurrentPost;
if (post.IsDm || !StatusText.Enabled)
return;
private void doReTweetUnofficial()
{
//RT @id:内容
- if (this.ExistCurrentPost)
+ var post = this.CurrentPost;
+ if (this.ExistCurrentPost && post != null)
{
- var post = this.CurrentPost;
if (post.IsDm || !StatusText.Enabled)
return;
}
else
{
+ DetailsListView? listView;
+
var tb = _statuses.RemovedTab.Pop();
- DetailsListView listView;
if (tb.TabType == MyCommon.TabUsageType.Related)
{
var relatedTab = _statuses.GetTabByType(MyCommon.TabUsageType.Related);
// StatusText.Focus();
//}
this.MarkSettingCommonModified();
- this.StatusText_TextChanged(null, null);
+ this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
}
private void HashToggleMenuItem_Click(object sender, EventArgs e)
HashTogglePullDownMenuItem.Checked = false;
}
this.MarkSettingCommonModified();
- this.StatusText_TextChanged(null, null);
+ this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
}
private void HashStripSplitButton_ButtonClick(object sender, EventArgs e)
- => this.HashToggleMenuItem_Click(null, null);
+ => this.HashToggleMenuItem_Click(this.HashToggleMenuItem, EventArgs.Empty);
public void SetPermanentHashtag(string hashtag)
{
var tab = this.CurrentTab;
var post = this.CurrentPost;
- if (tab.TabType == MyCommon.TabUsageType.DirectMessage || !this.ExistCurrentPost || post.IsDm)
+ if (tab.TabType == MyCommon.TabUsageType.DirectMessage || !this.ExistCurrentPost || post == null || post.IsDm)
{
this.FavOpMenuItem.Enabled = false;
this.UnFavOpMenuItem.Enabled = false;
{
this.RefreshPrevOpMenuItem.Enabled = false;
}
- if (!this.ExistCurrentPost || post.InReplyToStatusId == null)
+ if (!this.ExistCurrentPost || post == null || post.InReplyToStatusId == null)
{
OpenRepSourceOpMenuItem.Enabled = false;
}
{
OpenRepSourceOpMenuItem.Enabled = true;
}
- if (!this.ExistCurrentPost || string.IsNullOrEmpty(post.RetweetedBy))
+ if (!this.ExistCurrentPost || post == null || string.IsNullOrEmpty(post.RetweetedBy))
{
OpenRterHomeMenuItem.Enabled = false;
}
OpenRterHomeMenuItem.Enabled = true;
}
- if (this.ExistCurrentPost)
+ if (this.ExistCurrentPost && post != null)
{
this.DelOpMenuItem.Enabled = post.CanDeleteBy(this.tw.UserId);
}
}
private void MenuItemTab_DropDownOpening(object sender, EventArgs e)
- => this.ContextMenuTabProperty_Opening(sender, null);
+ => this.ContextMenuTabProperty_Opening(sender, null!);
public Twitter TwitterInstance
=> this.tw;
else
PublicSearchQueryMenuItem.Enabled = false;
- if (!this.ExistCurrentPost)
+ var post = this.CurrentPost;
+ if (!this.ExistCurrentPost || post == null)
{
this.CopySTOTMenuItem.Enabled = false;
this.CopyURLMenuItem.Enabled = false;
this.CopyURLMenuItem.Enabled = true;
this.CopyUserIdStripMenuItem.Enabled = true;
- var post = this.CurrentPost;
if (post.IsDm) this.CopyURLMenuItem.Enabled = false;
if (post.IsProtect) this.CopySTOTMenuItem.Enabled = false;
}
private async Task doShowUserStatus(string id, bool ShowInputDialog)
{
- TwitterUser user = null;
+ TwitterUser? user = null;
if (ShowInputDialog)
{
private async void RtCountMenuItem_Click(object sender, EventArgs e)
{
- if (!this.ExistCurrentPost)
+ var post = this.CurrentPost;
+ if (!this.ExistCurrentPost || post == null)
return;
- var post = this.CurrentPost;
var statusId = post.RetweetedId ?? post.StatusId;
TwitterStatus status;
if (ImageSelector.Visible)
{
this.MarkSettingCommonModified();
- this.StatusText_TextChanged(null, null);
+ this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
}
}
private void ImageSelector_VisibleChanged(object sender, EventArgs e)
- => this.StatusText_TextChanged(null, null);
+ => this.StatusText_TextChanged(this.StatusText, EventArgs.Empty);
/// <summary>
/// StatusTextでCtrl+Vが押下された時の処理
private void MenuItemCommand_DropDownOpening(object sender, EventArgs e)
{
var post = this.CurrentPost;
- if (this.ExistCurrentPost && !post.IsDm)
+ if (this.ExistCurrentPost && post != null && !post.IsDm)
RtCountMenuItem.Enabled = true;
else
RtCountMenuItem.Enabled = false;
private async void ShowRelatedStatusesMenuItem_Click(object sender, EventArgs e)
{
var post = this.CurrentPost;
- if (this.ExistCurrentPost && !post.IsDm)
+ if (this.ExistCurrentPost && post != null && !post.IsDm)
{
try
{
}
if (ev.Event == "unfavorite" && ev.Username.Equals(tw.Username, StringComparison.InvariantCultureIgnoreCase))
{
- var favTab = this._statuses.GetTabByType(MyCommon.TabUsageType.Favorites);
+ var favTab = this._statuses.FavoriteTab;
favTab.EnqueueRemovePost(ev.Id, setIsDeleted: false);
}
}
{
if (e.KeyCode == Keys.Space)
{
- this.JumpUnreadMenuItem_Click(null, null);
+ this.JumpUnreadMenuItem_Click(this.JumpUnreadMenuItem, EventArgs.Empty);
e.SuppressKeyPress = true;
}