Skip to content

Commit 8bc8263

Browse files
committed
fix warnings of build
1 parent 0348792 commit 8bc8263

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/Nager.WindowsCalendarWeek/Program.cs

+19-17
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ namespace Nager.WindowsCalendarWeek;
55

66
static class Program
77
{
8-
private static System.Windows.Forms.Timer RefreshIconTimer;
9-
private static NotifyIcon CalendarWeekNotifyIcon;
10-
private static int OneDayMilliseconds = 86400000;
8+
private static readonly System.Windows.Forms.Timer RefreshIconTimer;
9+
private static readonly NotifyIcon CalendarWeekNotifyIcon;
10+
private static readonly int OneDayMilliseconds = 86400000;
1111

12-
/// <summary>
13-
/// The main entry point for the application.
14-
/// </summary>
15-
[STAThread]
16-
static void Main()
12+
static Program()
1713
{
1814
var firstRefreshInterval = (int)(OneDayMilliseconds - Math.Floor(DateTime.Now.TimeOfDay.TotalMilliseconds));
1915

@@ -38,40 +34,46 @@ static void Main()
3834
},
3935
Visible = true
4036
};
37+
}
38+
39+
/// <summary>
40+
/// The main entry point for the application.
41+
/// </summary>
42+
[STAThread]
43+
static void Main()
44+
{
45+
4146

4247
CalendarWeekNotifyIcon.MouseClick += TrayIcon_Click;
4348

4449
Application.Run();
4550
}
4651

47-
private static void RefreshIconTimer_Tick(object sender, EventArgs e)
52+
private static void RefreshIconTimer_Tick(object? sender, EventArgs e)
4853
{
4954
RefreshIconTimer.Interval = OneDayMilliseconds;
5055

5156
var oldIcon = CalendarWeekNotifyIcon.Icon;
52-
if (oldIcon != null)
53-
{
54-
oldIcon.Dispose();
55-
}
57+
oldIcon?.Dispose();
5658

5759
var bmp = GetBitmapOfCurrentCalendarWeek();
5860
CalendarWeekNotifyIcon.Icon = Icon.FromHandle(bmp.GetHicon());
5961
}
6062

61-
private static void TrayIcon_Click(object sender, MouseEventArgs e)
63+
private static void TrayIcon_Click(object? sender, MouseEventArgs e)
6264
{
6365
if (e.Button == MouseButtons.Left)
6466
{
6567
OpenOnlineCalendar();
6668
}
6769
}
6870

69-
private static void OnlineCalendarItemClickEvent(object sender, EventArgs e)
71+
private static void OnlineCalendarItemClickEvent(object? sender, EventArgs e)
7072
{
7173
OpenOnlineCalendar();
7274
}
7375

74-
private static void HolidayItemClickEvent(object sender, EventArgs e)
76+
private static void HolidayItemClickEvent(object? sender, EventArgs e)
7577
{
7678
OpenHoliday();
7779
}
@@ -136,7 +138,7 @@ private static int GetWeekNumber()
136138
return CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
137139
}
138140

139-
private static void QuitItemClickEvent(object sender, EventArgs e)
141+
private static void QuitItemClickEvent(object? sender, EventArgs e)
140142
{
141143
Application.Exit();
142144
}

src/Nager.WindowsCalendarWeekNet4/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static class Program
1010
{
1111
private static Timer RefreshIconTimer;
1212
private static NotifyIcon CalendarWeekNotifyIcon;
13-
private static int OneDayMilliseconds = 86400000;
13+
private static readonly int OneDayMilliseconds = 86400000;
1414

1515
/// <summary>
1616
/// The main entry point for the application.

0 commit comments

Comments
 (0)