NotifyIcon does not use the appropriate icon size
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 1d 13m
- Merged PRs (30d)
- 85
Description
### .NET version
6.0
### Did it work in .NET Framework?
No
### Did it work in any of the earlier releases of .NET Core or .NET 5+?
_No response_
### Issue description
There is a [long-known issue](https://www.hhhh.org/cloister/csharp/icons/) that `NotifyIcon` does not use the proper icon size. Rather than using the small icon size, it takes whatever size the `System.Drawing.Icon` has been constructed for (usually the default icon size), which Windows then scales down to the small icon size.
There is a work-around:
```
_notifyIcon.Icon = new Icon(_notifyIcon.Icon, SystemInformation.SmallIconSize);
```
`NotifyIcon` should do this itself.
### Steps to reproduce
1. Create a new WinForms project, name it "NotifyIconBug".
2. Add a resource file and name it `Resource1.resx`.
3. Add an icon with sizes of 16x16 and 32x32 to the `Resource1.resx` and name it `application_icon`. Use images for the two sizes of the icon that are distinguishable from one another.
3. Add a `NotifyIcon` to `Form1` and name it `notifyIcon1`.
4. Set the `Icon` property of the `NotifyIcon` to the icon: `notifyIcon1.Icon = Resource1.application_icon;`
5. Run the project, having the notification area on a low-DPI display. The 32x32 size of the icon is displayed scaled down to 16x16 rather than displaying the 16x16 size.
I'd guess you could also recreate this on a high-DPI display as well if you scale up the above sizes accordingly.
Contributor guide
Assessment
This issue has not been assessed yet.