MaterialSkin icon indicating copy to clipboard operation
MaterialSkin copied to clipboard

Drawer not showing icons after inserting new tab at runtime

Open onlytropics opened this issue 3 years ago • 2 comments
trafficstars

I am using the drawer with the flag ShowIconsWhenHidden set (although that shouldn't make a difference really). After the user did some input, a new Tab is created at runtime and inserted after the currently active tab. At this point, the currently active Tab and all the following ones do not display their icons anymore.

Looked at the source code and found the private method preProcessIcons, which I guessed had something to do with it. It is called when ShowIconsWhenHidden is modified so I tried

f.DrawerShowIconsWhenHidden = false;
f.DrawerShowIconsWhenHidden = true;

after inserting the new tab and it definitely helps. Now only the current tab and the new tab's icons are missing.

I had to change MaterialDrawer.cs lines 288-290 to

iconsBrushes[tabPage.ImageKey] = textureBrushGray;
iconsSelectedBrushes[tabPage.ImageKey] = textureBrushColor;
iconsSize[tabPage.ImageKey] = new Rectangle(0, 0, iconRect.Width, iconRect.Height);

as the Add() which was there previously throws an Exception if the key already exists, essentially making calling preProcessIcons more than once impossible.

It also seems that the tabs can't share icons? It seems if I set more than one tab to the same Icon ID, they are not displayed.

onlytropics avatar Aug 16 '22 12:08 onlytropics

#368 will allow you to set the same icon on multiple tab pages, because it adds the icon from the iconlist in the dictionary by concatenate the ImageKey with TabPage's name.

I hope @orapps44 to merge it.

Edit: I suggest (as @leocb said) to use something else for WinForms, or to switch to WPF or something else, as long as this project I don't think it will be maintained anymore. 😌

valimaties avatar Sep 12 '22 11:09 valimaties

I yolo merged it. Not sure when another version will be uploaded to nuget, but feel free to compile it and use it yourself

leocb avatar Sep 12 '22 13:09 leocb