void puzzle_GiveFeedback(object sender, GiveFeedbackEventArgs e) { Puzzle puzzle = (Puzzle)sender; Point relativePoint = _form.PointToClient(Cursor.Position); puzzle.Location = new Point(Cursor.Position.X - differnceBetweenCursorAndPuzzleX, Cursor.Position.Y - differnceBetweenCursorAndPuzzleY); puzzle.topPuzzle.AllowDrop = true; smallPuzzles.SetTopPuzzleLocation(puzzle); smallPuzzles.SetBottomPuzzleLocation(puzzle); smallPuzzles.SetRightPuzzleLocation(puzzle); smallPuzzles.SetLeftPuzzleLocation(puzzle); puzzle.Refresh(); }
private void SetSmallPuzzles(Puzzle puzzle) { if (puzzle.topPuzzle != null) { smallPuzzles.SetTopPuzzleLocation(puzzle); } if (puzzle.rightPuzzle != null) { smallPuzzles.SetRightPuzzleLocation(puzzle); } if (puzzle.bottomPuzzle != null) { smallPuzzles.SetBottomPuzzleLocation(puzzle); } if (puzzle.leftPuzzle != null) { smallPuzzles.SetLeftPuzzleLocation(puzzle); } }
private void SetBottomPuzzle(Puzzle puzzle) { var controls = _form.Controls.Cast <Control>(); List <Puzzle> intersectedPuzzles = controls .Where(x => x.Bounds.IntersectsWith(puzzle.Bounds) && x != puzzle && x.GetType() == typeof(Puzzle)).Cast <Puzzle>() .ToList(); puzzle.bottomPuzzle = new List <Puzzle>(); if (intersectedPuzzles.Count != 0) { for (int i = 0; i < intersectedPuzzles.Count; i++) { Puzzle bottomPuzzle = new Puzzle(); bottomPuzzle.Size = new Size(10, 10); bottomPuzzle.CoordinateX = intersectedPuzzles[i].Location.X - puzzle.Location.X; bottomPuzzle.CoordinateY = intersectedPuzzles[i].Location.Y; setSmallPuzzle.SetBottomPuzzleLocation(puzzle); _form.Controls.Add(bottomPuzzle); puzzle.bottomPuzzle.Add(bottomPuzzle); } } }