|
-
September 21st, 2009, 02:40 PM
#7
Re: Coloring a part of string(text ) in Stringbuilder
Coloring a string if you are userdrawing it can be done in any way you want to do it. You only need to create any system where your later during drawing the string could decide whats the string and whats the commands or atributes.
All together id built up in one string like "Here is [Color=red ] my Text [/ red] "
You can create your attributes in your own way or using already known standards like HTML or RTF
If you are consequent your own idea per sure also would work, but if there aleady exists standards, whats the reason not using them. Re- creating the wheel again? Any real reason for that?
Any compatibility to known systems will need lots of conversion while using already known patterns are easy to use and much easier to maintain.
You can use for exmple HTML coding but still parsing that code in your own graphics method and getting the result this way directly drawn to the form.
Having attributes in the end of the text has lots of disadvantages. Doing that your attibutes needs to reference to the point where each of your attributes begins and ends. For example think you simple add one sign in the middle of the text, all your references to text after that change needs to be corrected. XML and using tags for your Attributes is maybe a better solution. But I personally would simple use HTML similar to what we use here Look how the code in the editor is colored and you have an easy solution.
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|