Nope, I get a "declaration expected" error when I try to create the class.Quote:
Originally posted by Pirate
Umm ,
VB Code:
Imports Microsoft.CSharp
:rolleyes:
Ugh
Printable View
Nope, I get a "declaration expected" error when I try to create the class.Quote:
Originally posted by Pirate
Umm ,
VB Code:
Imports Microsoft.CSharp
:rolleyes:
Ugh
After you got it referenced , try closing your application and run again . Uh , hope I'm not saying bull**** but surely this makes one crazy .:confused: . I mean everything seems to be fine as you mentioned but oh well .
I reloaded VS 2003 and it still does it, ugh.Quote:
Originally posted by Pirate
After you got it referenced , try closing your application and run again . Uh , hope I'm not saying bull**** but surely this makes one crazy .:confused: . I mean everything seems to be fine as you mentioned but oh well .
I don't get it, in the class browser it shows the Controller namespace and under that it shows my class and then my functions, but yet I cannot use any of them! Ugh.
There is probably something really simple you need to do and I just overlooked it or something.
There is something that you must be missing. Did the DLL compile fine? Where does UCase come from? Here is an example like the code you posted and it works just fine.
I never tried to compile it. There is no reason to, right now I have 3 projects in my solutions. 1 being the VB DLL and the other being the C# DLL. I am trying to port the VB DLL to the C# DLL before I delete the VB DLL project, so I haven't tried compiling it yet. I can't even use the code from the C# project anyway so there isn't much since to t and compile it anyway.Quote:
Originally posted by Edneeis
There is something that you must be missing. Did the DLL compile fine? Where does UCase come from? Here is an example like the code you posted and it works just fine.
I'll check out your solution though, maybe I just missed something stupid and I'll figure it out
BTW, UCase() is a VB function. It makes a string uppercase.,
Okay, I think I got you guys confused. I want to use this C# DLL in a VB.NET Forms Application. Edneeis' example is of 2 C# projects, and it works fine, and I am doing the EXACT samething except I am using a C# DLL and a VB.NET project.
Is their something special I have to do since the DLL is in C# and the app is in VB? I didn't think you would because of the CRL (I think I got that one right).
Use release mode and build your dll . Well , you must do this sooner or later . Try this dll in new project and see what's going to happen ?
No its got to be something else here is an example with a VB exe. So if you haven't compiled the dll then I'm assuming you set the reference to the DLL Project right (via the Project tab since there is no actual DLL yet)?
Hmm very strange. There isn't anything you have to do different since it comes from a C# dll.
Yeah I referenced it. I tried building it and holy crap are their alot of errors.
Ack, lol.
Well quick question (again). Is their a C# equivelant for UCase() and Replace()? Those work fine in VB and I tried using Microsoft.VisualBasic but that wouldn't let me use them.
Then fix the errors , they might be your problem .Quote:
Originally posted by kasracer
Yeah I referenced it. I tried building it and holy crap are their alot of errors.
Ack, lol.
Well quick question (again). Is their a C# equivelant for UCase() and Replace()? Those work fine in VB and I tried using Microsoft.VisualBasic but that wouldn't let me use them.
Yes, ToUpper in string objects .
Code:string s="ABCD";
s.ToUpper();
string s2="Blah";
string tmp=s2.Replace("Blah","New string");
Okay it works now, lol
Now, PT, did you get what you needed? lol
I'm too curious to know what was the problem ? :DQuote:
Originally posted by kasracer
Okay it works now, lol
Now, PT, did you get what you needed? lol
hmm still not, and looking for the highlight code in #develop is a pain in the ass as it is too big and there is no place where it says where each thing isQuote:
Originally posted by kasracer
Okay it works now, lol
Now, PT, did you get what you needed? lol
If speed is an issue then I'd recommend not checking on every keypress. Just check if the last press was a space or enter so you know its at the end of a word.
And to go along with that, only check the last word or words that were typed. You shouldn't need to recheck the whole document everytime. There is a lot of optimizations you can do to this, but you will have to work at it.Quote:
Originally posted by Edneeis
If speed is an issue then I'd recommend not checking on every keypress. Just check if the last press was a space or enter so you know its at the end of a word.
Or start it in separate thread . I've read an article some time ago about MS Word in relation to threadings. It's multithreaded app in sense of one thread for checking grammer , and one for word processing, while some other do kinds of alignments at the same time . So , you should consider this as a solution .Quote:
Originally posted by Edneeis
If speed is an issue then I'd recommend not checking on every keypress. Just check if the last press was a space or enter so you know its at the end of a word.
Here is a small example using RegularExpressions. It uses the only check on spaces and enters as well as only checking the last word.
But the code i shown earlier in the topic only searched for the last word lolQuote:
Originally posted by Edneeis
Here is a small example using RegularExpressions. It uses the only check on spaces and enters as well as only checking the last word.
edit: tried your code with the document i've tried mine code and it is even slower
The thing to understand is that my document has about 30k lines
Can you upload a file to use as an example? A lot of the optimizations mentioned are more for as you type. If you already have the file and just need to colorize it then I'm sure there are much better ways of handling the initial coloring.
question
Are we interested in finding speedy code for syntax-highlight existing files when they open, or highlight as a user types?
Both things, I need to do it when i open the file and that's ok as it can take whatever time it takes but also as you typeQuote:
Originally posted by nemaroller
question
Are we interested in finding speedy code for syntax-highlight existing files when they open, or highlight as a user types?
Well, it shouldn't be really complicated then.
As you type: as I mentioned in my first post on page 1, watch the keypresses, if its anything other than a SPACE , ( , ) you can ignore it.
As far as matching the words typed to reserved words...
I imagine you would want to keep the reserved words in-memory, as a character array, or a string array. It takes memory, but I would be willing to bet all IDE's do it this way.
Your real problem (question) seems to be... what is the best way to color the syntax.
If you use a richtextbox, and when a user hits SPACE, do you reload the entire contents of the richtextbox with the new formatting for the word ... ie... myrichtextbox1.text=revisedtext? Is that fast enough when considering 30,000 lines of text.?
Or, do you need a custom-made text-entry area, that perhaps uses .drawstring so you can erase only that word, and refill it.
Therefore, how you render the formatted (colored) word appearance, is the design issue. I haven't worked much with richtextboxes, so if there is a way to just replace one line, surely that would do. If there's not, then you must look at option 2... even as complicated as it may first appear to be.
As the file loads : Well, that should be heck alot easier than the first issue. As you said, speed is not much of an issue there.
I really don't see how I could go about doing that DrawString thing...Am i suposed to draw all the in screen text or just the word? and if i scroll down the text box? Isn't it goin to be a mess? :S
Using DrawString methods will be a second opinion (I like it) but it has to be drawing from OnPaint or probably he has to create his own RTF control and override that . Umm , I don't how the performance will be but I suppose this event is busy with different drawing issues .
This simple code shows how to draw string , PT :
I agree with nemaroller about loading all 'keywords' in array that your editor has to check . Try to read anything about word processing in turn it might help to figure out how to handle this . I've not toyed with RTF yet , but these are just quick tips .:DCode:Font fnt=new Font("Times New Roman",10);
Graphics g=richTextBox1.CreateGraphics();
g.DrawString("Colored Text",fnt,Brushes.Red,20,20);
Thanks, i've already used .DrawString() before but I can see a LOT of work to highlight the things in the OnPaint. DId you already think that everytime the user scrolls or moves the text I will have to call the Paint event? it will make it very slow (I think..)
Umm , interesting !Quote:
Originally posted by PT Exorcist
Thanks, i've already used .DrawString() before but I can see a LOT of work to highlight the things in the OnPaint. DId you already think that everytime the user scrolls or moves the text I will have to call the Paint event? it will make it very slow (I think..)
To answer this question , put a MessageBox.Show("blah") in OnPaint() method and just type in the RTF and see if it draws as it scroll down . I think yes . Basically , that method gets fired on any tiny change in the window if I'm not wrong .
errm I can't find that event in the richtextbox, only in the form
do they miss that? :S
ok the OnPaint() method is protected so only if you inherit from the richtextbox you can access it..
Anyways I did it and it didn't fire even once:confused:
will I have to subclass the damn thing?
OnPaint , I forgot how to do that in VB.NET but it's very easy in C#:D . Are you using C# or VB?Quote:
Originally posted by PT Exorcist
errm I can't find that event in the richtextbox, only in the form
do they miss that? :S
Well, it appears RichTextbox has a Lines property, in which you can manipulate a single line. This is probably your best bet, combining simplicity and performance.
This way, you would only need to replace the current line the user is typing in.
hmm yep i'm so stupid..i've used that property to implement a line counter in the side of the richtextbox and completly forgot about that when using it in this highlighterQuote:
Originally posted by nemaroller
Well, it appears RichTextbox has a Lines property, in which you can manipulate a single line. This is probably your best bet, combining simplicity and performance.
This way, you would only need to replace the current line the user is typing in.
edit:but I can't put RTF with that as it only shows me the text without formatting tags :blush:
darn..
well, sorry to say it, but you're going to have to inherit system.windows.forms.textboxbase and figure it out from there.
Even if it showed the RTF in the .Lines property i think it wouldn't work as what it does when you use the property is go thru all the code at runtime and get the line so no big advantage in that
richtextbox inherits textboxbase, so you should be able to get control of what color(font) to draw with on any specified line or text, since rtf uses it, and it has formatted text.
Is there any ready property that returns the last word was typed and also the position ?
No
****
I think the ONLY way to do that efficiently is thru subclassing
Which implies writing a lot of code . Did you figure out anything from the C# IDE open source ? my next proj is something about code formatting so I'm afraid I'll get stuck in some part .:rolleyes:
No, I did find the line number object but didn't quite get how that did work
Well, after spending the last half hour catching wndproc messages, it appears whenever there are formatting changes within the text in a richedit control, it sends a EM_GETCHARFORMAT, which seems to direct the edit control window on how to draw the text.
Anyway, here is a resouce you'll probably need!
http://msdn.microsoft.com/library/de...itcontrols.asp
"application can send messages to a rich edit control to format characters and paragraphs to retrieve formatting information. Paragraph formatting attributes include alignment, tabs, indents, numbering, and simple tables. For characters, you can specify font name, size, color, and effects such as bold, italic, and protected.
You can apply paragraph formatting by using the EM_SETPARAFORMAT message. To determine the current paragraph formatting for the selected text, use the EM_GETPARAFORMAT message. The PARAFORMAT or PARAFORMAT2 structure is used with both messages to specify paragraph formatting attributes.
You can apply character formatting by using the EM_SETCHARFORMAT message. To determine the current character formatting for the selected text, you can use the EM_GETCHARFORMAT message. The CHARFORMAT or CHARFORMAT2 structure is used with both messages to specify character attributes.
You can also use EM_SETCHARFORMAT and EM_GETCHARFORMAT messages to set and retrieve the character formatting of the insertion point, which is the formatting applied to any subsequently inserted characters. For example, if an application sets the default character formatting to bold and the user then types a character, that character is bold.
The character formatting of the insertion point is applied to newly inserted text only if the current selection is empty (if the current selection is an insertion point). Otherwise, the new text assumes the character formatting of the text it replaces. If the selection changes, the default character formatting changes to match the first character in the new selection.
The protected character effect is unique in that it does not change the appearance of text. If the user attempts to modify protected text, a rich edit control sends its parent window an EN_PROTECTED notification message, allowing the parent window to allow or prevent the change. To receive this notification message, you must enable it by using the EM_SETEVENTMASK message.
Foreground color is always a character attribute. In Rich Edit 1.0, background color is only a property of the rich edit control. To set the default background color, use the EM_SETBKGNDCOLOR message. Note, Rich Edit does not support the
"
Thanks I'll read it
I had a idea that might be good. I could just use #develop and add the IL language to it, I'd have a good GUI and would have much of the trouble resolved. What do you think? I already made a post asking that guys if it's easy or not to implement those things: http://www.icsharpcode.net/OpenSourc...?TOPIC_ID=4009
Also in another thread i said #develop sucks, well their new beta versions are a LOT better than the first ones that i've tried
Did you check this out ? It seems there are other ones written in C# ! Just dig in :D
http://sourceforge.net/softwaremap/t...85&discrim=271
Thanks I didnt know about them and I'll look at them but the idea of using #develop to something usefull(haha :P) is exciting me
Quote:
Originally posted by PT Exorcist
I had a idea that might be good. I could just use #develop and add the IL language to it, I'd have a good GUI and would have much of the trouble resolved. What do you think? I already made a post asking that guys if it's easy or not to implement those things: http://www.icsharpcode.net/OpenSourc...?TOPIC_ID=4009
What do you mean by 'add the IL' (Intermediate Language) ? Is that kind of binary editor you are making ?;)
lol :D . If you're subscribed in their mailing list , then they will piss you off with every single line change . heh , good but annoying when I get up in the morning and see email about releasing new update .Quote:
Also in another thread i said #develop sucks, well their new beta versions are a LOT better than the first ones that i've tried
I am going to make an IDE for IL
it has a lot of useful functions, you can see how your code compiles, get a better insight of how the .NET works, and make a lot of things with decompiled files that I won't say here so people don't get pissed off :p
Cool but I expect MS won't continue with that bull-***** called MSIL because it's just an easy way to hack others' code :rolleyes: .
lol .NET cannot exist without the MSIL so MS will always have to use it.
They can make obfuscators(that actually are not that much trouble) or the things that just don't allow the code to be decompiled (at least with ILDASM, but that maybe in the future with some other decompiler might be possible).
Yeah that's what I meant . They will integrate a free tool that obfuscate (lol . it's not a word) code and make it scrambled . But don't be so sure about it , I won't bet on it . Obfuscators is trusted product and they guarantee that it's 100% secured . :)Quote:
Originally posted by PT Exorcist
lol .NET cannot exist without the MSIL so MS will always have to use it.
They can make obfuscators(that actually are not that much trouble) or the things that just don't allow the code to be decompiled (at least with ILDASM, but that maybe in the future with some other decompiler might be possible).
They already did put an obfuscator in VS.net 2003 but the obfuscator just renames the function's name in most of the cases , by the code flow logic you can still see what each function does :rolleyes:
Yah , I know . That's Community Edition , there are also Professional and Enterprise I believe . Goodluck and try to be the first name on the market ! but make sure it's properly protected because if I found ,I won't buy it but I'll crack and use it for free .:D :DQuote:
Originally posted by PT Exorcist
They already did put an obfuscator in VS.net 2003 but the obfuscator just renames the function's name in most of the cases , by the code flow logic you can still see what each function does :rolleyes:
If i ever sell something and use some kind of control I'll use the legal ones, not cracking ones.
If i ever make some open source thing then I'll stick out with the free controls over there.
I am just doing this because I am young and still not make any profit out of this and I would never buy any of these controls anyways. I don't send this cracked controls to friends anyways, but thru decompilation of the DLL's i've learnt already a quite big part of the IL without having to be reading the book. I just go to the reference and see which OpCode does what and from there i just do it.
That's the way of learning i'm starting to use with asm too
I just thought you might need this :http://www.ellkay.com/downloads.htm
It's a converter from C# code to VB.NET that's availabe to download . It may help in some specific implementation issues regarding keywords lookup and so .
Have a look at this project...
http://www.gotdotnet.com/Community/W...8-74db65f463fb
HTH
Russ