Skip to content

feature: images of runners are placed in menu#188

Merged
Kyome22 merged 2 commits into
runcat-dev:mainfrom
VirtualKley:feature-icon-menu-runner-selection
Jul 24, 2025
Merged

feature: images of runners are placed in menu#188
Kyome22 merged 2 commits into
runcat-dev:mainfrom
VirtualKley:feature-icon-menu-runner-selection

Conversation

@VirtualKley
Copy link
Copy Markdown
Contributor

Hello,

I made a change when creating the menu, now for the runner section the initial position icon is shown as a thumbnail image.

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,

@Kyome22
Copy link
Copy Markdown
Collaborator

Kyome22 commented Jul 23, 2025

@VirtualKley When using dark mode in the system settings, the context menu is white, so the runner is not visible.

Screenshot (35)

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.

Comment thread RunCat365/Program.cs Outdated
Comment on lines +149 to +160
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;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icons are not necessary for anything other than runners, so let's specialize them.

Suggested change
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;
}

Comment thread RunCat365/Program.cs Outdated
Comment on lines +172 to +173
string entityName = getTitle(value);
var item = new ToolStripMenuItem(entityName, GetIconImageForMenu(entityName), onClickEvent)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's eliminate the possibility of icons other than runner-type icons being applied.

Suggested change
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)

@Kyome22
Copy link
Copy Markdown
Collaborator

Kyome22 commented Jul 23, 2025

Memo for myself:
Separate from the scope of the pull request, I found several places where var could be used with type inference, so I will deal with those separately.

…ght theme is used directly for the miniaturized icons in the menu.
@VirtualKley
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Collaborator

@Kyome22 Kyome22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Kyome22 Kyome22 merged commit d27829c into runcat-dev:main Jul 24, 2025
@VirtualKley VirtualKley deleted the feature-icon-menu-runner-selection branch July 27, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants