How to set one line readonly?

SyntaxEditor for WPF Forum

Posted 13 years ago by Stefan
Avatar
Hello,

I want to set one or more lines readonly, so that the user can't modify them.
But I don't know how to do this.

Maybe with an AdornmentLayer? Please help!

In the WinForms version, I used an SpanIndicatorLayer, but I can't find it in WPF.

Best regards,
Stefan

[Modified at 02/03/2011 03:41 AM]

Comments (5)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stefan,

Unfortunately the automated read-only ranges feature is still on the TODO list for the WPF version. However you can prevent edits to a region by setting e.Cancel = true in the document's TextChanging event if those edits will alter a range that should be read-only.


Actipro Software Support

Posted 13 years ago by Stefan
Avatar
Hello,

thanks for your answer. Now I can set specific lines as read-only:

private void _syntaxEditor_DocumentTextChanging(
object sender,
ActiproSoftware.Windows.Controls.SyntaxEditor.EditorSnapshotChangingEventArgs e)
{
if (FirstAndLastLineLocked)
{
foreach (var operation in e.TextChange.Operations)
{
if (operation.StartPosition.Line < 1)
e.Cancel = true;

if (operation.StartPosition.Line >= e.OldSnapshot.Lines.Count - 1)
e.Cancel = true;

if (operation.DeletionEndPosition.Line >= e.OldSnapshot.Lines.Count - 1)
e.Cancel = true;

if (e.OldSnapshot.Lines.Count + operation.LinesDelta < 3)
e.Cancel = true;
}
}
}

[Modified at 02/04/2011 05:21 AM]
Posted 12 years ago by Andreas
Avatar

Hi,

Is this functionality still unavailable for the WPF editor? I'm running into an issue where I'm collapsing certain regions in a document - but those collapsed regions can still be deleted...which is not good.

We're designing a system where a user is only shown an editable part of a class - but collapsing everything around that editable part is not good enough when you can still delete the collapsed content...

 

Regards,

Andreas

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

Hi Andreas,

We don't yet have read-only regions implemented, but you can use the DocumentTextChanging event to ensure that those regions don't get removed, by canceling the text change as needed.  You could probably call the view.ICollapsedRegionManager's methods to get the collapsed ranges and base your logic on that.


Actipro Software Support

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

Hello,

Read-only regions have been implemented and will be available in the WPF SyntaxEditor 2014.2 build 611 maintenance release.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.