Example #1
0
        private void InitVideoPuzzles(Stream streamSource)
        {
            //create imedia source from the stream
            this.VideoSource = JigsawHelper.CreateVideoSource(streamSource);

            //create image pieces
            IList <IJigsawPiece> pieces = JigsawPieceFactory.CreateVideoPuzzelPieces(this.VideoSource, this._columns,
                                                                                     this._rows, this.PieceSize, this.PieceType);

            //scramble the pieces
            this.Pieces = JigsawHelper.ScramblePieces(pieces, this._rows, this._columns);

            //insert into canvas
            foreach (JigsawPieceBase piece in this.Pieces)
            {
                this.InsertPiece(this.Window.Canvas, piece);
            }
        }
        public void TestConvertPointWithValidStrings()
        {
            const int rows       = 4;
            const int columns    = 4;
            var       imaeSource = new BitmapImage();
            var       pieces     = new List <IJigsawPiece>();

            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < columns; col++)
                {
                    IJigsawPiece jigsawPiece = JigsawPieceFactory.CreateImagePuzzelPiece(imaeSource, col, row, 200, PieceType.SimpleBezier);
                    pieces.Add(jigsawPiece);
                }
            }
            var scrambledPieces = JigsawHelper.ScramblePieces(pieces, rows, columns);

            foreach (var jigsawPiece in scrambledPieces)
            {
                var tempModel = BezierCurveHelper.FindModel(jigsawPiece.CurrentColumn, jigsawPiece.CurrentRow);
                Assert.AreEqual(jigsawPiece.Position, tempModel.Position);
            }
        }