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(); }
public void Construct(List <Puzzle> puzzles) { puzzles.Sort(); foreach (Puzzle puzzle in puzzles) { Puzzle automatedPuzzle = new Puzzle(); automatedPuzzle.Location = new System.Drawing.Point(puzzle.CoordinateX + form.Width - _image.Width - distanseBetweenControls, puzzle.CoordinateY + distanseBetweenControls); automatedPuzzle.Size = new System.Drawing.Size(puzzle.Width, puzzle.Height); automatedPuzzle.Width = puzzle.Width; automatedPuzzle.Height = puzzle.Height; automatedPuzzle.Image = puzzle.Image; automatedPuzzle.BorderStyle = BorderStyle.Fixed3D; automatedPuzzle.Click += new EventHandler(automatedPuzzle_Click); if (puzzle.topPuzzle != null && puzzle.topPuzzle.Image != null) { automatedPuzzle.topPuzzle = SetPuzzle(automatedPuzzle.topPuzzle); automatedPuzzle.topPuzzle.Image = puzzle.topPuzzle.Image; smallPuzzles.SetTopPuzzleLocation(automatedPuzzle); } if (puzzle.rightPuzzle != null && puzzle.rightPuzzle.Image != null) { automatedPuzzle.rightPuzzle = SetPuzzle(automatedPuzzle.rightPuzzle); automatedPuzzle.rightPuzzle.Image = puzzle.rightPuzzle.Image; smallPuzzles.SetRightPuzzleLocation(automatedPuzzle); } form.Controls.Add(automatedPuzzle); automatedConstructPuzzlesList.Add(automatedPuzzle); _image.SendToBack(); } }
public void SetSmallPuzzlesLocationTest() { SetSmallPuzzlesLocation setSmallPuzzles = new SetSmallPuzzlesLocation(); puzzles[0].rightPuzzle = new Puzzle(); setSmallPuzzles.SetRightPuzzleLocation(puzzles[0]); Puzzle rightPuzzle = puzzles[0].rightPuzzle; Assert.AreEqual(rightPuzzle.Location.X, puzzles[0].Location.X + puzzles[0].Size.Width); }
private void SetRightPuzzle(Puzzle puzzle) { puzzle.rightPuzzle = new Puzzle(); if (puzzle.CoordinateX + puzzle.Width < _picture.Width - 3) { puzzle.rightPuzzle.Size = new Size(10, 10); setSmallPuzzle.SetRightPuzzleLocation(puzzle); puzzle.rightPuzzle.Image = GetPartOfImage(new Rectangle(puzzle.CoordinateX + puzzle.Width, puzzle.CoordinateY + puzzle.Height / 2 - 5, 10, 10)); _form.Controls.Add(puzzle.rightPuzzle); } }
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); } }