Compartir a través de


InkPicture.SelectionResized Event

InkPicture.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 InkPicture'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;
//...
  theInkPicture.SelectionMoved += new InkOverlaySelectionMovedEventHandler(theInkPicture_SelectionMoved);
//...
  private void theInkPicture_SelectionMoved(object sender, InkOverlaySelectionMovedEventArgs e)
  {
       Rectangle newBounds = theInkPicture.Selection.GetBoundingBox();

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

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

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates how to affect an InkPicture'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 theInkPicture As InkPicture
'...
    Private Sub theInkPicture_SelectionResized(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionResizedEventArgs) _
    Handles theInkPicture.SelectionResized
        Dim newBounds As Rectangle = theInkPicture.Selection.GetBoundingBox()

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

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

See Also