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

Allow IconSource to be a concrete BitmapSource #71

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

tmr0861
Copy link

@tmr0861 tmr0861 commented Nov 25, 2021

By adding a BitmapSource.ToIcon extension method to util.cs, along a check in ImageSource.ToIcon to look for the concrete type and call said method, the IconSource can be bound to a concrete BitmapSource type. This allows for dynamic drawing of the icon image by my application.

There may be better ways to do this, but this seemed pretty simple.

hardcodet and others added 2 commits April 22, 2021 13:22
Long-overdue contributor recognition.
…ce.ToIcon to look for the concrete type and call the method
@Lakritzator
Copy link
Collaborator

Thank you for your interest in the repository, and for your contribution.

The limited possibilities for defining an icon definitively need some love, in fact I already talked about this for ages here, but also in #24 this is seen. I already prepared some work, last April, but somehow didn't get to it yet.

It's not rocket science, but I do not think it's "pretty simple", for instance your PR would cause memory leaks as you forget to dispose the bitmap created here.

Also it might not be the most performant solution, so I like to propose I come up with a more flexible and better solution.
I might step up my efforts, but it depends on how much time I can free up.

@Lakritzator
Copy link
Collaborator

I even forgot to mention the hbitmap leak...

@tmr0861
Copy link
Author

tmr0861 commented Dec 4, 2021

Thank you for your interest in the repository, and for your contribution.

The limited possibilities for defining an icon definitively need some love, in fact I already talked about this for ages here, but also in #24 this is seen. I already prepared some work, last April, but somehow didn't get to it yet.

It's not rocket science, but I do not think it's "pretty simple", for instance your PR would cause memory leaks as you forget to dispose the bitmap created here.

Also it might not be the most performant solution, so I like to propose I come up with a more flexible and better solution. I might step up my efforts, but it depends on how much time I can free up.

Thanks for considering the request. I look forward to seeing this done the right way so I can learn more. Thanks again!

@maxpavlov
Copy link

Until this PR is reviewed, finalized, and merged, the only way of adding an icon for the Notification area (basically the main product driver behind this library), is via embedded application resources. This is casting users unable to dynamically generate and use icons. This might seem like a non-common case, but the limitation is rather artificial and comes only from the following line of code in the current master branch:

Utils.cs, Line 174:

StreamResourceInfo streamInfo = Application.GetResourceStream(uri);

This GetResourceStream makes sure only icons embedded as Resources could be used.

I would love this PR to be merged as with it, any BitmapImage could be supplied.

@Lakritzator Lakritzator changed the base branch from master to develop May 20, 2022 09:51
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

Successfully merging this pull request may close these issues.

None yet

4 participants