diff --git a/app/DD-Record-Organizer/frmLevel_Designer.vb b/app/DD-Record-Organizer/frmLevel_Designer.vb index b4da61e..251ccd1 100644 --- a/app/DD-Record-Organizer/frmLevel_Designer.vb +++ b/app/DD-Record-Organizer/frmLevel_Designer.vb @@ -571,12 +571,32 @@ Mouse_Down = False End Sub - Private Sub Control_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp + Private Sub Control_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseUp ' The button was released, so we're going back to Static mode. If Mouse_Moving = True Then Mouse_Moving = False 'end_location = e.Location DesignerCtrlBuilder.EndLocation = e.Location + Dim currentPosition As Point = DesignerCtrlBuilder.CurrentControl.Location + + ' Das Control sollte nicht außerhalb des Panels geschoben werden (Koordinaten kleiner 0) + If CurrentPosition.X < 0 Then + DesignerCtrlBuilder.CurrentControl.Location = New Point(0, DesignerCtrlBuilder.CurrentControl.Location.Y) + End If + + If CurrentPosition.Y < 0 Then + DesignerCtrlBuilder.CurrentControl.Location = New Point(DesignerCtrlBuilder.CurrentControl.Location.X, 0) + End If + + ' Ebenso nicht über die Größe des Panels (X-Achse) + If CurrentPosition.X > pnlDesigner.Width Then + DesignerCtrlBuilder.CurrentControl.Location = New Point(pnlDesigner.Width - DesignerCtrlBuilder.CurrentControl.Width, DesignerCtrlBuilder.CurrentControl.Location.Y) + End If + + ' Ebenso nicht über die Größe des Panels (Y-Achse) + If CurrentPosition.Y > pnlDesigner.Height Then + DesignerCtrlBuilder.CurrentControl.Location = New Point(DesignerCtrlBuilder.CurrentControl.Location.X, pnlDesigner.Height - DesignerCtrlBuilder.CurrentControl.Height) + End If 'frmTool_ControlProperties.Instance.UpdateControlLocation(CtrlBuilder.CurrentControl) UpdateControlLocation(DesignerCtrlBuilder.CurrentControl)