Share via


InkOverlaySelectionMovedEventArgs.OldSelectionBoundingRect Property

InkOverlaySelectionMovedEventArgs.OldSelectionBoundingRect Property

Gets the bounding rectangle of the selected Strokes collection as it existed before the SelectionMoved event fired.

Definition

Visual Basic .NET Public ReadOnly Property OldSelectionBoundingRect As Rectangle
C# public Rectangle OldSelectionBoundingRect { get; }
Managed C++ public: __property Rectangle* get_OldSelectionBoundingRect();

Property Value

System.Drawing.Rectangle. The bounding rectangle of the selected Strokes collection as it existed before the SelectionMoved event fired.

This property is read-only. This property has no default value.

Remarks

The OldSelectionBoundingRect property gets the position that the selected Strokes collection was located in before the SelectionMoved event fired.

Examples

[C#]

This C# example creates an event handler, theInkOverlay_SelectionMoved, that affects a selection after it has been moved. If the selected Strokes collection has been moved so that any part of the collection is positioned outside the left or top boundaries of the InkOverlay object, theInkOverlay, the event handler moves the selection back to its original position.

using Microsoft.Ink;
//...
  theInkOverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(theInkOverlay_SelectionMoved);
//...
  private void theInkOverlay_SelectionMoved(object sender, InkOverlaySelectionMovedEventArgs e)
  {
       Rectangle newBounds = theInkOverlay.Selection.GetBoundingBox();
       // Check if the selection is positioned outside the left or top boundaries
       // of the window.
       if (newBounds.Left < 0 || newBounds.Top < 0)
       {
           // Move to back to original location
           theInkOverlay.Selection.Move(e.OldSelectionBoundingRect.Left - newBounds.Left,
               e.OldSelectionBoundingRect.Top - newBounds.Top);

           // Trick to insure that selection handles are updated
           theInkOverlay.Selection = theInkOverlay.Selection;
       }
   }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example creates an event handler, theInkOverlay_SelectionMoved, that affects a selection after it has been moved. If the selected Strokes collection has been moved so that any part of the collection is positioned outside the left or top boundaries of the InkOverlay object, theInkOverlay, the event handler moves the selection back to its original position.

Imports Microsoft.Ink
'...
    Private WithEvents theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_SelectionMoved(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionMovedEventArgs) Handles theInkOverlay.SelectionMoved
        Dim newBounds As Rectangle = theInkOverlay.Selection.GetBoundingBox()
        'Check if if the selection is positioned outside the left or top boundaries
        'of the window.
        If newBounds.Left < 0 Or newBounds.Top < 0 Then
            'Move to back to original location
            theInkOverlay.Selection.Move(e.OldSelectionBoundingRect.Left - newBounds.Left, _
                e.OldSelectionBoundingRect.Top - newBounds.Top)

            'Trick to insure that selection handles are updated
            theInkOverlay.Selection = theInkOverlay.Selection
        End If
    End Sub
'...

See Also