Compartilhar via


InkOverlay.SelectionResizing Event

InkOverlay.SelectionResizing Event

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

Definition

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

Remarks

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

When you create an InkOverlaySelectionResizingEventHandler 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.

Examples

[C#]

This C# example demonstrates how to affect a selection of an InkOverlay before it has been resized. If it will be resized so that any of it is off of the control, then it turns the selection red. (Note that it sets the strokes' actual Color to red.)

using Microsoft.Ink;
//...
  theInkOverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(theInkOverlay_SelectionMoved);
//...
  private void theInkOverlay_SelectionMoving(object sender, InkOverlaySelectionMovingEventArgs e)
  {
      if (e.NewPixelRect.Left < 0 || e.NewPixelRect.Right > ClientRectangle.Width ||
          e.NewPixelRect.Top < 0 || e.NewPixelRect.Bottom > ClientRectangle.Height)
      {
          foreach (Stroke stroke in theInkOverlay.Selection)
          {
              stroke.DrawingAttributes.Color = Color.Red;
          }
          // Update the color
          Invalidate(e.NewPixelRect);
     }

  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates how to affect a selection of an InkOverlay before it has been resized. If it will be resized so that any of it is off of the control, then it turns the selection red. (Note that it sets the strokes' actual Color to red.)

Imports Microsoft.Ink
'...
    Private WithEvents theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_SelectionMoving(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionMovingEventArgs) _
    Handles theInkOverlay.SelectionMoving
        If e.NewPixelRect.Left < 0 Or e.NewPixelRect.Right > ClientRectangle.Width Or _
                e.NewPixelRect.Top < 0 Or e.NewPixelRect.Bottom > ClientRectangle.Height Then
            Dim selectedStroke As Stroke
            For Each selectedStroke In theInkOverlay.Selection
                selectedStroke.DrawingAttributes.Color = Color.Red
            Next

          ' Update the color
          Invalidate(e.NewPixelRect)
        End If
    End Sub
'...

See Also