private void OnBoardCellClick(object sender, EventArgs e) { if (sender is Button) { CellInformation cellInfo = (sender as Button).Tag as CellInformation; if (cellInfo != null) { if (AllowClick) { if (Matrix[cellInfo.Row, cellInfo.Column] == 0) { ApplyCell(cellInfo.Row, cellInfo.Column, PlayerValue); if (CellClicked != null) { CellClicked(this, new EventArgs()); } } else { if (CellClickInvalid != null) { CellClickInvalid(this, new EventArgs()); } } } } } }
public IEnumerable <ICellInformation> Convert(string[] text) { var list = new List <ICellInformation>(); for (var row = 0; row < text.GetLength(0); row++) { for (var column = 0; column < text [row].Length; column++) { Cell.Status status = text [row] [column] == ' ' ? Cell.Status.Dead : Cell.Status.Alive; if (status == Cell.Status.Dead) { continue; } var info = new CellInformation { RowIndex = row, ColumnIndex = column, Status = status, NeighboursAlive = 0 }; list.Add(info); } } return(list); }
public void InitializeBoard(int rowCount, int columnCount) { this.rowCount = rowCount; this.columnCount = columnCount; _cells = new Button[rowCount, columnCount]; _matrix = new int[rowCount, columnCount]; for (int row = 0; row < rowCount; row++) { for (int column = 0; column < columnCount; column++) { Button cell = new Button(); cell.Width = CELL_WIDTH; cell.Height = CELL_HEIGHT; cell.Left = column * CELL_WIDTH; cell.Top = row * CELL_HEIGHT; CellInformation cellInfomation = new CellInformation { Row = row, Column = column }; cell.Tag = cellInfomation; cell.Click += OnBoardCellClick; _cells[row, column] = cell; _matrix[row, column] = 0; this.Controls.Add(cell); } } }
public void ShowSingleCellQi(CellInformation cl) { this.cell = cl; cell.ShowOutLine(); cell.DisPlayInfo(); cell.ShowSingleCellQi(); }
private IEnumerable <ICellInformation> CreateCellsInformation() { var one = new CellInformation { RowIndex = -10, ColumnIndex = -10, NeighboursAlive = 0, Status = Cell.Status.Alive }; var two = new CellInformation { RowIndex = 10, ColumnIndex = 10, NeighboursAlive = 0, Status = Cell.Status.Alive }; var three = new CellInformation { RowIndex = 0, ColumnIndex = 0, NeighboursAlive = 0, Status = Cell.Status.Alive }; return(new[] { one, two, three }); }
public IEnumerable <ICellInformation> Find(Dictionary <int, ICells> rows) { var list = new List <CellInformation>(); foreach (KeyValuePair <int, ICells> row in rows) { IEnumerable <int> aliveInRow = row.Value.GetAllAlive(); foreach (int index in aliveInRow) { var info = new CellInformation { RowIndex = row.Key, ColumnIndex = index, Status = Cell.Status.Alive, NeighboursAlive = m_Finder.NumberOfAliveNeighbours(rows, row.Key, index) }; list.Add(info); } } return(list); }
public void ReturnClick() { if (cell) { cell.UnlodaOutLine(); cell = null; } }
public void Status_Roundtrip_Test() { // Arrange CellInformation sut = CreateSut(); // Act // Assert sut.Status.ShouldEqual(Cell.Status.Alive); }
public void ReturnClicks() { if (cell) { cell.UnlodaOutLine(); cell.HideSingleCellQi(); cell = null; } }
public void ColumnIndex_Roundtrip_Test() { // Arrange CellInformation sut = CreateSut(); // Act // Assert sut.ColumnIndex.ShouldEqual(2); }
private IPdfPCellEvent CellImage(DateTime date) { IPdfPCellEvent image = new NoCellEvent(); // No image as default. if (CellInformation.ContainsKey(date)) { var tmp = CellInformation[date].Image; image = EventSpecificImage(tmp.Image, tmp.Width, tmp.Height); } return(image); }
public void Apply_SetsStatusToDead_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); SurvivorRule sut = CreateSut(); // Act sut.Apply(info); // Assert info.Status.ShouldEqual(Cell.Status.Alive); }
public void Apply_CallsApply_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Apply(info); // Assert sut.WasCalledApply.ShouldBeTrue(); }
public void Initialize_CallsInitialize_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); // Act sut.Initialize(info); // Assert sut.WasCalledInitialize.ShouldBeTrue(); }
public void Priority_ReturnsInteger_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); OvercrowdingRule sut = CreateSut(); // Act sut.Apply(info); // Assert sut.Priority.ShouldEqual(2); }
public void Initialize_AddsLessThanRule_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); UnderpopulationRule sut = CreateSut(); // Act sut.Initialize(info); // Assert sut.GetConditions().Last().ShouldBeInstanceOf <IsLessThan>(); }
public void Initialize_AddsConditions_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); UnderpopulationRule sut = CreateSut(); // Act sut.Initialize(info); // Assert sut.GetConditions().Count().ShouldEqual(1); }
public void Apply_SetsStatusToDead_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); UnderpopulationRule sut = CreateSut(); // Act sut.Apply(info); // Assert info.Status.ShouldEqual(Cell.Status.Dead); }
public void Priority_ReturnsInteger_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); UnderpopulationRule sut = CreateSut(); // Act sut.Apply(info); // Assert sut.Priority.ShouldEqual(1); }
public void Initialize_AddsMoreThanRule_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); NewbornRule sut = CreateSut(); // Act sut.Initialize(info); // Assert sut.GetConditions().First().ShouldBeInstanceOf <IsEqual>(); }
public void ClearConditions_ClearsCondintions_WhenCalled() { // Arrange CellInformation info = CreateCellInformation(); TestRule sut = CreateSut(); sut.Initialize(info); // Act sut.ClearConditions(); // Assert sut.GetConditions().Count().ShouldEqual(0); }
public void LivingCells_ReturnsAllAlive_WhenCalled() { // Arrange var expected = new CellInformation[0]; var finder = Substitute.For <ILivingCellFinder>(); finder.Find(Arg.Any <Dictionary <int, ICells> >()).Returns(expected); UnlimitedBoard sut = CreateSut(); // Act IEnumerable <ICellInformation> actual = sut.LivingCells(); // Assert expected.ShouldEqual(actual); }
public void IsValid_ReturnsTrueOrFalse_ForGivenNeighbours(int neighbours, bool expected) { // Arrange CellInformation info = CreateCellInformation(neighbours); UnderpopulationRule sut = CreateSut(); sut.Initialize(info); // Act bool actual = sut.IsValid(); // Assert Assert.Equal(expected, actual); }
private float CalcEffecTxHt(CellInformation cellInfo, BinInformation binInfo) { GeoXYLine geoXYLine = new GeoXYLine(cellInfo.XYPoint, binInfo.XYPoint); short[] altitudes = base.m_GeoDataObserver.GisInfo.GetValueByGeoXYLine(geoXYLine, (double) cellInfo.Resolution, DemDataType.Height); this.m_EffTxHeightMethod = base.modelBeforeAdjust.EffTxHeightCalcuMethod as EffectTxHeightBase; SectionPathLossCalcParam param = new SectionPathLossCalcParam(); param.CalcResolution = cellInfo.Resolution; param.TxAntennaHeight = cellInfo.TxHeight; param.RxAntennaHeight = 1.5f; param.MergeEdgeMaxDis = 80f; param.PropagModel = base.modelBeforeAdjust; param.Frequency = cellInfo.Frequency; param.TransmitterName = cellInfo.CellName; float num = (this.m_EffTxHeightMethod == null) ? cellInfo.TxHeight : this.m_EffTxHeightMethod.CalcPointEffTxHt(param, altitudes); return (float) Math.Log10((double) num); }
/// <summary> /// Erzeugt eine neue Liste. /// </summary> /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param> /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param> /// <param name="length">Die Anzahl der Bytes für diese Liste.</param> public CellList(IDescriptorContainer container, int offset, int length) : base(container, offset, length) { // Check minimum length if (length < 0) { return; } // Attach to data Section section = container.Section; // Helper List <CellInformation> cells = new List <CellInformation>(); // Load while (length > 0) { // Create CellInformation cell = CellInformation.Create(section, offset, length); // Done if (null == cell) { break; } // Remember cells.Add(cell); // Correct offset += cell.Length; length -= cell.Length; } // Test m_Valid = (0 == length); // Load if (m_Valid) { Cells = cells; } }
private IEnumerable <ICellInformation> CreateCellsInformationStillLife() { var one = new CellInformation { RowIndex = 1, ColumnIndex = 1, NeighboursAlive = 0, Status = Cell.Status.Alive }; var two = new CellInformation { RowIndex = 1, ColumnIndex = 2, NeighboursAlive = 0, Status = Cell.Status.Alive }; var three = new CellInformation { RowIndex = 2, ColumnIndex = 1, NeighboursAlive = 0, Status = Cell.Status.Alive }; var four = new CellInformation { RowIndex = 2, ColumnIndex = 2, NeighboursAlive = 0, Status = Cell.Status.Alive }; return(new[] { one, two, three, four }); }
private void InsertFooter(DayOfWeek expectedDay) { // The day of the week don't exist in the month. Insert an empty day in the caledar. // For instance: If the first day of February is on a tuesday. The monday belongs to January. if (!Dates.Any(d => d.DayOfWeek == expectedDay)) { EmptyDay(); return; } var dateInWeek = Dates.First(d => d.DayOfWeek == expectedDay); // The date of the week for this day of the week. if (CellInformation.ContainsKey(dateInWeek)) { var c = CellInformation[dateInWeek]; AddAnyContent(c.Text.ToString()); } else { EmptyDay(); } }
private ICellInformation CreateCellInformation(Dictionary <int, ICells> rows, int rowIndex, int columnIndex) { Cell.Status status = GetStatus(rows, rowIndex, columnIndex); int numberOfAliveNeighbours = NumberOfAliveNeighbours(rows, rowIndex, columnIndex); var cell = new CellInformation { RowIndex = rowIndex, ColumnIndex = columnIndex, Status = status, NeighboursAlive = numberOfAliveNeighbours }; return(cell); }
private IEnumerable <CellInformation> CreateExpectedCellInfos() { var list = new List <CellInformation>(); var zeroZero = new CellInformation { RowIndex = 0, ColumnIndex = 0, Status = Cell.Status.Alive, NeighboursAlive = 2 }; list.Add(zeroZero); var zeroOne = new CellInformation { RowIndex = 0, ColumnIndex = 1, Status = Cell.Status.Alive, NeighboursAlive = 2 }; list.Add(zeroOne); var oneZero = new CellInformation { RowIndex = 1, ColumnIndex = 0, Status = Cell.Status.Alive, NeighboursAlive = 2 }; list.Add(oneZero); return(list); }
public TableCellProvider(AutomationProvider parent, CellInformation cell) : base(parent, TableItemPattern.Pattern, GridItemPattern.Pattern) { _cell = cell; ControlType = ControlType.Text; }
public void SetUp() { _cell = new TestCell(); _cellInformation = DataGridCellInformation.FromCell(_cell); }
private void CalculateModelValue(CellInformation cellInfo, BinInformation binInfo, ref float[] tempModelValue) { float num = 0f; if ((cellInfo.TxHeight == 0f) || float.IsNegativeInfinity(cellInfo.TxHeight)) { num = 0f; } else { num = this.CalcEffecTxHt(cellInfo, binInfo); } float num2 = 1.5f; tempModelValue[0] = 1f; tempModelValue[1] = binInfo.LogDistance; tempModelValue[2] = num; tempModelValue[3] = binInfo.DiffLoss; tempModelValue[4] = binInfo.LogDistance * num; tempModelValue[5] = num2; tempModelValue[6] = binInfo.ClutterLoss; }