Compartir a través de


InkPicture.SelectionMoving Event

Occurs when the position of the current selection is about to change, 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 SelectionMoving As InkOverlaySelectionMovingEventHandler
'Usage
Dim instance As InkPicture
Dim handler As InkOverlaySelectionMovingEventHandler

AddHandler instance.SelectionMoving, handler
public event InkOverlaySelectionMovingEventHandler SelectionMoving
public:
event InkOverlaySelectionMovingEventHandler^ SelectionMoving {
    void add (InkOverlaySelectionMovingEventHandler^ value);
    void remove (InkOverlaySelectionMovingEventHandler^ value);
}
/** @event */
public void add_SelectionMoving (InkOverlaySelectionMovingEventHandler value)

/** @event */
public void remove_SelectionMoving (InkOverlaySelectionMovingEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

Remarks

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

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

Example

This C# example is a SelectionMoving event handler that affects a selection of an InkPicture control before the selection has been moved. If the selection will be moved so that any of it is outside the bounds of the window, the event handler turns the selection red. Note that the event handler sets the Stroke objects' Color to red.

[C#]

using Microsoft.Ink;
//...
  theInkPicture.SelectionMoved += new InkOverlaySelectionMovedEventHandler(theInkPicture_SelectionMoved);
//...
  private void theInkPicture_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 theInkPicture.Selection)
          {
              stroke.DrawingAttributes.Color = Color.Red;
          }
          // Update the color
          Invalidate(e.NewPixelRect);
     }

  }
//...

This Microsoft® Visual Basic® .NET example is a SelectionMoving event handler that affects a selection of an InkPicture control before the selection has been moved. If the selection will be moved so that any of it is outside the bounds of the window, the event handler turns the selection red. Note that the event handler sets the Stroke objects' Color to red.

[Visual Basic]

Imports Microsoft.Ink
'...
    Private WithEvents theInkPicture As InkPicture
'...
    Private Sub theInkPicture_SelectionMoving(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlaySelectionMovingEventArgs) _
    Handles theInkPicture.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 theInkPicture.Selection
                selectedStroke.DrawingAttributes.Color = Color.Red
            Next

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

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkPicture Class
InkPicture Members
Microsoft.Ink Namespace
InkOverlaySelectionMovedEventArgs
InkPicture.Selection
InkPicture.SelectionMoved