/// <summary> /// Adds cells to the sheet without checking for its existance. /// The method is used by Importing Bulk data methods exposed by OpenXmlPackaging /// </summary> /// <param name="row">Cell Row</param> /// <param name="column">Cell Column</param> /// <param name="value">Value of the cell</param> internal void AddCell(int row, int column, string value) { // Get the current row var cellRow = AllCells.ContainsKey(row) ? AllCells[row] : null; // Add one if the row does not exist if (cellRow == null) { cellRow = new List <Cell>(); AllCells.Add(row, cellRow); } // Create a cell var cell = new Cell(row, column) { Stylesheet = _styleSheet, Value = value }; // Assign the Row property of the cell if (cellRow.Count == 0) { cell.Row = new Row(row); } else { cell.Row = cellRow[0].Row; } // Add the cell to the row cellRow.Add(cell); }
private void CreateCells(string puzzleString) { var parsedString = ParseString(puzzleString); for (var i = 1; i <= 9; i++) { Rows.Add(CreateCellCollection(i)); Columns.Add(CreateCellCollection(i)); Groups.Add(CreateCellCollection(i)); } for (var i = 0; i < 9; i++) { for (var j = 0; j < 9; j++) { var cell = string.IsNullOrEmpty(puzzleString) ? GetCell(i, j) : GetCell(i, j, parsedString[i, j]); cell.Puzzle = this; Rows[i].Cells.Add(cell); Columns[j].Cells.Add(cell); AllCells.Add(cell); var k = GetGroupIndex(i, j); cell.Location.Group = Groups[k]; Groups[k].Cells.Add(cell); } } NonInitialCells = AllCells.Where(cell => !cell.IsInitialCell); }
/// <summary> /// Returns a cell at a given row, column. /// It creates a new cell if it does not exist. /// It will return the cell if it already exists /// </summary> /// <param name="rowNumber">Row Number</param> /// <param name="columnIndex">Column Index</param> /// <returns></returns> private Cell GetCell(int rowNumber, int columnIndex) { string reference = Utilities.BuildReference(rowNumber, columnIndex); var row = AllCells.FirstOrDefault(c => c.Key == rowNumber).Value; // Check if the cell already exists var cell = row == null ? null : row.FirstOrDefault(c => c.ColumnNumber == columnIndex); // Cell does not exist. Create one. if (cell == null) { cell = new Cell(reference) { Stylesheet = _styleSheet }; var currentRow = Rows.FirstOrDefault(r => r.Index == rowNumber); // If the row already exists, get the row. Else, create a new row List <Cell> thisRow = null; if (AllCells.ContainsKey(rowNumber)) { thisRow = AllCells[rowNumber]; } else { thisRow = new List <Cell>(); AllCells.Add(rowNumber, thisRow); } // Add cell to the current row. thisRow.Add(cell); // Add the current row to the list of rows if it does not exist in the list. if (currentRow == null) { cell.Row = new Row(rowNumber); Rows.Add(cell.Row); } else { cell.Row = currentRow; } // Add the current column to the list of columns if it does not exist in the list. if (!Columns.ColumnsList.Any(c => c.Index == columnIndex)) { Columns.ColumnsList.Add(new Column { Index = columnIndex }); } } return(cell); }
public Level(int level) { this.level = level; Members = new(); for (int i = 0; i < 24; i++) { var n = new Cell(); Members.Add(n); AllCells.Add(n); } }
public void Update(bool extraSurrounding) { ulong steamId; if (SteamId == null || !ulong.TryParse(SteamId, out steamId)) { throw new InvalidDataException( $"The Steam ID ({SteamId ?? "NULL"}) for the zone '{Name}' is invalid."); } var identity = GameManager.Instance.GetIdentity(steamId); if (identity == null) { throw new InvalidDataException($"Couldn't find the Identity for {SteamId} in the zone '{Name}'."); } if (MainCell <= 0) { throw new InvalidDataException( $"The Cell ({SteamId ?? "NULL"}) for the zone '{Name}' is invalid."); } var cluster = BuildConnectedOwnedCellCluster(identity, MainCell); Stakes.Clear(); foreach (var cell in cluster) { var stake = GetStakeOnCell(cell); if (stake != null) { Stakes.Add(stake); } } if (extraSurrounding) { var surroundingCells = GetUniqueSurroundingUnownedCells(cluster); foreach (var surroundingCell in surroundingCells) { cluster.Add(surroundingCell); } } Bounds.Clear(); AllCells.Clear(); foreach (var cell in cluster) { Bounds.Add(GetCellBounds(cell)); AllCells.Add(cell); } }
private ICell AddCell(IWebElement webElement, int colNum, int rowNum, string colName, string rowName) { var cell = (Cell)_allCells.FirstOrDefault(c => c.ColumnNum == colNum && c.RowNum == rowNum); if (cell != null) { cell.WebElement = webElement; return(cell.UpdateData(colName, rowName)); } cell = new Cell(colNum, rowNum, colName, rowName, CellLocatorTemplate, this, -1, webElement: webElement); if (Cache) { AllCells.Add(cell); } return(cell); }
private ICell AddCell(int colIndex, int rowIndex, int colNum, int rowNum, string colName, string rowName) { var cell = (Cell)AllCells.FirstOrDefault(c => c.ColumnNum == colNum && c.RowNum == rowNum); if (cell != null) { return(cell.UpdateData(colName, rowName)); } cell = new Cell(colNum, rowNum, colName, rowName, CellLocatorTemplate, this, colIndex, rowIndex); cell.SetAvatar((GetElementModule)cell.Get().Avatar); if (Cache) { AllCells.Add(cell); } return(cell); }
public void AddPlayerTrayOriginMove(Coords coords) { AllCells.Add(new Cell(coords)); OriginCells.Add(new Cell(coords)); }