Example #1
0
        public void TestLinkBidirectional()
        {
            var cell1 = new Cell();
            var cell2 = new Cell();

            cell1.Link(cell2);
            Assert.IsTrue(cell1.IsLinked(cell2));
            Assert.IsTrue(cell2.IsLinked(cell1));
        }
Example #2
0
        public void TestLink()
        {
            var cell1 = new Cell();
            var cell2 = new Cell();

            cell1.Link(cell2, false);

            Assert.IsTrue(cell1.IsLinked(cell2));
            Assert.IsFalse(cell2.IsLinked(cell1));
        }
Example #3
0
        protected override Brush BackgroundBrushFor(Cell cell)
        {
            if (max == 0)
            {
                return base.BackgroundBrushFor(cell);
            }

            var distance = Distances[cell];
            var intensity = Convert.ToDouble(max - distance) / max;
            var dark = Convert.ToInt32(255 * intensity);
            var bright = Convert.ToInt32(128 + (127 * intensity));

            return new SolidBrush(Color.FromArgb(dark, bright, dark));
        }
Example #4
0
        public int this[Cell cell]
        {
            get
            {
                int val;
                if (_Cells.TryGetValue(cell, out val))
                {
                    return val;
                }

                return -1;
            }
            set
            {
                _Cells[cell] = value;
            }
        }
Example #5
0
 public void TestConstructor()
 {
     var cell = new Cell();
 }
Example #6
0
        public Cell Unlink(Cell cell, bool bidirectional = true)
        {
            _Links[cell] = false;

            if (bidirectional)
            {
                cell.Unlink(this, false);
            }

            return this;
        }
Example #7
0
 public bool IsLinked(Cell cell)
 {
     return cell != null && _Links.ContainsKey(cell) && _Links[cell];
 }
Example #8
0
 public Distances(Cell root)
 {
     _Root = root;
     _Cells = new Dictionary<Cell, int>();
     _Cells[_Root] = 0;
 }
Example #9
0
 public bool HasKey(Cell cell)
 {
     return _Cells.Keys.Any(c => c == cell);
 }