Share via


InkOverlaySelectionResizingEventArgs.NewPixelRect Property

InkOverlaySelectionResizingEventArgs.NewPixelRect Property

Gets the bounding rectangle of the selection after the SelectionResizing event, as a Rectangle Leave Site structure.

Definition

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

Property Value

System.Drawing.Rectangle. The size of the selection after the SelectionResizing event.

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

Remarks

The NewPixelRect property provides specific information about the InkOverlaySelectionResizingEventArgs event.

Note: This Rectangle Leave Site structure is specified in client window coordinates, which allows for scenarios such as maintaining the aspect ratio when resizing.

Examples

[C#]

This C# example creates an event handler, theInkOverlay_SelectionResizing, that affects a selected Strokes collection of an InkOverlay, theInkOverlay. If the selection is resized so that any of it extends beyond the boundaries of the control, the event handler turns the selection red. (Note that the handler sets the Color property to red for each Stroke in the Strokes collection, so it will be red even if the strokes are resized back within the boundaries.)

using Microsoft.Ink;
//...
  theInkOverlay.SelectionResizing += new InkOverlaySelectionResizingEventHandler(theInkOverlay_SelectionResizing);
//...
  private void theInkOverlay_SelectionResizing(object sender, InkOverlaySelectionResizingEventArgs e)
  {
      //Check the bounds of the resizing selection to see if it goes outside.
      if (e.NewPixelRect.Left < 0 || e.NewPixelRect.Right > ClientRectangle.Width ||
          e.NewPixelRect.Top < 0 || e.NewPixelRect.Bottom > ClientRectangle.Height)
      {
          //If too big change the color of the strokes to red.
          foreach (Stroke stroke in theInkOverlay.Selection)
          {
              stroke.DrawingAttributes.Color = Color.Red;
          }
     }

  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example creates an event handler, theInkOverlay_SelectionResizing, that affects a selected Strokes collection of an InkOverlay, theInkOverlay. If the selection is resized so that any of it extends beyond the boundaries of the control, the event handler turns the selection red. (Note that the handler sets the Color property to red for each Stroke in the Strokes collection, so it will be red even if the strokes are resized back within the boundaries.)

Imports Microsoft.Ink
'...
    Private WithEvents theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_SelectionResizing(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionResizingEventArgs) _
    Handles theInkOverlay.SelectionResizing
        ' Check the bounds of the resizing selection to see if it goes outside.
        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
            'If too big change the color of the strokes to red.
            For Each selectedStroke In theInkOverlay.Selection
                selectedStroke.DrawingAttributes.Color = Color.Red
            Next
        End If
    End Sub
'...

See Also