Example #1
0
        private void MovePieces(IJigsawPiece original, IJigsawPiece target)
        {
            if ((original != null) && (target != null))
            {
                this.MovePiece(target, original.Position);
                this.MovePiece(original, target.Position);
                //swap position
                var tempOriginPoint = new Point(original.Position.X, original.Position.Y);
                original.Position = new Point(target.Position.X, target.Position.Y);
                target.Position   = tempOriginPoint;
                //Swap column and row numbers
                int targetX = target.CurrentColumn;
                int targetY = target.CurrentRow;
                target.CurrentColumn   = original.CurrentColumn;
                target.CurrentRow      = original.CurrentRow;
                original.CurrentColumn = targetX;
                original.CurrentRow    = targetY;

                //Adjust Z Index
                int zIndex = (int)original.GetValue(Panel.ZIndexProperty);
                original.SetValue(Panel.ZIndexProperty, zIndex + 1);
                if (this.CheckPieces())
                {
                    MessageBox.Show("You have successfully finished this puzzel", "Congratulations!");
                    this.ShowPicture();
                }
            }
        }
Example #2
0
        private void MovePieces(IJigsawPiece original, IJigsawPiece target)
        {
            if ((original != null) && (target != null))
            {
                this.MovePiece(target, original.Position);
                this.MovePiece(original, target.Position);
                //swap position
                var tempOriginPoint = new Point(original.Position.X, original.Position.Y);
                original.Position = new Point(target.Position.X, target.Position.Y);
                target.Position = tempOriginPoint;
                //Swap column and row numbers
                int targetX = target.CurrentColumn;
                int targetY = target.CurrentRow;
                target.CurrentColumn = original.CurrentColumn;
                target.CurrentRow = original.CurrentRow;
                original.CurrentColumn = targetX;
                original.CurrentRow = targetY;

                //Adjust Z Index
                int zIndex = (int)original.GetValue(Panel.ZIndexProperty);
                original.SetValue(Panel.ZIndexProperty, zIndex + 1);
                if (this.CheckPieces())
                {
                    MessageBox.Show("You have successfully finished this puzzel", "Congratulations!");
                    this.ShowPicture();
                }
            }
        }