-
Dec 29th, 2011, 12:28 PM
#1
Thread Starter
Member
ColorCode.dll Help
Hi, I've been trying to get syntax hilighting for a RichTextBox.
I am struggling trying to code it myself, so I looked around a bit, and found a cool .dll file called ColorCode.
http://colorcode.codeplex.com/
So I went into my project and imported the ColorCode.dll file. (Project>Add Reference)
However, I don't know how to use it!?
Is there anyone out there that has used this .dll file?
How can I use it to get Syntax Hilighting in RichTextBox1?
I have googled may times with no sucess.
-
Dec 29th, 2011, 07:59 PM
#2
Re: ColorCode.dll Help
the example on that page looks simple enough:
vb Code:
imports ColorCode
dim sourceCode as string = io.File.ReadAllText("/path/to/source/file")
dim colorizedSourceCode as string = new CodeColorizer().Colorize(sourceCode, Languages.CSharp)
i haven't tried it but i'm guessing colorizedSourceCode will contain rtf
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 1st, 2012, 08:32 PM
#3
Thread Starter
Member
Re: ColorCode.dll Help
I have tried that code, but i don't know how i'm supposed to use it? thoes are Dim statements..?
-
Jan 1st, 2012, 08:41 PM
#4
Re: ColorCode.dll Help
assuming you want c# syntax highlighting:
vb Code:
richtextbox1.rtf = new CodeColorizer().Colorize(richtextbox1.text, Languages.CSharp)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 1st, 2012, 08:56 PM
#5
Thread Starter
Member
Re: ColorCode.dll Help
ok, thanks for your help, but at run-time i get this message:
"File format is not valid."
and it highlights this line:
Code:
richtextbox1.rtf = new CodeColorizer().Colorize(richtextbox1.text, Languages.CSharp)
I've tried changing it to:
Code:
Dim colorizedSourceCode As String = New CodeColorizer().Colorize(RichTextBox1.Text, Languages.CSharp)
RichTextBox1.Rtf = colorizedSourceCode
Thanks for your help, i really appreciate it!
-
Jan 1st, 2012, 09:06 PM
#6
Re: ColorCode.dll Help
i don't know any more about how ColorCode.dll works.
hopefully someone else can help you.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 1st, 2012, 09:30 PM
#7
PowerPoster
-
Jan 2nd, 2012, 04:15 PM
#8
Thread Starter
Member
Re: ColorCode.dll Help
I have tried this:
Code:
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim sourceCode As String = My.Resources.Resources.IHttpModule
Dim coloredCode As ColorCode.CodeColorizer = New ColorCode.
CodeColorizer
Dim colorizedSourceCode As String = coloredCode.Colorize(sourceCode, ColorCode.Languages.VbDotNet)
End Sub
Before, but could not understand, or get how to use the part at the top which says:
Code:
Dim sourceCode As String = My.Resources.Resources.IHttpModule
-
Jan 2nd, 2012, 04:18 PM
#9
PowerPoster
Re: ColorCode.dll Help
not sure I follow. do you have anything in your resources IHttpModule?
by the look and conventions, IHttpModule is an interface. you are using a string to get sourcecode.
you dont need it. sourcecode is just a string.... ie:
Code:
Dim myString as String = "hello"
the above line is a source code snippet for VB code. what if you use the above string in "sourceCode"?
-
Jan 2nd, 2012, 05:33 PM
#10
Thread Starter
Member
Re: ColorCode.dll Help
ok, i see, but it's all Dim statements, when do you actually use any of the defined statements to effect the text in the RichTextBox?
I tried:
Code:
RichTextBox1.Text = colorizedSourceCode
Which was a mess.
I also tried:
Code:
RichTextBox1.RTF = colorizedSourceCode
but that crashed. ):
-
Jan 2nd, 2012, 05:36 PM
#11
PowerPoster
Re: ColorCode.dll Help
crashed? why would a string being assigned to a string crash? error messages please!
you say when do you use it to actually reflect the changes? well, here:
Dim colorizedSourceCode As String = coloredCode.Colorize(sourceCode, ColorCode.Languages.VbDotNet)
richTextBox.Text = colorizedSourceCode
now remember though, for the formatting to happen, the output from the colorizer MUST be have the correct syntax/formatting for RTF so the control can render it the way you want otherwise, it wont work.
-
Jan 2nd, 2012, 06:07 PM
#12
Thread Starter
Member
Re: ColorCode.dll Help
at run-time,
and when trying:
Code:
Dim colorizedSourceCode As String = coloredCode.Colorize(sourceCode, ColorCode.Languages.VbDotNet)
RichTextBox1.Text = colorizedSourceCode
I get lots of funny charicters when I enter text, such as when entering "Imports" I get this in my RichTextBox:
Code:
<div style="color:Black;background-color:White;"><pre>
s<div style=<span style="color:#A31515;">"color:Black;background-color:White;"</span>><pre>
t&lt;div style=<span style=<span style="color:#A31515;">"color:#A31515;"</span>>&quot;color:Black;background-color:White;&quot;</span>&gt;&lt;pre&gt;
r&amp;lt;div style=&lt;span style=<span style=<span style="color:#A31515;">"color:#A31515;"</span>>&quot;color:#A31515;&quot;</span>&gt;&amp;quot;color:Black;background-color:White;&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;pre&amp;gt;
o&amp;amp;lt;div style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#A31515;">"color:#A31515;"</span>>&quot;color:#A31515;&quot;</span>&gt;&amp;quot;color:#A31515;&amp;quot;&lt;/span&gt;&amp;gt;&amp;amp;quot;color:Black;background-color:White;&amp;amp;quot;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;lt;pre&amp;amp;gt;
p&amp;amp;amp;lt;div style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#A31515;">"color:#A31515;"</span>>&quot;color:#A31515;&quot;</span>&gt;&amp;quot;color:#A31515;&amp;quot;&lt;/span&gt;&amp;gt;&amp;amp;quot;color:#A31515;&amp;amp;quot;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;quot;color:Black;background-color:White;&amp;amp;amp;quot;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;lt;pre&amp;amp;amp;gt;
m&amp;amp;amp;amp;lt;div style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#A31515;">"color:#A31515;"</span>>&quot;color:#A31515;&quot;</span>&gt;&amp;quot;color:#A31515;&amp;quot;&lt;/span&gt;&amp;gt;&amp;amp;quot;color:#A31515;&amp;amp;quot;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;quot;color:#A31515;&amp;amp;amp;quot;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;quot;color:Black;background-color:White;&amp;amp;amp;amp;quot;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;pre&amp;amp;amp;amp;gt;
I
&amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;gt;
&amp;amp;amp;lt;/pre&amp;amp;amp;gt;&amp;amp;amp;lt;/div&amp;amp;amp;gt;
&amp;amp;lt;/pre&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;
&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
</pre></div>
</pre></div>
-
Jan 2nd, 2012, 06:16 PM
#13
PowerPoster
Re: ColorCode.dll Help
ah
this is HTML. RTF is NOT HTML
this is your problem here
-
Jan 2nd, 2012, 06:28 PM
#14
Thread Starter
Member
Re: ColorCode.dll Help
eh, why would it turn to HTML?!
any ideas on how to fix it?
-
Jan 2nd, 2012, 06:31 PM
#15
PowerPoster
Re: ColorCode.dll Help
well, not sure how the 3rd party API works (you should contact them since they made it!) but if it spits out HTML Then that probably is its job. unless there is some options/settings you need to specify, dont know
there is nothing to "fix" if it was developed for HTML....
why dont you take a look at the source code?
http://colorcode.codeplex.com/Source...ist/changesets
it helps if you read more and more about the product (just browsing the site) - it pretty much is designed for HTML. case closed really
-
Jan 2nd, 2012, 06:38 PM
#16
Thread Starter
Member
Re: ColorCode.dll Help
):
I will contact them.
on their main page it says:
"Language Support
ColorCode supports the following languages:
XML
Java
JavaScript
SQL
C#
VB.NET
ASPX (C#)
ASPX (VB.NET)
C++
PHP
PowerShell"
-
Jan 2nd, 2012, 06:40 PM
#17
PowerPoster
Re: ColorCode.dll Help
yes meaning that the syntax highlighter will work with code that is of the above languages (with the options specified in the configuration)
it does work. but it is only for HTML. for example if you write (in a string) VB.NET or C# code and configure it for the respective language, it will syntax highlight it
Tags for this Thread
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
|