'Events to selection a portion of image
Private Sub dragHelper_DragDelta(sender As Object, e As C1DragDeltaEventArgs)
Dim pos = e.GetPosition(image)
pos = New Point(Math.Max(0, Math.Min(pos.X, bitmap.PixelWidth)),
Math.Max(0, Math.Min(pos.Y, bitmap.PixelHeight)))
selection = New Rect(Math.Round(Math.Min(start.X, pos.X)),
Math.Round(Math.Min(start.Y, pos.Y)),
Math.Round(Math.Abs(start.X - pos.X)),
Math.Round(Math.Abs(start.Y - pos.Y)))
End Sub
Private Sub image_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) _
Handles image.MouseLeftButtonDown
MyBase.OnMouseLeftButtonDown(e)
Dim pos = e.GetPosition(image)
start = New Point(Math.Max(0, Math.Min(pos.X, bitmap.PixelWidth)),
Math.Max(0, Math.Min(pos.Y, bitmap.PixelHeight)))
End Sub
Private Sub image_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) _
Handles image.MouseLeftButtonUp
MyBase.OnMouseLeftButtonUp(e)
Dim pt = e.GetPosition(image)
If Math.Abs(pt.X - start.X) < 4 AndAlso Math.Abs(pt.Y - start.Y) < 4 Then
selection = New Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)
End If
End Sub