void nameImage_MouseUp(object sender, MouseEventArgs e) { curentMoveLabel = null; mousePosition = null; Label curentLabel = (Label)sender; PictureBox curentPic = isCheckAreaEntering(curentLabel); if (curentPic != null) { Rectangle rectLabel = curentLabel.Bounds; Rectangle rectPic = curentPic.Bounds; rectLabel.X = rectPic.X + 1; rectLabel.Y = rectPic.Y + rectPic.Height + 1; curentLabel.Bounds = rectLabel; PuzzleBox puzzleBox = new PuzzleBox(); puzzleBox.namePic = curentLabel.Text; puzzleBox.pictures = curentPic; puzzleBox.tag = curentPic.Tag; addedPuzzleToLis(puzzleBox); } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (curentMoveLabel != null) { if (mousePosition == null) { mousePosition = new MousePosition(); mousePosition.X = e.Location.X; mousePosition.Y = e.Location.Y; } Point startMovePoint = new Point(mousePosition.X , mousePosition.Y); Point newPointControl = new Point(); newPointControl.X = e.X - startMovePoint.X; newPointControl.Y = e.Y - startMovePoint.Y; Point controlLocation = curentMoveLabel.Location; controlLocation.X += newPointControl.X; controlLocation.Y += newPointControl.Y; curentMoveLabel.Location = controlLocation; } }