TableCell class was added
This commit is contained in:
35
StructureHelperCommon/Models/Tables/IShTableCell.cs
Normal file
35
StructureHelperCommon/Models/Tables/IShTableCell.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Tables
|
||||
{
|
||||
public enum CellRole
|
||||
{
|
||||
Title,
|
||||
Header,
|
||||
Regular
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generic interface for cell of table
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IShTableCell<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Value of cell
|
||||
/// </summary>
|
||||
T Value { get; set; }
|
||||
/// <summary>
|
||||
/// Number of cell, joined with this one
|
||||
/// </summary>
|
||||
int ColumnSpan { get; set; }
|
||||
/// <summary>
|
||||
/// Role of the cell in table
|
||||
/// </summary>
|
||||
CellRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace StructureHelperCommon.Models.Tables
|
||||
{
|
||||
public interface IShTableRow<T>
|
||||
{
|
||||
List<T> Elements { get; }
|
||||
List<IShTableCell<T>> Elements { get; }
|
||||
int RowSize { get; }
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Tables
|
||||
{
|
||||
public class ListTable<T>
|
||||
public class ShTable<T>
|
||||
{
|
||||
private List<IShTableRow<T>> table;
|
||||
|
||||
public int RowSize { get; }
|
||||
|
||||
public ListTable(int rowSize)
|
||||
public ShTable(int rowSize)
|
||||
{
|
||||
if (rowSize <= 0)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace StructureHelperCommon.Models.Tables
|
||||
return table;
|
||||
}
|
||||
|
||||
public List<T> GetElementsFromRow(int rowIndex)
|
||||
public List<IShTableCell<T>> GetElementsFromRow(int rowIndex)
|
||||
{
|
||||
if (rowIndex >= 0 && rowIndex < table.Count)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace StructureHelperCommon.Models.Tables
|
||||
if (columnIndex >= 0 && columnIndex < RowSize &&
|
||||
rowIndex >= 0 && rowIndex < table.Count)
|
||||
{
|
||||
table[rowIndex].Elements[columnIndex] = value;
|
||||
table[rowIndex].Elements[columnIndex].Value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
24
StructureHelperCommon/Models/Tables/ShTableCell.cs
Normal file
24
StructureHelperCommon/Models/Tables/ShTableCell.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Tables
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class ShTableCell<T> : IShTableCell<T>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public T Value { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public int ColumnSpan { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public CellRole Role { get; set; }
|
||||
public ShTableCell()
|
||||
{
|
||||
Role = CellRole.Regular;
|
||||
ColumnSpan = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace StructureHelperCommon.Models.Tables
|
||||
{
|
||||
public class ShTableRow<T> : IShTableRow<T>
|
||||
{
|
||||
private List<T> elements;
|
||||
private List<IShTableCell<T>> elements;
|
||||
|
||||
public int RowSize { get; }
|
||||
|
||||
@@ -20,15 +20,16 @@ namespace StructureHelperCommon.Models.Tables
|
||||
}
|
||||
|
||||
RowSize = rowSize;
|
||||
elements = new List<T>(rowSize);
|
||||
elements = new List<IShTableCell<T>>(rowSize);
|
||||
for (int i = 0; i < rowSize; i++)
|
||||
{
|
||||
elements.Add(default);
|
||||
var newCell = new ShTableCell<T>();
|
||||
elements.Add(newCell);
|
||||
}
|
||||
}
|
||||
|
||||
// Property to access elements in the row
|
||||
public List<T> Elements => elements;
|
||||
public List<IShTableCell<T>> Elements => elements;
|
||||
|
||||
internal void Add(object value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user