private static Entities.Grid.GridRow GetRow(Entities.Grid.GridRow row, RowMovement direction) { if (row is null) { throw new ArgumentNullException(nameof(row)); } var allRows = row.Grid.AllRows; var rowIndex = allRows.IndexOf(row); if ((direction == RowMovement.Up && rowIndex == 0) || (direction == RowMovement.Down && rowIndex == allRows.Count - 1)) { return(null); } var newIndex = direction == RowMovement.Up ? rowIndex - 1 : rowIndex + 1; Entities.Grid.GridRow newRow; do { newRow = allRows[(direction == RowMovement.Up ? newIndex-- : newIndex++)]; } while (!newRow.Visible && newIndex >= 0 && newIndex <= allRows.Count - 1); if (!newRow.Visible) { return(null); } return(newRow); }
void Spawn() { if (!GameManager.instance.pauseMode && !GameManager.instance.ventanaAbierta) { GameObject obj = Instantiate(varPrefab, transform.position, Quaternion.identity); RowMovement row = obj.GetComponent <RowMovement>(); row.Move(speed, leftSense); } Invoke("Spawn", step); }
/// <summary> /// Move the position of a given row /// </summary> /// <param name="direction">direction of movement</param> /// <param name="dataRow">row to be moved</param> private void MoveRow(DataGridViewRow dataRow, RowMovement direction) { // Perform no operation when no rows are selected if (null == dataRow) { return; } CTCTestCaseDetailsDataSet.TestCaseDetailsDataTable dtable = cTCTestCaseDetails.TestCaseDetails; DataRow currentRow = ((DataRowView)dataRow.DataBoundItem).Row; DataRow newRow = cTCTestCaseDetails.TestCaseDetails.NewTestCaseDetailsRow(); newRow.ItemArray = currentRow.ItemArray; int newRowIndex = 0; if (direction == RowMovement.MoveDown) { newRowIndex = (dataRow.Index + 2) > testCaseDetails_DataGrid.Rows.Count ? testCaseDetails_DataGrid.Rows.Count : (dataRow.Index + 2); } else if (direction == RowMovement.MoveUp) { newRowIndex = (dataRow.Index - 1) < 0 ? 0 : (dataRow.Index - 1); } else if (direction == RowMovement.MoveBottom) { newRowIndex = testCaseDetails_DataGrid.Rows.Count; } dtable.Rows.InsertAt(newRow, newRowIndex); testCaseDetails_DataGrid.Rows[newRowIndex].Selected = true; testCaseDetails_DataGrid.CurrentCell = testCaseDetails_DataGrid.Rows[newRowIndex].Cells[0]; testCaseDetails_DataGrid.DataBindingComplete -= testCaseDetails_DataGrid_DataBindingComplete; dtable.Rows.Remove(currentRow); testCaseDetails_DataGrid.DataBindingComplete += testCaseDetails_DataGrid_DataBindingComplete; dtable.AcceptChanges(); }