Posted 15 years ago
by Daniel Navarro
Version: 9.1.0502
Platform: .NET 3.5
Environment: Windows XP (64-bit)
I'm keeping a list TextSnapshotRange (compilation errors in an DSL), but I want the caret to end up sometimes at the beginning, and sometimes at the end of the range when its selected.
The thing is when I create a new TextSnapshotRange from the TextRange (to keep track of versions) the order of StartOffset/EndOffset are always sorted! (it doesn't keep the original direction of the range).
Let me explain this with an example:
// r1 and r2 are two similar ranges, but in different direction
TextRange r1 = new TextRange(start, end);
TextRange r2 = new TextRange(end, start);
// r1 != r2, but when I convert them to a TextSnapshotRange ...
TextSnapshotRange sr1 = new TextSnapshotRange(Snapshot, r1);
TextSnapshotRange sr2 = new TextSnapshotRange(Snapshot, r2);
// then sr1 == sr2 (it doesn't keep the direction of the selection range)
And I can't find a workaround because all TextSnapshotRange properties are read only, so I can't swap the StartOffset and the EndOffset myself when the direction of the range was backwards.
Thanks.
Please let me know if I didn't explain myself clearly :)
[Modified at 07/22/2009 03:13 PM]
The thing is when I create a new TextSnapshotRange from the TextRange (to keep track of versions) the order of StartOffset/EndOffset are always sorted! (it doesn't keep the original direction of the range).
Let me explain this with an example:
// r1 and r2 are two similar ranges, but in different direction
TextRange r1 = new TextRange(start, end);
TextRange r2 = new TextRange(end, start);
// r1 != r2, but when I convert them to a TextSnapshotRange ...
TextSnapshotRange sr1 = new TextSnapshotRange(Snapshot, r1);
TextSnapshotRange sr2 = new TextSnapshotRange(Snapshot, r2);
// then sr1 == sr2 (it doesn't keep the direction of the selection range)
And I can't find a workaround because all TextSnapshotRange properties are read only, so I can't swap the StartOffset and the EndOffset myself when the direction of the range was backwards.
Thanks.
Please let me know if I didn't explain myself clearly :)
[Modified at 07/22/2009 03:13 PM]