InkCollectorMouseDownEventHandler Delegate
Represents the method that handles the MouseDown event of an InkCollector object.
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
'Declaration Public Delegate Sub InkCollectorMouseDownEventHandler ( _ sender As Object, _ e As CancelMouseEventArgs _ ) 'Usage Dim instance As New InkCollectorMouseDownEventHandler(AddressOf HandlerMethod)
Parameters
- sender
- Type: System.Object
The source InkCollector object of this event.
- e
- Type: Microsoft.Ink.CancelMouseEventArgs
The CancelMouseEventArgs object that contains the event data.
When you create an InkCollectorMouseDownEventHandler 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 in managed code if you add an event handler.
To improve real-time ink performance, hide the mouse cursor while inking. To do so, hide the mouse cursor in the MouseDown event handler, and show the mouse cursor in the MouseUp event handler.
In this example, when the MouseDown event fires, a check is made to see if EditingMode is set to Select. If so, the HitTestSelection method is called to determine which part of the selection (if any) has been hit. If the hit occurs on any of the four main compass directions, as specified by the SelectionHitResult enumeration, the stroke objects that are selected are changed to a different color.
Private Sub mInkObject_MouseDown(ByVal sender As Object, ByVal e As CancelMouseEventArgs) If InkOverlayEditingMode.Select = mInkObject.EditingMode Then Select Case mInkObject.HitTestSelection(e.X, e.Y) Case SelectionHitResult.North ChangeSelectionColor(Color.Green) Case SelectionHitResult.East ChangeSelectionColor(Color.Red) Case SelectionHitResult.South ChangeSelectionColor(Color.Purple) Case SelectionHitResult.West ChangeSelectionColor(Color.Blue) End Select End If End Sub Private Sub ChangeSelectionColor(ByVal color As Color) Dim DA As DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone() DA.Color = color mInkObject.Selection.ModifyDrawingAttributes(DA) Using G As Graphics = CreateGraphics() ' Get the bounding box of the selection. The default is ' to include the width of the strokes in the calculation. ' The returned rectangle is measured in ink units. Dim rInkUnits As Rectangle = mInkObject.Selection.GetBoundingBox() ' In selection mode, the selected strokes are drawn inflated ' GetBoundingBox() does not take this into account ' Rectangle rInkUnits is inflated to compensate rInkUnits.Inflate(53, 53) Dim topLeft As Point = rInkUnits.Location Dim bottomRight As Point = rInkUnits.Location + rInkUnits.Size ' get a Renderer object to make the conversion Dim R As Renderer = New Renderer() ' convert the points to pixels R.InkSpaceToPixel(G, topLeft) R.InkSpaceToPixel(G, bottomRight) ' create a rectangle that is in pixels Dim rPixelUnits As Rectangle = _ New Rectangle(topLeft, New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y)) ' Redraw the strokes mInkObject.Draw(rPixelUnits) End Using End Sub
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: