# LunaWin LunaWin is a small systray utility displaying the current moon phase. It's written in .NET C# using WinForms. The actual lunar phase calculation credit goes to [this blog post](https://minkukel.com/en/various/calculating-moon-phase/) *([archive](https://archive.ph/hjXlv))*, which details the rationale behind the calculations and presents a PHP implementation. This project demonstrates a number of concepts, some more advanced than others. **Introductory** * Programmatically creating and updating a system tray icon using [`NotifyIcon`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.notifyicon?view=windowsdesktop-8.0) * Programmatically creating and updating the icon's context menu using [`ContextMenuStrip`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.contextmenustrip?view=windowsdesktop-8.0) and [`ToolStripMenuItem`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.toolstripmenuitem?view=windowsdesktop-8.0) * Setting a program to run at user login (startup) **Advanced** * Using [`Mutex`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.mutex?view=netframework-4.7.2) to find existing instance of application * Using [`DllImport`](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?view=netframework-4.7.2) to access the current Windows 10+ theme (light or dark) natively * Overloading [`WndProc`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.wndproc?view=windowsdesktop-8.0) to handle system-wide messaging, to detect Windows 10+ theme changes * Accessing memory directly through pointers and [`unsafe`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/unsafe) code handling