Skip to content

Commit

Permalink
fix warnings of build
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Feb 28, 2024
1 parent 0348792 commit 8bc8263
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
36 changes: 19 additions & 17 deletions src/Nager.WindowsCalendarWeek/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ namespace Nager.WindowsCalendarWeek;

static class Program
{
private static System.Windows.Forms.Timer RefreshIconTimer;
private static NotifyIcon CalendarWeekNotifyIcon;
private static int OneDayMilliseconds = 86400000;
private static readonly System.Windows.Forms.Timer RefreshIconTimer;
private static readonly NotifyIcon CalendarWeekNotifyIcon;
private static readonly int OneDayMilliseconds = 86400000;

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static Program()
{
var firstRefreshInterval = (int)(OneDayMilliseconds - Math.Floor(DateTime.Now.TimeOfDay.TotalMilliseconds));

Expand All @@ -38,40 +34,46 @@ static void Main()
},
Visible = true
};
}

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{


CalendarWeekNotifyIcon.MouseClick += TrayIcon_Click;

Application.Run();
}

private static void RefreshIconTimer_Tick(object sender, EventArgs e)
private static void RefreshIconTimer_Tick(object? sender, EventArgs e)
{
RefreshIconTimer.Interval = OneDayMilliseconds;

var oldIcon = CalendarWeekNotifyIcon.Icon;
if (oldIcon != null)
{
oldIcon.Dispose();
}
oldIcon?.Dispose();

var bmp = GetBitmapOfCurrentCalendarWeek();
CalendarWeekNotifyIcon.Icon = Icon.FromHandle(bmp.GetHicon());
}

private static void TrayIcon_Click(object sender, MouseEventArgs e)
private static void TrayIcon_Click(object? sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
OpenOnlineCalendar();
}
}

private static void OnlineCalendarItemClickEvent(object sender, EventArgs e)
private static void OnlineCalendarItemClickEvent(object? sender, EventArgs e)
{
OpenOnlineCalendar();
}

private static void HolidayItemClickEvent(object sender, EventArgs e)
private static void HolidayItemClickEvent(object? sender, EventArgs e)
{
OpenHoliday();
}
Expand Down Expand Up @@ -136,7 +138,7 @@ private static int GetWeekNumber()
return CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
}

private static void QuitItemClickEvent(object sender, EventArgs e)
private static void QuitItemClickEvent(object? sender, EventArgs e)
{
Application.Exit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Nager.WindowsCalendarWeekNet4/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static class Program
{
private static Timer RefreshIconTimer;
private static NotifyIcon CalendarWeekNotifyIcon;
private static int OneDayMilliseconds = 86400000;
private static readonly int OneDayMilliseconds = 86400000;

/// <summary>
/// The main entry point for the application.
Expand Down

0 comments on commit 8bc8263

Please sign in to comment.