// generuje nahodne strany pre zadany kusok, nie tvary, iba ci bude zubok dovnutra alebo von, zvyslo, vodorovne
        private static PieceArrangement[] GeneratePiecesArrangement(Size gridDimensions) //gridDimensions rozmery pre pocet kuskov v riadkoch a stlpcoch
        {
            int width  = gridDimensions.Width;
            int height = gridDimensions.Height;

            PieceArrangement[] arrangement = new PieceArrangement[width * height];
            Random             rnd         = new Random();

            int index;

            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    index = j * width + i; //pole cislujeme od 0 preto i namiesto i+1, vytvarame poziciu indexu 2d pola v 1d poli
                    arrangement[index] = new PieceArrangement();

                    #region TopSide
                    if (j == 0)
                    {
                        arrangement[index].TopSide = "none";
                    }
                    else if (arrangement[index - width].BottomSide == "in")
                    {
                        arrangement[index].TopSide = "out";
                    }
                    else
                    {
                        arrangement[index].TopSide = "in";
                    }
                    #endregion

                    #region LeftSide
                    if (i == 0)
                    {
                        arrangement[index].LeftSide = "none";
                    }
                    else if (arrangement[index - 1].RightSide == "in")
                    {
                        arrangement[index].LeftSide = "out";
                    }
                    else
                    {
                        arrangement[index].LeftSide = "in";
                    }
                    #endregion

                    #region BottomSide
                    if (j == (height - 1))
                    {
                        arrangement[index].BottomSide = "none";
                    }
                    else if (rnd.NextDouble() >= 0.5)
                    {
                        arrangement[index].BottomSide = "out";
                    }
                    else
                    {
                        arrangement[index].BottomSide = "in";
                    }
                    #endregion

                    #region RightSide
                    if (i == (width - 1))
                    {
                        arrangement[index].RightSide = "none";
                    }
                    else if (rnd.NextDouble() >= 0.5)
                    {
                        arrangement[index].RightSide = "out";
                    }
                    else
                    {
                        arrangement[index].RightSide = "in";
                    }
                    #endregion
                }
            }

            return(arrangement);
        }
        // Vytvori spojenu krivku urcujucu tvar puzzle za pomoci metod z triedy PuzzleBezierovaKrivka a nastaveni hran z PieceArrangement
        private static GraphicsPath CreatePuzzleShapePath(int pieceSurroundingSize,
                                                          Size pieceDimensions,
                                                          PieceArrangement arrang)
        {
            GraphicsPath bezierpath = new GraphicsPath();

            int   locationx = pieceSurroundingSize; //offset pre posun vyrezu
            int   locationy = pieceSurroundingSize;
            int   pieceWidth = pieceDimensions.Width;
            int   pieceHeight = pieceDimensions.Height;
            Point p1, p2, p3, p4;

            p1 = new Point(locationx, locationy);
            p2 = new Point(locationx + pieceWidth, locationy);
            p3 = new Point(locationx + pieceWidth, locationy + pieceHeight);
            p4 = new Point(locationx, locationy + pieceHeight);


            #region TopCurve p1 --> p2
            switch (arrang.TopSide)
            {
            case "none":
                bezierpath.AddLine(p1, p2);
                break;

            case "in":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.HorizontalPoints(p1, p2, true));
                break;

            case "out":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.HorizontalPoints(p1, p2, false));
                break;

            default:
                break;
            }
            #endregion

            #region RightCurve p2 --> p3
            switch (arrang.RightSide)
            {
            case "none":
                bezierpath.AddLine(p2, p3);
                break;

            case "in":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.VerticalPoints(p2, p3, false));
                break;

            case "out":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.VerticalPoints(p2, p3, true));
                break;

            default:
                break;
            }
            #endregion

            #region BottomCurve p3 --> p4
            switch (arrang.BottomSide)
            {
            case "none":
                bezierpath.AddLine(p3, p4);
                break;

            case "in":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.HorizontalPoints(p3, p4, false));
                break;

            case "out":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.HorizontalPoints(p3, p4, true));
                break;

            default:
                break;
            }
            #endregion

            #region LeftCurve p4 --> p1
            switch (arrang.LeftSide)
            {
            case "none":
                bezierpath.AddLine(p4, p1);
                break;

            case "in":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.VerticalPoints(p4, p1, true));
                break;

            case "out":
                bezierpath.AddBeziers(PuzzleBezierovaKrivka.VerticalPoints(p4, p1, false));
                break;

            default:
                break;
            }
            #endregion


            //--PRIKLAD-----
            //Point[] bezierPoints1 = PuzzleBezierovaKrivka.HorizontalPoints(p1, p2, true); //static nastaveny
            //Point[] bezierPoints2 = PuzzleBezierovaKrivka.VerticalPoints(p2, p3, false);
            //Point[] bezierPoints3 = PuzzleBezierovaKrivka.HorizontalPoints(p3, p4, true);
            //Point[] bezierPoints4 = PuzzleBezierovaKrivka.VerticalPoints(p4, p1, false);

            //bezierpath.AddBeziers(bezierPoints1);
            //bezierpath.AddBeziers(bezierPoints2);
            //bezierpath.AddBeziers(bezierPoints3);
            //bezierpath.AddBeziers(bezierPoints4);

            return(bezierpath);
        }