Share via


InkOverlay.SelectionMoved Event

Occurs when the position of the current selection has changed, such as through alterations to the user interface, cut-and-paste procedures, or the Selection property.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Event SelectionMoved As InkOverlaySelectionMovedEventHandler
'Usage
Dim instance As InkOverlay 
Dim handler As InkOverlaySelectionMovedEventHandler 

AddHandler instance.SelectionMoved, handler
public event InkOverlaySelectionMovedEventHandler SelectionMoved
public:
 event InkOverlaySelectionMovedEventHandler^ SelectionMoved {
    void add (InkOverlaySelectionMovedEventHandler^ value);
    void remove (InkOverlaySelectionMovedEventHandler^ value);
}
JScript does not support events.

Remarks

The event handler receives an argument of type InkOverlaySelectionMovedEventArgs containing data about this event.

When you create an InkOverlaySelectionMovedEventHandler delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For performance reasons, the default event interest is off but is turned on automatically if you add an event handler.

To get the old bounding rectangle of the Strokes collection that has been moved, use the OldSelectionBoundingRect of the InkOverlaySelectionMovedEventArgs object. To get the new bounding rectangle, call the GetBoundingBox method for the Strokes collection in the InkOverlay object's Selection property.

Examples

In this example, an SelectionMoved event handler examines a selection after it has been moved. If the selected Strokes collection is moved so that any of the selection is off the left or top side of the window, then the selection is moved back to its original position.

Private Sub mInkObject_SelectionMoved(ByVal sender As Object, ByVal e As InkOverlaySelectionMovedEventArgs)
    ' mInkObject can be InkOverlay or InkPicture 
    Dim newBounds As Rectangle = mInkObject.Selection.GetBoundingBox()
    ' Check if we have gone off the left or top sides of the window. 
    If (newBounds.Left < 0 Or newBounds.Top < 0) Then 
        ' Move to back to original spot
        mInkObject.Selection.Move(e.OldSelectionBoundingRect.Left - newBounds.Left, _
            e.OldSelectionBoundingRect.Top - newBounds.Top)
        ' Trick to insure that selection handles are updated
        mInkObject.Selection = mInkObject.Selection
    End If 
End Sub
private void mInkObject_SelectionMoved(object sender, InkOverlaySelectionMovedEventArgs e)
{
    // mInkObject can be InkOverlay or InkPicture
    Rectangle newBounds = mInkObject.Selection.GetBoundingBox();

    // Check if we have gone off the left or top sides of the window. 
    if (newBounds.Left < 0 || newBounds.Top < 0)
    {
        // Move to back to original spot
        mInkObject.Selection.Move(e.OldSelectionBoundingRect.Left - newBounds.Left,
            e.OldSelectionBoundingRect.Top - newBounds.Top);

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

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkOverlay Class

InkOverlay Members

Microsoft.Ink Namespace

InkOverlay.Selection

InkOverlaySelectionMovedEventArgs

InkOverlay.SelectionMoving