Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer not showing icons after inserting new tab at runtime #364

Open
onlytropics opened this issue Aug 16, 2022 · 2 comments
Open

Drawer not showing icons after inserting new tab at runtime #364

onlytropics opened this issue Aug 16, 2022 · 2 comments

Comments

@onlytropics
Copy link

onlytropics commented Aug 16, 2022

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.

@valimaties
Copy link

valimaties commented Sep 12, 2022

#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. 😌

@leocb
Copy link
Owner

leocb commented Sep 12, 2022

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

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

No branches or pull requests

3 participants