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

making a simple string parser to insert the icon #2

Closed
furesoft opened this issue May 26, 2016 · 4 comments
Closed

making a simple string parser to insert the icon #2

furesoft opened this issue May 26, 2016 · 4 comments
Assignees
Milestone

Comments

@furesoft
Copy link

furesoft commented May 26, 2016

hi, pls add a string parser to add icons to textblock, rtb, etc like this:

:btc: is a cryptocurrency. :EURO: is a fiat money

@mkoertgen
Copy link
Member

mkoertgen commented May 27, 2016

Ah, i see. Nice idea.

Some thoughts on this. The parser would

  • create a separate run for each parsed icon - using the the fontawesome font
  • by default share size and foreground of the textblock's font

The generated inline for the textblock could be equivalent to this XAML

<TextBlock FontFamily="<some other font>">
  <Run Text="[&#xf15a;" FontFamily="/FontAwesome.Sharp;component/fonts/#FontAwesome"/>
  <Run Text=": is a cryptocurrency. "/>
  <Run Text="&#xf153;" FontFamily="/FontAwesome.Sharp;component/fonts/#FontAwesome"/>
  <Run Text=": is a fiat money"/>
</TextBlock>

Is that kind of what you had in mind?

@mkoertgen
Copy link
Member

mkoertgen commented May 27, 2016

Usage could be like this

<fa:.....TextBlock Text=":btc: is a cryptocurrency. :EURO: is a fiat money" />

This would allow binding a text which includes icon-tags. Nice.

I would suggest to get close to the standard c# string interpolation syntax for icon-tags like this

<fa:.....TextBlock Text="{fa:btc}: is a cryptocurrency. {fa-euro}: is a fiat money" />

I'm not sure yet if subclassing a text block would be a good fit. Maybe an attached behavior would suit better.

Here is an example where we used an attached behavior to format highlighted search results from elasticsearch back into a textblock

https://github.com/mkoertgen/hello.elastic.facetedSearch.wpf/blob/e21eb12e4fd3110afa65ce4dc1281b3c07c43bea/HelloFacets/Attached.cs

@mkoertgen
Copy link
Member

mkoertgen commented Jun 20, 2016

@furesoft Right now, i have no time for this. Feel free to contribute and do a pull request.

@mkoertgen mkoertgen self-assigned this Jun 25, 2016
@mkoertgen mkoertgen added this to the 4.6.3 milestone Jun 25, 2016
@mkoertgen mkoertgen reopened this Jun 25, 2016
@mkoertgen
Copy link
Member

mkoertgen commented Jun 25, 2016

Hi @furesoft. Had some spare time, so i added an inline parser as suggested using the attached property fa:Awesome.Inline.

Please check out v4.6.3 and let me know if this works out for you.

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

No branches or pull requests

2 participants