/// <summary> /// Determines whether the specified type is calculated. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static bool IsCalculated(CellTypeEnum type) { if (type == CellTypeEnum.Expression) { return(false); } return(true); }
/// <summary> /// Determines whether the specified type is calculated. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static bool IsCalculated(CellTypeEnum type) { if (type == CellTypeEnum.Expression) { return false; } return true; }
private static ICellStyle GetICellStyle(IWorkbook workbook, CellTypeEnum type, bool locked = false, IFont font = null, List <Type> datatypes = null) { if (type == CellTypeEnum.Cell) { ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.BorderTop = BorderStyle.THIN; cellStyle.BorderRight = BorderStyle.THIN; cellStyle.BorderBottom = BorderStyle.THIN; cellStyle.BorderLeft = BorderStyle.THIN; cellStyle.IsLocked = locked; if (datatypes != null) { foreach (Type datatype in datatypes) { if (datatype.Name == typeof(DateTime).Name) { cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("m/d/yy"); } } } else { //@ cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("Text"); } if (font != null) { cellStyle.SetFont(font); } return(cellStyle); } if (type == CellTypeEnum.Head) { ICellStyle headStyle = workbook.CreateCellStyle(); headStyle.FillForegroundColor = HSSFColor.GREY_40_PERCENT.index; headStyle.FillPattern = FillPatternType.SOLID_FOREGROUND; headStyle.BorderTop = BorderStyle.THIN; headStyle.BorderRight = BorderStyle.THIN; headStyle.BorderBottom = BorderStyle.THIN; headStyle.BorderLeft = BorderStyle.THIN; headStyle.WrapText = true; headStyle.Alignment = HorizontalAlignment.CENTER; headStyle.VerticalAlignment = VerticalAlignment.CENTER; headStyle.IsLocked = locked; if (font != null) { headStyle.SetFont(font); } return(headStyle); } return(workbook.CreateCellStyle()); }
public CellData(int posX, int posY, int type) { PosX = posX; PosY = posY; if (type == 0) { CellType = CellTypeEnum.COMMON; } else if (type == 1) { CellType = CellTypeEnum.GRASS; } else if (type == 2) { CellType = CellTypeEnum.WATER; } }
/// <summary> /// Count live adjacent cells for specified cell co-ordinates /// </summary> /// <param name="grid"></param> /// <param name="coOrdinates"></param> /// <returns>returns number of live neighbours</returns> private static int CountAliveNeighbours(Grid grid, CoOrdinates coOrdinates) { int liveNeighbours = 0; // Get the Cell type of current cell CellTypeEnum enumInnerCell = ReachableCell.GetCellType(grid, coOrdinates); List <CoOrdinates> reachableCells = new List <CoOrdinates>(); // populate reachable cells from current cell for easier traversing ReachableCell.ReachableCells.TryGetValue(enumInnerCell, out reachableCells); if (reachableCells.Count == 0) { throw new ArgumentNullException("Cannot find reachable co-ordinates"); } foreach (CoOrdinates coOrds in reachableCells) { liveNeighbours += IsAliveNeighbour(grid, coOrdinates, coOrds); } return(liveNeighbours); }
/// <summary> /// Gets the cell value. /// </summary> /// <param name="type">The type.</param> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"></exception> public static string GetCellValue(CellTypeEnum type, string value) { if (value == null) throw new ArgumentNullException(nameof(value)); string newValue = value; if (type == CellTypeEnum.Expression || type == CellTypeEnum.Text) { int expressionSymbolLength = 0; if (type == CellTypeEnum.Expression) { expressionSymbolLength = CellConst.ExpressionSymbol.Length; } if (type == CellTypeEnum.Text) { expressionSymbolLength = CellConst.TextSymbol.Length; } newValue = value.Substring(expressionSymbolLength, value.Length - 1); } return newValue; }
/// <summary> /// Gets the cell value. /// </summary> /// <param name="type">The type.</param> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"></exception> public static string GetCellValue(CellTypeEnum type, string value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } string newValue = value; if (type == CellTypeEnum.Expression || type == CellTypeEnum.Text) { int expressionSymbolLength = 0; if (type == CellTypeEnum.Expression) { expressionSymbolLength = CellConst.ExpressionSymbol.Length; } if (type == CellTypeEnum.Text) { expressionSymbolLength = CellConst.TextSymbol.Length; } newValue = value.Substring(expressionSymbolLength, value.Length - 1); } return(newValue); }
/// <summary> /// Get the co-ordinates with respectt to grid and return the Cell type enum /// </summary> /// <param name="grid"></param> /// <param name="coOrdinates"></param> /// <returns>returns CellTypeEnum</returns> public static CellTypeEnum GetCellType(Grid grid, CoOrdinates coOrdinates) { if ((coOrdinates.X < -1 || coOrdinates.X > grid.RowCount) || (coOrdinates.Y < -1 || coOrdinates.Y > grid.ColumnCount)) { throw new ArgumentOutOfRangeException("Invalid Index value: must be greater than or equal to minus one and less than or equal to Row count"); } CellTypeEnum enumCellType = CellTypeEnum.None; if (coOrdinates.X == 0 && coOrdinates.Y == 0) { enumCellType = CellTypeEnum.TopLeftCorner; } else if (coOrdinates.X == 0 && coOrdinates.Y == grid.ColumnCount - 1) { enumCellType = CellTypeEnum.TopRightCorner; } else if (coOrdinates.X == grid.RowCount - 1 && coOrdinates.Y == 0) { enumCellType = CellTypeEnum.BottomLeftCorner; } else if (coOrdinates.X == grid.RowCount - 1 && coOrdinates.Y == grid.ColumnCount - 1) { enumCellType = CellTypeEnum.BottomRightCorner; } else if (coOrdinates.X == 0 && (coOrdinates.Y > 0 && coOrdinates.Y < grid.ColumnCount - 1)) { enumCellType = CellTypeEnum.TopSide; } else if (coOrdinates.X == grid.RowCount - 1 && (coOrdinates.Y > 0 && coOrdinates.Y < grid.ColumnCount - 1)) { enumCellType = CellTypeEnum.BottomSide; } else if ((coOrdinates.X > 0 && coOrdinates.X < grid.RowCount - 1) && coOrdinates.Y == 0) { enumCellType = CellTypeEnum.LeftSide; } else if ((coOrdinates.X > 0 && coOrdinates.X < grid.RowCount - 1) && coOrdinates.Y == grid.ColumnCount - 1) { enumCellType = CellTypeEnum.RightSide; } else if ((coOrdinates.X > 0 && coOrdinates.X < grid.RowCount - 1) && (coOrdinates.Y > 0 && coOrdinates.Y < grid.ColumnCount - 1)) { enumCellType = CellTypeEnum.Center; } else if (coOrdinates.X == -1 && (coOrdinates.Y > 0 && coOrdinates.Y < grid.ColumnCount - 1)) { enumCellType = CellTypeEnum.OuterTopSide; } else if ((coOrdinates.X > 0 && coOrdinates.X < grid.RowCount - 1) && coOrdinates.Y == grid.ColumnCount) { enumCellType = CellTypeEnum.OuterRightSide; } else if (coOrdinates.X == grid.RowCount && (coOrdinates.Y > 0 && coOrdinates.Y < grid.ColumnCount - 1)) { enumCellType = CellTypeEnum.OuterBottomSide; } else if ((coOrdinates.X > 0 && coOrdinates.X < grid.RowCount - 1) && coOrdinates.Y == -1) { enumCellType = CellTypeEnum.OuterLeftSide; } return(enumCellType); }
public CellData(int posX, int posY, CellTypeEnum cellType) { PosX = posX; PosY = posY; CellType = cellType; }
public Cell(int row, int column, CellTypeEnum type) { Row = row; Column = column; CellType = type; }