Condividi tramite


InkOverlay.SelectionResized Event

InkOverlay.SelectionResized Event

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

Definition

Visual Basic .NET Public Event SelectionResized As InkOverlaySelectionResizedEventHandler
C# public event InkOverlaySelectionResizedEventHandler SelectionResized;
Managed C++ public: __event InkOverlaySelectionResizedEventHandler SelectionResized;

Remarks

The event handler receives an argument of type InkOverlaySelectionResizedEventArgs that contains data about this event.

When you create an InkOverlaySelectionResizedEventHandler delegate, you identify the method that will handle 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 collection of strokes that has been moved, use the OldSelectionBoundingRect of the InkOverlaySelectionResizedEventArgs object. To get the new bounding rectangle, call the Selection.GetBoundingBox method.

Examples

[C#]

This C# example demonstrates how to affect an InkOverlay's selection after it has been resized. If it has been resized so that either dimension is smaller than 500 ink units, then it restores it to its previous size.

using Microsoft.Ink;
//...
  theInkOverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(theInkOverlay_SelectionMoved);
//...
  private void theInkOverlay_SelectionMoved(object sender, InkOverlaySelectionMovedEventArgs e)
  {
       Rectangle newBounds = theInkOverlay.Selection.GetBoundingBox();

       // Check if we are too small
       if (newBounds.Height < 500 || newBounds.Width < 500)
       {
           // Resize to back to original rectangle
           theInkOverlay.Selection.ScaleToRectangle(e.OldSelectionBoundingRect);

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

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates how to affect an InkOverlay's selection after it has been resized. If it has been resized so that either dimension is smaller than 500 ink units, then it restores it to its previous size.

Imports Microsoft.Ink
'...
    Private WithEvents theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_SelectionResized(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionResizedEventArgs) _
    Handles theInkOverlay.SelectionResized
        Dim newBounds As Rectangle = theInkOverlay.Selection.GetBoundingBox()

        ' Check if we are too small
        If newBounds.Height < 500 Or newBounds.Width < 500 Then
            ' Resize to back to original rectangle
            theInkOverlay.Selection.ScaleToRectangle(e.OldSelectionBoundingRect)

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

See Also