Multiline Controls or Adornments

SyntaxEditor for WPF Forum

Posted 11 years ago by tal
Version: 13.1.0582
Avatar

Hey,

I am looking into building a small interpreter using SyntaxEditor and I was wondering how, if possible, could I (maybe using the Adornments system) append multi line controls (or adornments).

An example of a use case is that after hitting ENTER the last line (with the cursor) gets evaluated and the output is presented in a graph / tree view (or in any other control, for that matter which has a predefined height greater than one line) in the next few lines (which should not be modified using user input on the editor – the later could easily be accomplished using e.Cancel on document's text changed in the specific text ranges).

Thanks for the help,
Tal

Comments (8)

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

Hi Tal,

You might be able to inject a couple blank lines at the end of the document when Enter is pressed.  Make something that places an adornment on that first blank line's text range.  You should be able to use your intra-text spacer to reserve as must space as you need to render your adornment.

Then as you said, watch the document's TextChanging event and block any updates if they would overlap one of your adornment ranges.


Actipro Software Support

Posted 11 years ago by tal
Avatar

Hey,

Thanks, I went with this line of thinking and found out (after a bit of digging) inside the adornments example the lines:

IntraTextNoteTag tag = new IntraTextNoteTag();
tag.Key = tag;
tag.Size = new Size(30, 48);

I changed the size to what ever I needed and it worked like a charm.. (tag.Size = new Size(300, 300);

(Worth mentioning that the cursor would not change from TEXT-EDITING-MODE to the proper controller's mouse icon automatically...)

I have another small issue which I am having trouble finding the easiest solution: I want to enable the user to copy the text from the editor (using CTRL+C) while replacing the adornments with some other text - how could I achieve that?

Thanks again for the help,

Tal

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

Hi Tal,

For the mouse cursor, you can set the Cursor property of your adornment element to whichever cursor you wish to use.

For your other question, could you provide some more detail, perhaps with an example of the before and after, so that we can better understand what you are after?  Thanks!


Actipro Software Support

Posted 11 years ago by tal
Avatar

Hey,

The mouse cursor worked prefectly,

An eample would be: (interpreter code in the SyntaxEditor)

>> calc.plot("f(x)=x^2")

<adornment of a GRAPH-CONTROL for f(x)=x^2 (with scroll bars, zoom etc..)>

>>

And when I select all the contents of the SyntaxEditor and press CTRL+C I would like to replace the graph control (which cannot be copied to the clipboard) with an image (or supplement text in other cases) of the graph under the current conditions (zoom and location of the plot in the graph - which I already have a method of getting an image of the control).

Thanks again,

Tal

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

Hi Tal,

Your best bet would be to watch the CutCopyDrag event.  The event args for that pass the IDataStore that will be set to the clipboard.  So you can modify that as needed.


Actipro Software Support

Posted 11 years ago by tal
Avatar

Hey,

I tried that with setting the e.DataStore data and was unsuccessful:

e.DataStore.SetData("Text", "TEMP CONST STRING", true);

(I made sure that the event was called and that e.Action was indeed a Copy event; and made sure that the format "Text" was the correct one...)

I also tried to cancel out the event using e.Handled = True (in order to set the clipboard myself and not using the event caller) - again my attempt was unsuccessful...

Is there something wrong with what I did? how can I use it correctly?

Thanks,

Tal

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

Hi Tal,

We also set and check UnicodeText, and that has priority over Text.  So you'd need to do this:

e.DataStore.SetData("Text", "TEMP CONST STRING", true);
e.DataStore.SetData("UnicodeText", "TEMP CONST STRING", true);


Actipro Software Support

Posted 11 years ago by tal
Avatar

That worked great!

Thanks,

Tal

The latest build of this product (v24.1.2) was released 10 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.