Repository: Kyome22/RunCat_for_windows
File: RunCat365/Program.cs (C#)

Code before:

        private static Image? GetIconImageForMenu(string title)
        {
            Theme systemTheme = GetSystemTheme();
            string prefix = systemTheme.GetString();
            string iconName = $"{prefix}_{title}_0".ToLower();
            var obj = Resources.ResourceManager.GetObject(iconName);
            return obj switch
            {
                Icon icon => icon.ToBitmap(),
                _ => null
            } ?? null;
        }

        private static ToolStripMenuItem CreateMenuFromEnum<T>(
            string title,
            Func<T, string> getTitle,
            EventHandler onClickEvent,
            Func<T, bool> isChecked
        ) where T : Enum
        {
            var items = new List<ToolStripMenuItem>();
            foreach (T value in Enum.GetValues(typeof(T)))
            {
                string entityName = getTitle(value);
                var item = new ToolStripMenuItem(entityName, GetIconImageForMenu(entityName), onClickEvent)
                {
                    Checked = isChecked(value) 
                };
                items.Add(item);
            }
            return new ToolStripMenuItem(title, null, [.. items]);
        }

        private void OnApplicationExit(object? sender, EventArgs e)
        {
            UserSettings.Default.Runner = runner.ToString();
            UserSettings.Default.Theme = manualTheme.ToString();
            UserSettings.Default.FPSMaxLimit = fpsMaxLimit.ToString();
            UserSettings.Default.Save();
        }

        private static bool IsStartupEnabled()
        {
            var keyName = @"Software\Microsoft\Windows\CurrentVersion\Run";
            using var rKey = Registry.CurrentUser.OpenSubKey(keyName);
            if (rKey is null) return false;
            var value = (rKey.GetValue(Application.ProductName) is not null);
            rKey.Close();
            return value;
        }

Review comment (suggestion):
Let's eliminate the possibility of icons other than runner-type icons being applied.

```suggestion
                var entityName = getTitle(value);
                Image? iconImage = value is Runner runner ? GetRunnerThumbnailBitmap(runner) : null;
                var item = new ToolStripMenuItem(entityName, iconImage, onClickEvent)
```

Code after:

        private static Bitmap? GetRunnerThumbnailBitmap(Runner runner)
        {
            var iconName = $"{Theme.Light.GetString()}_{runner.GetString()}_0".ToLower();
            var obj = Resources.ResourceManager.GetObject(iconName);
            return obj is Icon icon ? icon.ToBitmap() : null;
        }

        private static ToolStripMenuItem CreateMenuFromEnum<T>(
            string title,
            Func<T, string> getTitle,
            EventHandler onClickEvent,
            Func<T, bool> isChecked
        ) where T : Enum
        {
            var items = new List<ToolStripMenuItem>();
            foreach (T value in Enum.GetValues(typeof(T)))
            {
                string entityName = getTitle(value);
                Image? iconImage = value is Runner runner ? GetRunnerThumbnailBitmap(runner) : null;
                var item = new ToolStripMenuItem(entityName, iconImage, onClickEvent)
                {
                    Checked = isChecked(value) 
                };
                items.Add(item);
            }
            return new ToolStripMenuItem(title, null, [.. items]);
        }

        private void OnApplicationExit(object? sender, EventArgs e)
        {
            UserSettings.Default.Runner = runner.ToString();
            UserSettings.Default.Theme = manualTheme.ToString();
            UserSettings.Default.FPSMaxLimit = fpsMaxLimit.ToString();
            UserSettings.Default.Save();
        }

        private static bool IsStartupEnabled()
        {
            var keyName = @"Software\Microsoft\Windows\CurrentVersion\Run";
            using var rKey = Registry.CurrentUser.OpenSubKey(keyName);
            if (rKey is null) return false;
            var value = (rKey.GetValue(Application.ProductName) is not null);
            rKey.Close();
            return value;
        }

        private static Theme GetSystemTheme()
        {
            var keyName = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
            using var rKey = Registry.CurrentUser.OpenSubKey(keyName);