public void TestLinkBidirectional() { var cell1 = new Cell(); var cell2 = new Cell(); cell1.Link(cell2); Assert.IsTrue(cell1.IsLinked(cell2)); Assert.IsTrue(cell2.IsLinked(cell1)); }
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)); }
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)); }
public int this[Cell cell] { get { int val; if (_Cells.TryGetValue(cell, out val)) { return val; } return -1; } set { _Cells[cell] = value; } }
public void TestConstructor() { var cell = new Cell(); }
public Cell Unlink(Cell cell, bool bidirectional = true) { _Links[cell] = false; if (bidirectional) { cell.Unlink(this, false); } return this; }
public bool IsLinked(Cell cell) { return cell != null && _Links.ContainsKey(cell) && _Links[cell]; }
public Distances(Cell root) { _Root = root; _Cells = new Dictionary<Cell, int>(); _Cells[_Root] = 0; }
public bool HasKey(Cell cell) { return _Cells.Keys.Any(c => c == cell); }