SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

AvalonEdit - Using the WPF TextFormatting Api (System.Windows.Media.TextFormatting)

Last post 10-13-2009 11:49 PM by DanielGrunwald. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-13-2009 6:24 PM

    • DotCam
    • Not Ranked
    • Joined on 10-13-2009
    • Posts 2

    AvalonEdit - Using the WPF TextFormatting Api (System.Windows.Media.TextFormatting)

    Hello everyone,

    I am working on a Wpf CustomControl that acts similar to a standard Wpf TextBox, however I am implementing the features of the System.Windows.Media.TextFormatting namespace (ie TextSource, TextFormatter, etc.). After searching long and hard for any other application that implements the TextFormatter Api, I discovered AvalonEdit, which has enabled me to get the TextFormatter to Format lines for me, and display them on-screen.

    I was wondering if you are able to give me any info on this topic, any info would be appreciated, but I am having trouble with performing hit-testing on the text that is created by the TextFormatter. I have analyzed AvalonEdit and see that you implemented your own logic for this, however the TextLine abstract class contains element's for performing CharacterHit's, and was wondering if you feel that the CharacterHit's are worth using for a control such as mine.

    If you know of any good sources of information on this topic, I have been working on this control for a while now and am not getting anywhere now diue to lack of info... Any other samples you know of (I have gone through all of the Advanced Text samples from MSDN already however) or articles etc (or if you guys know from creating your application), any info such as this would be extremly helpful, and I thank you in advance for your trouble.

    If you do not have any additional info, don't worry, I just thought I would check.

    Thank you very much in advance for any assistance you can provide!

    Cam M

  • 10-13-2009 6:53 PM In reply to

    Re: AvalonEdit - Using the WPF TextFormatting Api (System.Windows.Media.TextFormatting)

    AvalonEdit is using TextLine.GetCharacterHitFromDistance and GetDistanceFromCharacterHit for hit testing. Take a look at VisualLine.GetVisualPosition / GetVisualColumn. Custom logic is only used along the Y axis to find the correct TextLine.

    My primary information source were the Advanced Text samples from MSDN.

  • 10-13-2009 9:15 PM In reply to

    • DotCam
    • Not Ranked
    • Joined on 10-13-2009
    • Posts 2

    Re: AvalonEdit - Using the WPF TextFormatting Api (System.Windows.Media.TextFormatting)

     Hello Daniel,

    Thank you for such a fast response! I have been reviewing the VisualLine class, and went over how you use the CharacterHit's.

    I'm curious as to the reason you chose to create your own VisualLine class instead of implementing the abstract TextLine, was this done because of performance or other related issues with the TextLine class? or because integrating the Wpf TextFormatter with AvalonEdit required it?

    One last thing, is AvalonEdit built on top of the ICSharpCode.TextEditor library?  I found a class called CodeEditor.cs (not sure where I saw it) that looked like an adapter class between the two, is this correct?

    Thank you for the info,

    Cam

  • 10-13-2009 11:49 PM In reply to

    Re: AvalonEdit - Using the WPF TextFormatting Api (System.Windows.Media.TextFormatting)

    Deriving from TextLine means we would have to provide our own implementation of Draw() - the whole point of using TextLine is to re-use the text drawing implementation from the .NET framework.

    AvalonEdit is a stand-alone library, there are no references to any other SharpDevelop library.

    CodeEditor (it's part of AvalonEdit.AddIn) is integrating AvalonEdit into SharpDevelop - providing an adapter to the ITextEditor interface, integrating the bookmark system, code completion, etc.

    This is unrelated to ICSharpCode.TextEditor - apart from some old code that hasn't been ported to ITextEditor or AvalonEdit yet, ICSharpCode.TextEditor is not used anymore in SharpDevelop 4.

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.