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

Icons is not always shown. #65

Closed
dubstab96 opened this issue Apr 7, 2021 · 15 comments
Closed

Icons is not always shown. #65

dubstab96 opened this issue Apr 7, 2021 · 15 comments
Labels

Comments

@dubstab96
Copy link

I have a WinForms application that i am building with C# and sometimes the icons is not showing at all. After an app restart maybe they will.

@mkoertgen
Copy link
Member

Hi @dubstab96 ,

Thanks for reaching out. Can you provide some more context, e.g. what specific icons and with what controls you use them?

@dubstab96
Copy link
Author

dubstab96 commented Apr 8, 2021

Im using mostly IconButton and IconPictureBox in my application. Sometimes there are no icons showing, sometimes some shows and some others not and sometimes everything works just fine.
Here are some screenshots of different runs.

Successfull run:
image

Not successfull run:
image

I don't know if this is kind of VStudio Debugger problem, seems to happens on builded app also.
I might have to mention that i also use MaterialSkin controls (https://github.com/IgnaceMaes/MaterialSkin) and in one on thousands an exeption will occur on startup, stating that "Roboto" font does not support style "Regular".

@mkoertgen
Copy link
Member

Looks cool! There were some recent fixes regarding WinForms font selection, e.g. by explicitly setting the FontStyle, cf.:

Not sure what NuGet-version you are using.

@dubstab96
Copy link
Author

Im using FontAwesome.Sharp version 5.15.3
Seems to be the latest.

@mkoertgen
Copy link
Member

Ok, did you tree setting the FontStyle explicitly?

@dubstab96
Copy link
Author

Yes, just found out that it was set to Auto. I will set every control with the right IconFont and i will let you know if the problem is solved :)
Thank you very much

@dubstab96
Copy link
Author

After setting the IconFont property of some of the controls an ArgumentNullExeption was thrown
image

Again this exeption is not thrown every time application start. After two retries the app started just fine.

@mkoertgen
Copy link
Member

Ok, this looks like a problem with initialization order, i.e. fonts are not yet fully loaded.
The IconFont-setter should be this line, cf.:

Could you provide the whole stack-trace here?

@mkoertgen mkoertgen added the bug label Apr 8, 2021
@dubstab96
Copy link
Author

i'm not sure if this is what you need.
System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. Parameter name: family Source=System.Drawing StackTrace: at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) at System.Drawing.Font..ctor(FontFamily family, Single emSize, GraphicsUnit unit) at FontAwesome.Sharp.FormsIconHelper.GetAdjustedIconFont(Graphics g, FontFamily fontFamily, String text, SizeF size, Int32 maxFontSize, Int32 minFontSize, Boolean smallestOnFail) at FontAwesome.Sharp.FormsIconHelper.ToBitmap[TEnum](FontFamily fontFamily, TEnum icon, Int32 width, Int32 height, Nullable1 color, Double rotation, FlipOrientation flip)
at FontAwesome.Sharp.IconButton`1.UpdateImage()
at FontAwesome.Sharp.IconButton.set_IconFont(IconFont value)
at RPA_Client.Forms.Assistant.InitializeComponent() in C:\Users\badil\Documents\Visual Studio 2019\Projects\RPA_Client\RPA_Client\Forms\Assistant.Designer.cs:line 95
at RPA_Client.Forms.Assistant..ctor() in C:\Users\badil\Documents\Visual Studio 2019\Projects\RPA_Client\RPA_Client\Forms\Assistant.cs:line 30
at RPA_Client.LoginForm.LoggedIn(Object sender, EventArgs e) in C:\Users\badil\Documents\Visual Studio 2019\Projects\RPA_Client\RPA_Client\Forms\LoginForm.cs:line 64
at RPA_Client.Api.d__46.MoveNext() in C:\Users\badil\Documents\Visual Studio 2019\Projects\RPA_Client\RPA_Client\Models\Api.cs:line 77

This exception was originally thrown at this call stack:
[External Code]
RPA_Client.Forms.Assistant.InitializeComponent() in Assistant.Designer.cs
RPA_Client.Forms.Assistant.Assistant() in Assistant.cs
RPA_Client.LoginForm.LoggedIn(object, System.EventArgs) in LoginForm.cs
RPA_Client.Api.Login(RPA_Client.Models.LoginUserCredentials) in Api.cs`

@mkoertgen
Copy link
Member

Looks like this line here, cf.:

Yes, this should help.

Just for completeness: Which .NET/Core- and OS-version are you using?

Will also check for possible side-effects with https://github.com/IgnaceMaes/MaterialSkin

Not sure when i can promise you feedback on this.

Would you be able or willing to submit a pull request?

@dubstab96
Copy link
Author

I am using .NET Version 4.8.04084
Windows 10 build 19042.867

I am sorry but this project is taking the 110% out of me. Maybe some time in the future :)

Thank you for your help,
Always happy to hear from you.

@mkoertgen
Copy link
Member

Ok, no problem. Target system is the same i guess, i.e Win10, net48?

@dubstab96
Copy link
Author

Yes,
I tried to remove completely every reference of the MaterialSkin and after two whole days, no problem occured.
Everything works just fine.
Seems that there are side effects when MaterialSkin and Fontawesome.Sharp is loaded

@mkoertgen
Copy link
Member

Hi @dubstab96, ok for you to close the issue then?

@dubstab96
Copy link
Author

Of course. Thank you very much for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants