Ejemplo n.º 1
0
        public void DuplicateTest()
        {
            var Shapes = new List <Tetris.Controls.TileControl>();

            byte[,] arr = new byte[4, 4] {
                { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
            };
            byte[,] arr2 = new byte[4, 4] {
                { 1, 1, 1, 1 }, { 1, 0, 0, 1 }, { 1, 0, 0, 1 }, { 1, 1, 1, 1 }
            };
            Shape s1      = new Shape(arr, System.Drawing.Color.FromArgb(0, 0, 0, 0), System.Drawing.Color.FromArgb(0, 0, 0, 0));
            Shape otherS1 = new Shape(arr, System.Drawing.Color.FromArgb(0, 0, 0, 0), System.Drawing.Color.FromArgb(0, 0, 0, 0));
            Shape other   = new Shape(arr2, System.Drawing.Color.FromArgb(0, 0, 0, 0), System.Drawing.Color.FromArgb(0, 0, 0, 0));
            var   tc1     = new Tetris.Controls.TileControl(s1);
            var   tc2     = new Tetris.Controls.TileControl(otherS1);
            var   tc3     = new Tetris.Controls.TileControl(other);

            Shapes.Add(tc1);
            Shapes.Add(tc2);
            Shapes.Add(tc3);
            ShapeValidator.MarkDuplicates(Shapes);
            Assert.IsFalse(Shapes[0].IsDuplicate);
            Assert.IsTrue(Shapes[1].IsDuplicate);
            Assert.IsFalse(Shapes[2].IsDuplicate);
        }
Ejemplo n.º 2
0
        public TileBrowser(/*ref*/ List <Shape> Shapes)
        {
            InitializeComponent();
            Random r = new Random();

            TileControls.Clear();
            foreach (Shape s in Shapes)
            {
                TileControl t = new TileControl(s);
                TileControls.Add(t);
            }

            ShapeValidator.MarkDuplicates(TileControls);
            SortTilesByValidity();

            foreach (TileControl tc in TileControls)
            {
                this.TilesPanel.Children.Add(tc);
            }
        }