I have just uploaded a new complete refactoring of the Icon Bank for Winforms. In this refactoring, I use advanced features of both Winforms and .NET9
The libraries are named like this:
Rop.winforms9.DuotoneIcons.xxx
Where xxx represent the Icon Bank that it contains.
At the moment there are only two Icon Banks available:
- Rop.Winforms9.DuotoneIcons.MaterialDesign
- Rop.Winforms9.DuotoneIcons.GoogleMaterial
Both banks are duotone icons. Although in the case of the Material Design bank they can also be used as single color.
The icons in the library are loaded into an IEmbeddedIcons structure.
Thy can be accessed programmatically using the IconRepository class as follows:
IEmbeddedIcons myicons=IconRepository.GetEmbeddedIcons<MaterialDesignIcons>();
The IEmbeddedIcons structure is defined as:
public interface IEmbeddedIcons
{
string FontName { get; }
IReadOnlyList<string> Codes { get; }
IReadOnlyList<string> Aliases { get; }
Size BaseSize { get; }
int Count { get; }
DuoToneIcon? GetIcon(string name);
float DrawIcon(Graphics gr, string code, DuoToneColor iconcolor, float x, float y, float height);
float DrawIconBaseLine(Graphics gr, string code, DuoToneColor iconcolor, float x, float baseline, float height);
void DrawIconFit(Graphics gr, string code, DuoToneColor iconcolor, float x, float y, float width);
}
Icons can be drawn directly using 3 procedures:
- DrawIcon() which draws an icon at position x, y with the size defined by its height.
- DrawIconBaseLine() which draws an icon at position x, baseline with the size defined by its height.
- DrawIconFit() which draws an icon at position x, y with a size adjusted to a grid width x width.
In addition to the direct drawing of icons, several controls are included:
- IconLabel: This is a label control that includes an icon and a text.
- SoloIconLabel: This is a label control that only includes an icon.
- IconBoolLabel: This is a label control that displays an icon and a different text in different colors based on a boolean value.
- SoloIconBoolLabel: This is a label control that displays a different icon in different colors based on a boolean value.
- IconIndexLabel: This is a label control that displays a different icon and text based on an integer value.
- SoloIconIndexLabel: This is a label control that displays a different icon based on an integer value.
- IconButton: This is a button that includes an icon and text.
- SoloIconButton: This is a button that only includes an icon.
- IconBoolButton: This is a button that displays a different icon and text in different colors based on a boolean value.
- SoloIconBoolButton: This is a button that displays a different icon in different colors based on a boolean value.
- IconIndexButton: This is a button that displays a different icon and text based on an integer value.
- SoloIconIndexButton: This is a button that displays a different icon based on an integer value.
- SwitchIcon: This is a modern switch control.
- ColumnPanel: This is a column panel to indicate the ordering of a list.
Github Repository
In addition to the ready-to-use Nuget libraries, in the Github Repository corresponding to this icon bank suite, there is an Icon Browser, which is used to quickly locate the available icons and a Builder that allows you to create or increase the icon banks currently available.
Along with these two utilities… an example of use and employment of “Partial Controls” to generate new controls based on AOP (Aspect Oriented Programming)
If anyone is interested in the changes in Winforms application programming in .NET9, in future posts I will indicate how to modernize the creation of custom controls in Winforms according to the new possibilities of .NET9.
Remain listening…
This article was also published via Medium
Top comments (0)