I'm using AvalonEdit in a Microsoft Surface application. It's working great, but I have one problem with folding. There are this small + icons to enable folding. But I don't know how I can register the appropriate contact handlers. Any hints how to do that?
How to use AvalonEdit in Microsoft Surface application?
Asked Answered
I'm not sure what you mean by "contact handlers".
But you have to supply a folding strategy class based on AbstractFoldingStrategy. However folding strategy to go with most commonly used braces is not in the default AvalonEditor package, you can find one in the sample application or find it somewhere on the internet. But as you can't really do it to 100% without syntactic analysis of the code being edited, this simple BraceFoldingStrategy will occasionally behave in a rather odd way.
The folding is working correctly if I use it as a WPF application. I already installed other than the default handling strategy. The problem is, in Microsoft Surface, the touch events aren't recognized a properly mapped to the +/- icons that are there to fold the folding sections. –
Mountaineering
Ah, this. Have you tried looking into the AvalonEdit source code? It must be possible to add the touch events to the +/- boxes. You can find the source code as part of SharpDevelop sources. –
Mundy
@mzabsky: yes i searched through the source code but couldn't find the correct part in it. –
Mountaineering
@Roflcoptr Look at method OnMouseDown method in FoldingMarginMarker.cs –
Mundy
@mzabsky: ah thanks, that is the correct place, now I have just to figure out how to register other contact handlers there –
Mountaineering
@mzabsky: I registered a ContactHandler to each FoldingMargin. This works, each FoldingMargin has some markers as you pointed out. Do you know how I can find the correct FoldingMarginMarker based on the FoldingMargin? –
Mountaineering
@Roflcoptr What are you trying to do? Just overload OnTouchDown the exact same way the OnMouseDown is overloaded. –
Mundy
@mzabsky: I cant implement OnTouchDown in FoldingMarginMarker –
Mountaineering
@Roflcoptr Why? It inherits UIElement and UIElement has protected virtual metthod OnTouchDown...Or am I missing somethong? –
Mundy
@mzabsky: I don't think that OnTouchDown is the contact handler used by Microsoft Surface, but I'll try right now. Thanks! –
Mountaineering
@mzabsky: No it is really not possible. I can't override an OnTouchDown method. The method isn't found. –
Mountaineering
@Roflcoptr It was added in .NET 4.0, make sure you are not targeting .NET 3.5. –
Mundy
@mzabsky: Ok I found it, but changing it to NET 4.0 has to many other infuences on the existing code. However Ill mark your answer as accepted. I found another solution that isn't really nice, but is working. Im iterationg over all FoldingMarginMarkers and check which one is next to the capture Contact. –
Mountaineering
@Roflcoptr I'm glad your problem is solved, though I wonder what kind of issue prevents you from upping to .NET 4 (which is by all means significant improvement over 3.5, especially in context of WPF). Also, when you have a working solution, you should consider sending a patch file to the authors of SharpDevelop (or at least report them the issue). –
Mundy
© 2022 - 2024 — McMap. All rights reserved.