1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
Public Class UserControl1
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
PointThickness = New Thickness(ln.X1 + (ln.X2 - ln.X1) / 2,
ln.Y1 + (ln.Y2 - ln.Y2) / 2,
ln.Margin.Right,
ln.Margin.Bottom)
End Sub
Public Property PointThickness As Thickness
Get
Return GetValue(PointThicknessProperty)
End Get
Set(ByVal value As Thickness)
SetValue(PointThicknessProperty, value)
End Set
End Property
Public Shared ReadOnly PointThicknessProperty As DependencyProperty = _
DependencyProperty.Register("PointThickness", _
GetType(Thickness),
GetType(UserControl1), _
New FrameworkPropertyMetadata(Nothing))
Private Sub UserControl1_LayoutUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LayoutUpdated
PointThickness = New Thickness(ln.X1 + (ln.X2 - ln.X1) / 2,
ln.Y1 + (ln.Y2 - ln.Y2) / 2,
ln.Margin.Right,
ln.Margin.Bottom)
End Sub
Private ptDown As Point
Private isDown As Boolean
Private Sub Grid_PreviewMouseLeftButtonDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If e.LeftButton = MouseButtonState.Pressed Then
ptDown = e.GetPosition(Me.grd)
isDown = True
Me.grd.CaptureMouse()
End If
End Sub
Private Sub Grid_PreviewMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
If isDown And e.LeftButton = MouseButtonState.Pressed Then
Dim pt As Point = e.GetPosition(Me.grd)
ln.X1 += pt.X - ptDown.X
ln.Y1 += pt.Y - ptDown.Y
ln.X2 += pt.X - ptDown.X
ln.Y2 += pt.Y - ptDown.Y
ptDown = pt
End If
End Sub
Private Sub Grid_PreviewMouseRightButtonDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If e.RightButton = MouseButtonState.Pressed Then
isDown = False
ptDown = New Point
Me.grd.ReleaseMouseCapture()
End If
End Sub
End Class |
Partager