Questions on migrating from WinForms to WPF Editor

SyntaxEditor for WPF Forum

Posted 10 years ago by Craig - Varigence, Inc.
Version: 9.1.0500
Avatar
I've been trying to migrate from the WinForms syntax editor to the WPF Editor and am looking for info. on how to do things with the new WPF editor. Specifically:

1. In the winforms editor, there is a ViewMouseHover event. I assume MouseMove would be the WPF equivalent but is there a provided way to obtain the hitTestResult target so I'm certain that I'm over the text area in the editor?

2. I also use the UserInterfaceUpdate handler a bunch in the WinForms editor. Does the WPF editor have an equivalent event?

3. Looking through the documentation, I don't see any mention of outlining mode. Is that still coming or did I miss it?

4. The Winforms editor had SuspendPainting and ResumePainting functions. I'd suspend painting before changing the document's Text in code and changing FirstVisibilePosition and FirstVisibleX. Then I'd call ResumePainting. Do I still need this in WPF?

Overall, the WPF editor seems really nice although it'd be helpful if the documentation included a migration guide that mapped events and properties from the WinForms version to the WPF version.

Thanks,

-Craig

[Modified at 06/04/2009 07:37 PM]

Comments (7)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Craig,

Please keep in mind that the WinForms version has been developed on for years and the WPF version just came out in public beta last week. So while WPF can already do a lot and does have a lot of neat new features, it still is missing a number of feature areas found in WinForms. We will be adding these areas over the coming months though.

1) We don't yet have a ViewMouseHover event but that is on the TODO list. Same thing for a nice hit test method. You probably can hack up some hit test code now though by using some of the VisualTreeHelper.HitTest methods etc. There also are a number of methods on IEditorView that get positions from mouse locations, etc. But we do plan on wrapping it all up like we do in SE4 with a nicer HitTest method.

2) Sorry, no equivalent event at this time.

3) Outlining has not yet been implemented but is one of the top priority major feature areas we need to work on.

4) Try it without first and let us know if you have any problems. WPF is designed to use more of a general "lazy" approach to doing layouts and rendering so the suspend/resume may not be needed.

5) We do have on our TODO list to make a migration guide too. I think we mention that in the beta notes too. But we're waiting until the object model is a bit more finalized before we work on it. In the meantime please feel free to post questions here and we'll be happy to help.

Also keep an eye on our blog for news of new features that will be added in the months ahead such as outlining, etc.


Actipro Software Support

Posted 5 years ago by Matt Gerrans
Avatar

Is there any more guidance on the topic of migrating from the Winforms Syntax Editor to the WPF one?    In order to get the bi-directional support, I'm doing that with an old Winforms codebase, by hosting the WPF control in Winforms.

There seem to be many areas that have changed and I'm wondering if there are any articles/blogs that can help to speed up the discovery process.   For example, it looks like the event handling scheme is different (old code handles mouse hover events, but WPF doesn't have them, so it is probably some different mechanism, old lexicon files had trigger states, but new langdef files don't, no trigger activated events, spans are apparently replaced by offsets and ranges, span indicators replaced by adornments, etc.).

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matt,

While we don't have specific guidance for converting from the older WinForms model to the WPF one, the WPF one does have pretty extensive documentation and about 100 samples, many of which focus on individual feature areas.

We are also happy to give you pointers for which feature areas to examine that cover similar feature areas in WinForms.

For events, yes things are very different in WPF.  In WPF, languages are service providers.  That means that to add certain features to a language, you register a service on the language.  Some service types (like ILexer and IParser) are well defined and you register services that implement those interfaces to add lexer and parser functionality.  Then there are event sink services where you can handle things like mouse events, typing input events, etc.  Check the documentation for more information on the various language services that are available.

Span indicators are still around but they are implemented by harnessing the tagging features of the WPF SyntaxEditor.  There are special recognized tags for indicators that can be applied over a text range.  Check out the documentation and the several QuickStarts on indicators, as those will show you how to work with them.


Actipro Software Support

Posted 5 years ago by Matt Gerrans
Avatar

Okay, thanks.    By the way, the CHM file is a bit clunky for navigating.    Do you have the docs in any other formats (like html)?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Matt,

I'm sorry but the CHM is he only documentation format we have.


Actipro Software Support

Posted 5 years ago by Matt Gerrans
Avatar

Okay.   The thing that was annoying me about the CHMs is that whenever you follow a link (or do a search, etc.) and come back, it always goes back to the top of the page.    So, the trick is to just open the CHM in two or three separate windows, stay on track in the first one and use the others for searching and following links.    The other annoyance of CHMs is zooming the text size, but it is also managable (make the window small, zoom, then stretch it).

One other question; I'm just looking at your DataGridView control now as well, because our app shows our syntax language in a .NET DataGridView and right now we duplicate the syntax highlighting in the non-editable cells, while using the Actitpro Syntax Editor in the editable cell, which is clunky.    Does your DataGridView have smoother support for the Syntax Editor to support this kind of thing?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matt,

The DataGrid features we show are actually not a custom DataGrid control, but are free open source extensions to the native WPF DataGrid.  There isn't anything in the extensions specific to SyntaxEditor.  You could always use SyntaxEditor in a read-only mode to show the non-editable cells.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.