public override CTableViewCell TableCellForRow(CTableView table, int rowIndex) { CTableViewCell cell = m_cells[rowIndex]; if (cell is TableViewCellMock) { TableViewCellMock mockCell = cell as TableViewCellMock; mockCell.DetachFromList(); } return(cell); }
public void TestReusableCellsMultipleOccurrenceBigScroll() { MockCellEntry[] cells = new MockCellEntry[15]; for (int i = 0; i < cells.Length; ++i) { cells[i] = new MockCellEntry(typeof(TableViewCellMock1), 10); } ; TableViewAdapter adapter = new TestCellsHeightTableAdapter(cells); TableViewMock table = new TableViewMock(320, 50); table.DataSource = adapter; table.Delegate = adapter; table.ReloadData(); CTableViewCell a1 = table.FirstVisibleCell; CTableViewCell a2 = a1.NextCell; CTableViewCell a3 = a2.NextCell; CTableViewCell a4 = a3.NextCell; CTableViewCell a5 = a4.NextCell; table.Scroll(100); CTableViewCell b1 = table.FirstVisibleCell; CTableViewCell b2 = b1.NextCell; CTableViewCell b3 = b2.NextCell; CTableViewCell b4 = b3.NextCell; CTableViewCell b5 = b4.NextCell; Assert.AreSame(a1, b5); Assert.AreSame(a2, b4); Assert.AreSame(a3, b3); Assert.AreSame(a4, b2); Assert.AreSame(a5, b1); table.Scroll(-100); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; b4 = b3.NextCell; b5 = b4.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); Assert.AreSame(a3, b3); Assert.AreSame(a4, b4); Assert.AreSame(a5, b5); Assert.AreEqual(5, TableViewCellMock1.instanceCount); }
public override CTableViewCell TableCellForRow(CTableView table, int rowIndex) { CTableViewCell cell = table.DequeueReusableCell(m_cellsEntries[rowIndex].type); if (cell == null) { float width = table.Width; float height = m_cellsEntries[rowIndex].height; return((CTableViewCell)Activator.CreateInstance(m_cellsEntries[rowIndex].type, width, height)); } return(cell); }
private void AssertVisibleRows(CTableView table, params CTableViewCell[] cells) { Assert.AreEqual(cells.Length, table.VisibleCellsCount); int index = 0; CTableViewCell cell = table.FirstVisibleCell; CTableViewCell lastCell = null; while (cell != null) { Assert.AreSame(cells[index++], cell); lastCell = cell; cell = cell.NextCell; } Assert.AreEqual(cells.Length, index); Assert.AreSame(lastCell, table.LastVisibleCell); }
private string VisibleCellsToString(CTableView table) { StringBuilder buffer = new StringBuilder("["); int index = 0; for (CTableViewCell cell = table.FirstVisibleCell; cell != null; cell = cell.NextCell) { CConsoleTextEntryView textCell = cell as CConsoleTextEntryView; Assert.IsNotNull(textCell); buffer.Append(textCell.Value); if (++index < table.VisibleCellsCount) { buffer.Append(", "); } } buffer.Append("]"); return(buffer.ToString()); }
internal void AssertVisibleRows(CTableView table, params string[] values) { Assert.AreEqual(values.Length, table.VisibleCellsCount, "expected: " + StringArrayToString(values) + "\n" + "actual: " + VisibleCellsToString(table)); int index = 0; CTableViewCell cell = table.FirstVisibleCell; CTableViewCell lastCell = null; while (cell != null) { CConsoleTextEntryView textCell = cell as CConsoleTextEntryView; Assert.IsNotNull(textCell); Assert.AreEqual(values[index++], textCell.Value); lastCell = cell; cell = cell.NextCell; } Assert.AreEqual(values.Length, index); Assert.AreSame(lastCell, table.LastVisibleCell); }
public void TestAddTwoRows() { TableViewMock table = new TableViewMock(320, 15); CTableViewCell a1 = new TableViewCellMock1(table.Width, 10); CTableViewCell a2 = new TableViewCellMock2(table.Width, 15); TestCellPredefinedAdapter adapter = new TestCellPredefinedAdapter(new CTableViewCell[] { a1 }); table.DataSource = adapter; table.Delegate = adapter; table.ReloadData(); adapter.Add(a2); table.ReloadNewData(); CTableViewCell b1 = table.FirstVisibleCell; CTableViewCell b2 = b1.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); AssertVisibleRows(table, 0, 1); }
public void Add(CTableViewCell cell) { m_cells.Add(cell); }
public void TestReusableCells() { MockCellEntry[] cells = { new MockCellEntry(typeof(TableViewCellMock1), 10), new MockCellEntry(typeof(TableViewCellMock2), 10), new MockCellEntry(typeof(TableViewCellMock3), 10), new MockCellEntry(typeof(TableViewCellMock1), 10), new MockCellEntry(typeof(TableViewCellMock2), 10), new MockCellEntry(typeof(TableViewCellMock3), 10), }; TableViewAdapter adapter = new TestCellsHeightTableAdapter(cells); TableViewMock table = new TableViewMock(320, 25); table.DataSource = adapter; table.Delegate = adapter; table.ReloadData(); CTableViewCell a1 = table.FirstVisibleCell; CTableViewCell a2 = a1.NextCell; CTableViewCell a3 = a2.NextCell; Assert.AreEqual(typeof(TableViewCellMock1), a1.GetType()); Assert.AreEqual(typeof(TableViewCellMock2), a2.GetType()); Assert.AreEqual(typeof(TableViewCellMock3), a3.GetType()); table.Scroll(10); CTableViewCell b1 = table.FirstVisibleCell; CTableViewCell b2 = b1.NextCell; CTableViewCell b3 = b2.NextCell; Assert.AreSame(a2, b1); Assert.AreSame(a3, b2); Assert.AreSame(a1, b3); table.Scroll(10); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a3, b1); Assert.AreSame(a1, b2); Assert.AreSame(a2, b3); table.Scroll(10); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); Assert.AreSame(a3, b3); table.Scroll(5); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); Assert.AreSame(a3, b3); table.Scroll(-5); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); Assert.AreSame(a3, b3); table.Scroll(-10); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a3, b1); Assert.AreSame(a1, b2); Assert.AreSame(a2, b3); table.Scroll(-10); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a2, b1); Assert.AreSame(a3, b2); Assert.AreSame(a1, b3); table.Scroll(-10); b1 = table.FirstVisibleCell; b2 = b1.NextCell; b3 = b2.NextCell; Assert.AreSame(a1, b1); Assert.AreSame(a2, b2); Assert.AreSame(a3, b3); Assert.AreEqual(1, TableViewCellMock1.instanceCount); Assert.AreEqual(1, TableViewCellMock2.instanceCount); Assert.AreEqual(1, TableViewCellMock3.instanceCount); }
protected override bool OnMouseDown(CEvent evt, CTableViewCell cell) { ClickedCell = cell; return(true); }