// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.ComponentModel;
{
public partial class EventViewerDialog : OTBaseForm
{
- public List<Twitter.FormattedEvent> EventSource { get; set; }
+ public List<Twitter.FormattedEvent> EventSource { get; set; } = new List<Twitter.FormattedEvent>();
- private Twitter.FormattedEvent[] _filterdEventSource;
+ private Twitter.FormattedEvent[] _filterdEventSource = Array.Empty<Twitter.FormattedEvent>();
- private ListViewItem[] _ItemCache = null;
+ private ListViewItem[]? _ItemCache = null;
private int _itemCacheIndex;
- private TabPage _curTab = null;
+ private TabPage _curTab = null!;
public EventViewerDialog()
{
}
private MyCommon.EVENTTYPE ParseEventTypeFromTag()
- {
- return (MyCommon.EVENTTYPE)Enum.Parse(typeof(MyCommon.EVENTTYPE), _curTab.Tag.ToString());
- }
+ => (MyCommon.EVENTTYPE)Enum.Parse(typeof(MyCommon.EVENTTYPE), _curTab.Tag.ToString());
private bool IsFilterMatch(Twitter.FormattedEvent x)
{
{
try
{
- Regex rx = new Regex(TextBoxKeyword.Text);
+ var rx = new Regex(TextBoxKeyword.Text);
return rx.Match(x.Username).Success || rx.Match(x.Target).Success;
}
catch (Exception ex)
}
private void CheckExcludeMyEvent_CheckedChanged(object sender, EventArgs e)
- {
- CreateFilterdEventSource();
- }
+ => this.CreateFilterdEventSource();
private void ButtonRefresh_Click(object sender, EventArgs e)
- {
- CreateFilterdEventSource();
- }
+ => this.CreateFilterdEventSource();
private void TabEventType_SelectedIndexChanged(object sender, EventArgs e)
- {
- CreateFilterdEventSource();
- }
+ => this.CreateFilterdEventSource();
private void TabEventType_Selecting(object sender, TabControlCancelEventArgs e)
{
}
private void EventList_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e)
- {
- CreateCache(e.StartIndex, e.EndIndex);
- }
+ => this.CreateCache(e.StartIndex, e.EndIndex);
private void CreateCache(int StartIndex, int EndIndex)
{
_ItemCache = new ListViewItem[] { };
Array.Resize(ref _ItemCache, EndIndex - StartIndex + 1);
_itemCacheIndex = StartIndex;
- for (int i = 0; i < _ItemCache.Length; i++)
+ for (var i = 0; i < _ItemCache.Length; i++)
{
_ItemCache[i] = CreateListViewItem(_filterdEventSource[StartIndex + i]);
}
private void SaveLogButton_Click(object sender, EventArgs e)
{
- DialogResult rslt = MessageBox.Show(string.Format(Properties.Resources.SaveLogMenuItem_ClickText5, Environment.NewLine),
+ var rslt = MessageBox.Show(string.Format(Properties.Resources.SaveLogMenuItem_ClickText5, Environment.NewLine),
Properties.Resources.SaveLogMenuItem_ClickText2,
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
switch (rslt)
{
case DialogResult.Yes:
- SaveFileDialog1.FileName = $"{MyCommon.GetAssemblyName()}Events{_curTab.Tag}{DateTimeUtc.Now.ToLocalTime():yyMMdd-HHmmss}.tsv";
+ SaveFileDialog1.FileName = $"{ApplicationSettings.AssemblyName}Events{_curTab.Tag}{DateTimeUtc.Now.ToLocalTime():yyMMdd-HHmmss}.tsv";
break;
case DialogResult.No:
- SaveFileDialog1.FileName = $"{MyCommon.GetAssemblyName()}Events{DateTimeUtc.Now.ToLocalTime():yyMMdd-HHmmss}.tsv";
+ SaveFileDialog1.FileName = $"{ApplicationSettings.AssemblyName}Events{DateTimeUtc.Now.ToLocalTime():yyMMdd-HHmmss}.tsv";
break;
default:
return;
if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
{
if (!SaveFileDialog1.ValidateNames) return;
- using (StreamWriter sw = new StreamWriter(SaveFileDialog1.FileName, false, Encoding.UTF8))
+ using var sw = new StreamWriter(SaveFileDialog1.FileName, false, Encoding.UTF8);
+
+ switch (rslt)
{
- switch (rslt)
- {
- case DialogResult.Yes:
- SaveEventLog(_filterdEventSource.ToList(), sw);
- break;
- case DialogResult.No:
- SaveEventLog(EventSource, sw);
- break;
- default:
- //
- break;
- }
+ case DialogResult.Yes:
+ SaveEventLog(_filterdEventSource.ToList(), sw);
+ break;
+ case DialogResult.No:
+ SaveEventLog(EventSource, sw);
+ break;
+ default:
+ break;
}
}
this.TopMost = SettingManager.Common.AlwaysTop;
private void SaveEventLog(List<Twitter.FormattedEvent> source, StreamWriter sw)
{
- foreach (Twitter.FormattedEvent _event in source)
+ foreach (var _event in source)
{
sw.WriteLine(_event.Eventtype + "\t" +
"\"" + _event.CreatedAt.ToLocalTimeString() + "\"\t" +
.Where(e => e != "None" && e != "All")
.Select(e => new TabPage(e)
{
- // Name = "TabPage" + e,
Tag = e,
UseVisualStyleBackColor = true,
AccessibleRole = AccessibleRole.PageTab,