|
First, I'd like to let you know that I've selected your project to include in my next application which will be shared under the GNU GPL. Thanks for spending the time to create and release this: it's decently refined and also does a super fast render!
My question:
Is there a way to disable anti-alias for font smoothing? My application is a scripting client, and the font smoothing isn't preferred. It would be nice to have this as a public constructor to toggle the smoothing type to give users more control.
What I found:
In the ColorTextBoxDrawing.cs file, of the initGraphics method:
(some Graphics reference).Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
I've tested this functionality myself, both in the intiGraphics method as well as everywhere else you take in a Graphics parameter, but it seems to be failing. Are you overriding this somewhere else where I've overlooked? Thanks!
_________________
Software Engineer
Penn State Facilities Engineering Institute
|
|
|
|
|
Hi! Sorry for the late reply, but I was on vacation and didn't notice your comments any sooner.
First off, I'm glad to hear that somebody finds this little Control useful and is actually using it. Regarding your comment on anti-aliasing - this shouldn't be hard to implement - I will look into that as soon as I can (i.e. as soon as I have enough time to do so)
Regards,
Christian
|
|
|
|
|
Thanks Christian! No problem on the slow response, as I know you haven't touched this project in quite some time. I found it when Googling for syntax highlighting and rich text box for ideas on how to streamline custom syntax highlighting.
With your color text box, I've been able to avoid having to dump too much energy into streamlining syntax highlighting (and syntax suggestion) since this text box control will render quickly any ways and provide a smooth experience for users. I particularly like the very fast rendering of the line numbering and position reporting features. I've implemented them manually before, but never with as much rendering speed as yours.
_________________
Software Engineer
Penn State Facilities Engineering Institute
|
|
|
|
|
Is there now a solution for disabling AntiAliasing available?
I would be very interested.
|
|
|
|
|
You can use the TextRenderingHint on the Graphics object:
Graphics g;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
|
|
|
|
the colortextbox is not available . its not showing the colortextboxdemo.cs design page and colortextboxdemo2.cs page. pls upload a correct zip it will be very helpfull
Thanks
with regards
Balagurunathan.B
|
|
|
|
|
Hi!
I'm not sure what you mean by "...its not showing the colortextboxdemo.cs design page". Do you mean that you cannot open the project with the Visual Studio Designer? If so, what version are you using? The UI was designed with Visual C# Express 2005. Perhaps you need to recompile the solution or import it if you are using a different version!
Regards,
Chris
|
|
|
|
|
Make sure you delete the ColorTextBox_Key.pfx file first. Save the solution, then close and reopen it.
_________________
Software Engineer
Penn State Facilities Engineering Institute
|
|
|
|
|
First of all, nice job !
I was looking for a custom editbox and this one is cool
I did find a bug though, at least I think so ...
When you set the Font at Designtime it changes visibly, but when you (re)compile, it automatically resets itself to the DefaultFont. I noticed this in the demo's as well. It is possible to change the font at runtime, but the DesignTime support isn't working here. The property seems to have no purpose at the moment.
Could you please post a fix for this?
Thanks
OD
|
|
|
|
|
Hi!
Thanks for the feedback. I'm currently working on some performance improvements for Cut/Copy/Paste operations which require some rework of the internal data structures, so the next release will not be available soon.
In the meantime you can fix the bug you mentioned simply by changing the DesignerSerializationVisibility attribute of the Font property from Content to Visible!
Look for the following line in ColorTextBox.cs:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
and change it to
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
This should solve the problem you encountered.
Regards,
Christian
|
|
|
|
|
Cool that worked just fine
Thanks for the quick reply, I also voted for this article, hope it gets up there soon
Cheers,
OD
|
|
|
|
|
I can't open the project cause a dialog asks me for a password. I have to import a key file "ColorTextBox_Key.pfx" but I am almost new to C# and don't know what I should do.
|
|
|
|
|
Deleting the key file should help...
|
|
|
|
|
|
Quesion: Can we change font of selected text?
|
|
|
|
|
No, ColorTextBox is not intended to be a WYSIWYG editor. Calculating and rendering lines with different fonts is very costly and would slow down the whole component significantly.
However you can extend ColorTextBox to support different fonts, which requires some work as you have to override (nearly) all methods responsible for line drawing and calculation of the line metrics.
Unfortunately I do not have the time to do this, but if someone is willing to do so I'll be glad to assist!
|
|
|
|
|
:-DHi,
first of all, I have been looking for this control for sometime. I test the control using VB.NET. I want to be able to change textcolor on the fly, eg highlight words or whole line, etc
Issue, when set color, eg. ctb.SelectColor = Color.red, and type character. The color will not change. The color change only when you mark chars and change it using same property.
It seems that control allow only text color when you have text selected,then any char typed color will change.
Quesion: Can we change color of text at the cursor ?
|
|
|
|
|
Hello!
You're right! This is definitely a nasty bug - I will fix this in the next release!
Regards,
Christian
|
|
|
|
|
Hmm, on a second thought I'm not quite sure what you're trying to achieve... I know there is a bug when you type text and press Enter while the caret is not positioned at the end of the document. In that case the documents' color will change to the color of the text after the caret. Furthermore copy and paste of colored text coming from the ColorTextBox is currently not supported (although I know that this feature has worked before
However I'm unable to reproduce the behaviour you described - if you set the color with the SelectionColor property all characters will be inserted with that color.
However if the caret position changes after a call to SelectionColor the color will be set to the color at the new caret position.
Greetings,
Christian
-- modified at 14:18 Wednesday 21st March, 2007
|
|
|
|
|
Hi Christian,
Thank you for response,
What I want to archive is to use the control to function as Terminal emulator where I can change color of text before insert chars. For example, if a line of text received contain certain words, I may change color at the begining of the line and insert text, and reset color to normal. Or even highlight words with background color.
I also noticed your bug as you described. To get round that we just need to make sure that caret is at the end of the line.
Is there that we can fix it so that evry char inserted will be specific color, no matter where caret is ?
Is there a problem with focus while setting color properity ?
sanong
|
|
|
|
|
Hi!
I uploaded a new version which hopefully solves the issues you were having!
Regards,
Christian
|
|
|
|
|
Hi Chris,
Thank you.
I will definitly test it.
sanong
|
|
|
|
|
First of all, even though you think your design is not so good, it is the fastest.
Mind you, even leaving along the coloring, we don’t have even satisfactory edit control, for .NET or native Windows. Window’s EDIT lacks important events (like cursor position changed) and also has poor performance; Rich Edit has several severe glitches; some of them are only manifested on big files (I’ve developed my own rich-edit based editor and had a hard time to find some work-arounds).
As to the #developer’s edit control, for some applications it is unacceptable, because it renders way too slowly when the file size is about 2M or more.
So, I would encourage you to work your control in a comprehensive lightweight component. First of all, would you please some of your bugs? Here are some I found (and fixed one of them):
1) You’re missing KeyDown events Ctrl+Ins (copy), Shift+Del (cut), Shift+Ins (paste), “old” CIU-style equivalents (actually, more convenient) of Ctrl+C, Ctrl+X, Ctrl+V.
2) PgUp(PgDown) works incorrectly: it just scrolls, but it MUST also change caret position.
3) RenderMode.GDINative does not work with Unicode; shame on you: working with .NET and P/Invoke you should not forget using “Wide” version of Windows API names and proper marshalling for the.NET type “string”. Please see my fix below but look carefully: generally, you’re supposed to add “W” to all API names.
4) Another RenderMode.GDINative problem: text background color differs from that of control – it’s some close “rounded-up” color.
My fix of bug (3): file Win32Wrapper.cs:
<br />
[DllImport("gdi32.dll", EntryPoint = "ExtTextOutW")]<br />
internal static extern bool ExtTextOut(IntPtr hdc, int X, int Y, uint fuOptions,<br />
[In] ref RECT lprc,<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string lpString,<br />
uint cbCount, int [] lpDx);<br />
<br />
[DllImport("gdi32.dll", EntryPoint="TextOutW")]<br />
internal static extern bool TextOut(IntPtr hdc, int nXStart, int nYStart,<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string lpString,<br />
int cbString);<br />
<br />
[DllImport("gdi32.dll", EntryPoint="GetTextExtentPointW")]<br />
internal static extern bool GetTextExtentPoint(IntPtr hdc,<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string lpString,<br />
int cbString, ref Size lpSize);<br />
Design consideration: caret info area as a part of control is not appropriate. Instead, you should provide just a public event. The user most likely will process this event by updating status bar or something like that.
Lack of feature: how about Word Wrap (#developer’s editor does not have it either)?
Thank you.
--SA
Sergey A Kryukov
SAKryukov
|
|
|
|
|
First of all, thanks for the very constructive input! Concerning the bugs you mentioned:
1. KeyEvents:
Since I do not acutally use the control very much I didn't pay much attention to standard key event handling, but I'll try to implement the missing features as soon as possible!
2. PageUp / PageDown:
Same here: will be implemented in the next release!
3. GDINative rendering:
I implemented this rendering path to do some performance comparsions and I think it doesn't really offer great benefits in that area (maybe it does on slower machines, but I do not have the possibility to verify this as I do not own a sub-GHz PC anymore). Besides the bugs you pointed out (I wasn't aware of the Unicode issue - thanks) there are still other problems involved with native GDI rendering. A long story short: it simply doesn't work the way it's supposed to and should currently not be used. I'll add a comment to the enum value to point that out until I have the time to fix it (of course I'll add the fix you provided to the next release, but as I said there are still some other issues to solve!)
4. Background color for GDINative rendering:
See point 3.
Concerning the caret info area inside the control - let me put it the Microsoft way: "This behavior is by design."
In fact one major feature of the control is the support for reserved areas at the edges of the text area which allow easy extensibility in subclasses. Let me copy / paste the description of that feature from the source code:
So if you do not want to show the caret info area you can simply disable it with the respective property. Additionally I will add a public CaretChanged event to support external handling of caret events (the way you suggested).
I hope this helps!
Regards,
Christian
|
|
|
|
|
Good enough.
So, what are your plans for next release?
Thank you.
--SA
SAKryukov
|
|
|
|
|