예제 #1
0
        public void GetNextRowSuccess()
        {
            var caEngine = new CAEngine(3);

            caEngine.CurrentRow = new[] { 0, 0, 0 };
            caEngine.RuleNumber = 30;
            var expected = new[] { 0, 0, 0 };

            CollectionAssert.AreEqual(expected, caEngine.GetNextRow());
        }
예제 #2
0
        public void Generate()
        {
            int[] curRow = new int[CAPictureBox.Size.Width / myCellSize];
            int   col    = 0;
            int   row    = 0;

            // create the first row(s)
            for (col = 0; col < curRow.Length; col++)
            {
                curRow[col] = 0;
            }
            curRow[(int)(curRow.Length / 2)] = 1;
            myCAEngine.CurrentRow            = curRow;

            var myBitmap = new DirectBitmap(CAPictureBox.Size.Width, CAPictureBox.Size.Height);

            DrawRow(myBitmap, 0, curRow);
            // draw a bitmap with the rows
            for (row = 1; row < myBitmap.Size.Height / myCellSize; row++)
            {
                myCAEngine.GetNextRow().CopyTo(curRow, 0);
                DrawRow(myBitmap, row, curRow);
            }

            Bitmap oldBitmap = null;

            if (CAPictureBox.Image != null)
            {
                oldBitmap = (Bitmap)CAPictureBox.Image;
            }
            CAPictureBox.Image = myBitmap.Bitmap;
            if (oldBitmap != null)
            {
                oldBitmap.Dispose();
            }
        }