@@ -5,15 +5,11 @@ namespace Nager.WindowsCalendarWeek;
5
5
6
6
static class Program
7
7
{
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 ;
11
11
12
- /// <summary>
13
- /// The main entry point for the application.
14
- /// </summary>
15
- [ STAThread ]
16
- static void Main ( )
12
+ static Program ( )
17
13
{
18
14
var firstRefreshInterval = ( int ) ( OneDayMilliseconds - Math . Floor ( DateTime . Now . TimeOfDay . TotalMilliseconds ) ) ;
19
15
@@ -38,40 +34,46 @@ static void Main()
38
34
} ,
39
35
Visible = true
40
36
} ;
37
+ }
38
+
39
+ /// <summary>
40
+ /// The main entry point for the application.
41
+ /// </summary>
42
+ [ STAThread ]
43
+ static void Main ( )
44
+ {
45
+
41
46
42
47
CalendarWeekNotifyIcon . MouseClick += TrayIcon_Click ;
43
48
44
49
Application . Run ( ) ;
45
50
}
46
51
47
- private static void RefreshIconTimer_Tick ( object sender , EventArgs e )
52
+ private static void RefreshIconTimer_Tick ( object ? sender , EventArgs e )
48
53
{
49
54
RefreshIconTimer . Interval = OneDayMilliseconds ;
50
55
51
56
var oldIcon = CalendarWeekNotifyIcon . Icon ;
52
- if ( oldIcon != null )
53
- {
54
- oldIcon . Dispose ( ) ;
55
- }
57
+ oldIcon ? . Dispose ( ) ;
56
58
57
59
var bmp = GetBitmapOfCurrentCalendarWeek ( ) ;
58
60
CalendarWeekNotifyIcon . Icon = Icon . FromHandle ( bmp . GetHicon ( ) ) ;
59
61
}
60
62
61
- private static void TrayIcon_Click ( object sender , MouseEventArgs e )
63
+ private static void TrayIcon_Click ( object ? sender , MouseEventArgs e )
62
64
{
63
65
if ( e . Button == MouseButtons . Left )
64
66
{
65
67
OpenOnlineCalendar ( ) ;
66
68
}
67
69
}
68
70
69
- private static void OnlineCalendarItemClickEvent ( object sender , EventArgs e )
71
+ private static void OnlineCalendarItemClickEvent ( object ? sender , EventArgs e )
70
72
{
71
73
OpenOnlineCalendar ( ) ;
72
74
}
73
75
74
- private static void HolidayItemClickEvent ( object sender , EventArgs e )
76
+ private static void HolidayItemClickEvent ( object ? sender , EventArgs e )
75
77
{
76
78
OpenHoliday ( ) ;
77
79
}
@@ -136,7 +138,7 @@ private static int GetWeekNumber()
136
138
return CultureInfo . CurrentCulture . Calendar . GetWeekOfYear ( DateTime . Now , CalendarWeekRule . FirstFourDayWeek , DayOfWeek . Monday ) ;
137
139
}
138
140
139
- private static void QuitItemClickEvent ( object sender , EventArgs e )
141
+ private static void QuitItemClickEvent ( object ? sender , EventArgs e )
140
142
{
141
143
Application . Exit ( ) ;
142
144
}
0 commit comments