现在使用鼠标右键拖动的坐标该变量模拟计算出来的摆动角度
在鼠标移动的事件中检测右键是否按下,若是,则根据移动的坐标距离改变两个lable的值,这样即实现鼠标拖动风铃摆动了
Private Sub MainWindow_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Me.MouseMove
If right_down = 1 Then
position = Mouse.GetPosition(Me)
If position <> start_position Then
mouse_moved = 1
tmp_position.X = last_position.X + position.X - start_position.X
tmp_position.Y = last_position.Y - position.Y + start_position.Y
If tmp_position.X / 8 < 25 And tmp_position.X / 8 > -25 Then
stop_position.X = tmp_position.X
End If
If tmp_position.Y / 5 < 25 And tmp_position.Y / 5 > -25 Then
stop_position.Y = tmp_position.Y
End If
angle_x.Content = stop_position.X / 8
angle_y.Content = stop_position.Y / 5
swing_angle = Math.Sqrt(angle_x.Content ^ 2 + angle_y.Content ^ 2)