feature: images of runners are placed in menu#188
Conversation
|
@VirtualKley When using dark mode in the system settings, the context menu is white, so the runner is not visible.
The following tasks are required. [STAThread]
static void Main()
{
// Terminate RunCat365 if there's any existing instance.
using var procMutex = new Mutex(true, "_RUNCAT_MUTEX", out var result);
if (!result) return;
try
{
ApplicationConfiguration.Initialize();
+ Application.SetColorMode(SystemColorMode.System);
Application.Run(new RunCat365ApplicationContext());
}
finally
{
procMutex?.ReleaseMutex();
}
}<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<Nullable>enable</Nullable>
・・・
<ApplicationManifest>App.manifest</ApplicationManifest>
+ <NoWarn>$(NoWarn);WFO5001</NoWarn>
</PropertyGroup>However, I am not sure if this method works on Windows 10. |
| 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; | ||
| } |
There was a problem hiding this comment.
Icons are not necessary for anything other than runners, so let's specialize them.
| 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 Bitmap? GetRunnerThumbnailBitmap(Runner runner) | |
| { | |
| var systemTheme = GetSystemTheme(); | |
| var iconName = $"{systemTheme.GetString()}_{runner.GetString()}_0".ToLower(); | |
| var obj = Resources.ResourceManager.GetObject(iconName); | |
| return obj is Icon icon ? icon.ToBitmap() : null; | |
| } |
| string entityName = getTitle(value); | ||
| var item = new ToolStripMenuItem(entityName, GetIconImageForMenu(entityName), onClickEvent) |
There was a problem hiding this comment.
Let's eliminate the possibility of icons other than runner-type icons being applied.
| string entityName = getTitle(value); | |
| var item = new ToolStripMenuItem(entityName, GetIconImageForMenu(entityName), onClickEvent) | |
| var entityName = getTitle(value); | |
| Image? iconImage = value is Runner runner ? GetRunnerThumbnailBitmap(runner) : null; | |
| var item = new ToolStripMenuItem(entityName, iconImage, onClickEvent) |
|
Memo for myself: |
…ght theme is used directly for the miniaturized icons in the menu.
|
Hello, I made the changes, I also left the default theme, used the light theme for the menu icons, and made the requested changes to the image method. |

Hello,
I made a change when creating the menu, now for the runner section the initial position icon is shown as a thumbnail image.
I took into account the change of removing the static in Theme and also placing the icon obtaining the default system theme. I had internal problems when doing the merge, so I pulled from another branch. I will stay tuned for updates.
Best regards,