Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contextual Text Editor in WPF

Tags:

c#

.net

wpf

We are currently looking to create a text-editor in WPF (.NET 4.0) which will allow writers within our team to create movie scripts. In short, the functionality should ressemble that of FinalDraft or Adobe Story (i.e.: contextual positioning of text depending on the cursor's position and user intentions)

We are currently looking at two different solutions design-wise:

  • One WPF control which will act as the container, and multiple small text-editing controls which will represent rows within the script. This will allow us to position the controls using their margin, while also making binding easy. The challenge here would be the handling of multi-line selections. I was thinking of using a Listbox as the container, and each listbox item would be a custom control containing a textbox. This would require the instantiation of controls depending on the user's action. Everything would be skinned to give the impression that the user is working on a blank page.

  • One big textbox capable of displaying custom XML data. The challenge here would be to determine where exactly the cursor is located (i.e.: is the cursor on top of an actor's name, etc.) and positioning the text appropriately (i.e.: actor names are centered and in caps, etc.)

I recently tried implementing the first solution, but having to re-implement the whole selection behavior that is built-in in basic text boxes is non-trivial and requires a lot of work. As for the second solution, binding to my business objects will be much harder than simply instantiating multiple controls with different bindings.

Do you have any other solution in mind ?

like image 398
Hussein Khalil Avatar asked Jul 09 '12 16:07

Hussein Khalil


1 Answers

I needed a text editor for a application once. We had a big xml file for settings and the user should be able edit those.

Turns out , if your file is large enough (+ 10000 lines) the rich text box is getting pritty slow.

As for building a gui mask : only if your user wirtes some short options like text. But is i understand you want your useres to write creativ text. This "mask" gui - "lot of small places" will make them feel like they are in the 80ties.

I suggest: Dont write the Programm , only write a Plugin to an exitings editor. Some are free like: http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor or an add in for word - people love Word and know Word http://www.codeproject.com/Articles/8837/Writing-a-Word-Add-in-Part-I

And for binding data and the like: Once the text is written, the user just need to press the save button and you can parse the input for information. I would not do it on the fly as it can get pretty slow. Also you say that the information is linked so only if all the data is written you can make use of it.

like image 138
Thomas Avatar answered Oct 24 '22 04:10

Thomas