예제 #1
0
        public void Should_Correctly_Resolve_Relationship_To_Neighbours()
        {
            Field f1 = new Field(0, 1);
            // Setting neighbours (2 fields, 2 red mines, 1 blue mine)
            List<Field> neighbours = new List<Field> { new Field(0, 0), new Field(0, 2), new Field(1, 0, MinesColors.Blue), new Field(1, 1, MinesColors.Red), new Field(1, 2, MinesColors.Red) };
            f1.NeighbouringFields = neighbours;

            Assert.IsFalse(f1.IsMine);
            Assert.AreEqual(f1.Color, MinesColors.NoColor);
            Assert.IsTrue(f1.NeighbouringMines == 3);
            Assert.IsTrue(f1.NeighbouringFields.Count == 5);
            Assert.IsTrue(f1.GetColoredMines(MinesColors.Red) == 2) ;
            Assert.IsTrue(f1.GetColoredMines(MinesColors.Blue) == 1);
        }
예제 #2
0
        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="field">Gibt das zu repräsentierende Feld an.</param>
        public CtrlFieldCheckBox(Field field, bool blueEnabled, bool greenEnabled = false, bool yellowEnabled = false)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }
            base.Appearance = Appearance.Button;
            base.Height = 40;
            base.Width = 40;
            base.TextAlign = ContentAlignment.MiddleCenter;
            base.Font = new System.Drawing.Font("Consolas", 12, FontStyle.Bold);
            base.ForeColor = Color.FromKnownColor(System.Drawing.KnownColor.Black);
            base.Margin = new Padding(0);
            base.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            base.FlatAppearance.CheckedBackColor = Color.FromKnownColor(System.Drawing.KnownColor.Black);
            this._Field = field;
            base.MouseDown += CtrlFieldCheckBox_MouseDown;
            this._BlueEnabled = blueEnabled;
            this._GreenEnabled = greenEnabled;
            this._YellowEnabled = yellowEnabled;

            this.LoadImage();
        }