2424using System . Windows . Documents ;
2525using System . Windows . Input ;
2626using System . Windows . Media ;
27+
2728using ICSharpCode . AvalonEdit ;
2829using ICSharpCode . AvalonEdit . Editing ;
2930using ICSharpCode . AvalonEdit . Rendering ;
3031using ICSharpCode . AvalonEdit . Utils ;
3132using ICSharpCode . NRefactory ;
3233using ICSharpCode . SharpDevelop ;
3334using ICSharpCode . SharpDevelop . Editor ;
35+
3436namespace CSharpBinding . Refactoring
3537{
3638 class InsertionCursorLayer : Canvas , IDisposable
@@ -41,9 +43,10 @@ class InsertionCursorLayer : Canvas, IDisposable
4143
4244 readonly TextArea editor ;
4345
44- public int CurrentInsertionPoint {
45- get ;
46- set ;
46+ public int CurrentInsertionPointIndex { get ; set ; }
47+
48+ public InsertionPoint [ ] InsertionPoints {
49+ get { return insertionPoints ; }
4750 }
4851
4952 int insertionPointNextToMouse = - 1 ;
@@ -73,8 +76,8 @@ public InsertionCursorLayer(TextArea editor, string operation, IList<InsertionPo
7376
7477 protected override void OnRender ( DrawingContext drawingContext )
7578 {
76- DrawLineForInsertionPoint ( CurrentInsertionPoint , markerPen , drawingContext ) ;
77- if ( insertionPointNextToMouse > - 1 && insertionPointNextToMouse != CurrentInsertionPoint )
79+ DrawLineForInsertionPoint ( CurrentInsertionPointIndex , markerPen , drawingContext ) ;
80+ if ( insertionPointNextToMouse > - 1 && insertionPointNextToMouse != CurrentInsertionPointIndex )
7881 DrawLineForInsertionPoint ( insertionPointNextToMouse , tempMarkerPen , drawingContext ) ;
7982 SetGroupBoxPosition ( ) ;
8083 // HACK: why OnRender() override? we could just use Line objects instead
@@ -128,7 +131,7 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
128131 else {
129132 insertionPointNextToMouse = FindNextInsertionPoint ( e . GetPosition ( this ) ) ;
130133 if ( insertionPointNextToMouse >= 0 )
131- CurrentInsertionPoint = insertionPointNextToMouse ;
134+ CurrentInsertionPointIndex = insertionPointNextToMouse ;
132135 InvalidateVisual ( ) ;
133136 }
134137 e . Handled = true ;
@@ -181,9 +184,9 @@ ExecutedRoutedEventHandler MoveMarker(bool up)
181184 {
182185 return ( sender , e ) => {
183186 if ( up )
184- layer . CurrentInsertionPoint = Math . Max ( 0 , layer . CurrentInsertionPoint - 1 ) ;
187+ layer . CurrentInsertionPointIndex = Math . Max ( 0 , layer . CurrentInsertionPointIndex - 1 ) ;
185188 else
186- layer . CurrentInsertionPoint = Math . Min ( layer . insertionPoints . Length - 1 , layer . CurrentInsertionPoint + 1 ) ;
189+ layer . CurrentInsertionPointIndex = Math . Min ( layer . insertionPoints . Length - 1 , layer . CurrentInsertionPointIndex + 1 ) ;
187190 layer . InvalidateVisual ( ) ;
188191 layer . ScrollToInsertionPoint ( ) ;
189192 } ;
@@ -192,9 +195,9 @@ ExecutedRoutedEventHandler MoveMarker(bool up)
192195 ExecutedRoutedEventHandler MoveMarkerPage ( bool up )
193196 {
194197 return ( sender , e ) => {
195- TextLocation current = layer . insertionPoints [ layer . CurrentInsertionPoint ] . Location ;
198+ TextLocation current = layer . insertionPoints [ layer . CurrentInsertionPointIndex ] . Location ;
196199 double currentVPos = layer . editor . TextView . GetVisualTopByDocumentLine ( current . Line ) ;
197- int newIndex = layer . CurrentInsertionPoint ;
200+ int newIndex = layer . CurrentInsertionPointIndex ;
198201 double newVPos ;
199202 do {
200203 if ( up ) {
@@ -214,7 +217,7 @@ ExecutedRoutedEventHandler MoveMarkerPage(bool up)
214217 newVPos = layer . editor . TextView . GetVisualTopByDocumentLine ( layer . insertionPoints [ newIndex ] . Location . Line ) ;
215218 }
216219 while ( Math . Abs ( currentVPos - newVPos ) < layer . editor . ActualHeight ) ;
217- layer . CurrentInsertionPoint = newIndex ;
220+ layer . CurrentInsertionPointIndex = newIndex ;
218221 layer . InvalidateVisual ( ) ;
219222 layer . ScrollToInsertionPoint ( ) ;
220223 } ;
@@ -224,9 +227,9 @@ ExecutedRoutedEventHandler MoveMarkerFull(bool up)
224227 {
225228 return ( sender , e ) => {
226229 if ( up )
227- layer . CurrentInsertionPoint = 0 ;
230+ layer . CurrentInsertionPointIndex = 0 ;
228231 else
229- layer . CurrentInsertionPoint = layer . insertionPoints . Length - 1 ;
232+ layer . CurrentInsertionPointIndex = layer . insertionPoints . Length - 1 ;
230233 layer . InvalidateVisual ( ) ;
231234 layer . ScrollToInsertionPoint ( ) ;
232235 } ;
@@ -247,14 +250,14 @@ void InsertCode(object sender, ExecutedRoutedEventArgs e)
247250
248251 internal void ScrollToInsertionPoint ( )
249252 {
250- var location = insertionPoints [ CurrentInsertionPoint ] . Location ;
253+ var location = insertionPoints [ CurrentInsertionPointIndex ] . Location ;
251254 editor . GetService < TextEditor > ( ) . ScrollTo ( location . Line , location . Column ) ;
252255 SetGroupBoxPosition ( ) ;
253256 }
254257
255258 void SetGroupBoxPosition ( )
256259 {
257- var boxPosition = GetLinePosition ( CurrentInsertionPoint ) + new Vector ( editor . TextView . ActualWidth * 0.6 - 5 , - groupBox . ActualHeight / 2.0 ) ;
260+ var boxPosition = GetLinePosition ( CurrentInsertionPointIndex ) + new Vector ( editor . TextView . ActualWidth * 0.6 - 5 , - groupBox . ActualHeight / 2.0 ) ;
258261 Canvas . SetTop ( groupBox , boxPosition . Y ) ;
259262 Canvas . SetLeft ( groupBox , boxPosition . X ) ;
260263 }
@@ -267,7 +270,7 @@ void Cancel(object sender, ExecutedRoutedEventArgs e)
267270 void FireExited ( bool success )
268271 {
269272 if ( Exited != null ) {
270- Exited ( this , new InsertionCursorEventArgs ( insertionPoints [ CurrentInsertionPoint ] , success ) ) ;
273+ Exited ( this , new InsertionCursorEventArgs ( insertionPoints [ CurrentInsertionPointIndex ] , success ) ) ;
271274 }
272275 }
273276
0 commit comments