// CELLBEGINEDIT private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { // What cell are we editing?? int row = e.RowIndex; int column = e.ColumnIndex; // Get that cell from our spreadsheet Cell selectedCell = spreadsheet.GetCell(row, column + 1); // set the Value of the grid's cell to the spreadsheet Cell's Text field dataGridView1.Rows[row].Cells[column].Value = selectedCell.Text; }
//execute undo of cell color public void UnExec(object ss) { Spreadsheet undo = (Spreadsheet)ss; Cell undoCell = undo.GetCell(row, column); redoColor = undoCell.BgColor; undoCell.BgColor = undoColor; }
// store the previous color from the current cell // set the new color // return the previous color with associated cell public IUndoRedoCmd Exec(Spreadsheet ss) { Cell curCell = ss.GetCell(m_name); int prevColor = curCell.BGColor; curCell.BGColor = m_color; return(new RestoreBGColorCmd(prevColor, m_name)); }
public IUndoRedoCmd Exec(Spreadsheet sheet) { Cell theCell = sheet.GetCell(_cellName); string oldText = theCell.Text; theCell.Text = _cellText; return(new TextCmd(_cellName, oldText)); }
// store previous text from the current cell // place current text in the current cell // return previous text associated with the current cell name public IUndoRedoCmd Exec(Spreadsheet ss) { Cell curCell = ss.GetCell(m_name); string prevTxt = curCell.Text; curCell.Text = m_text; return(new RestoreTextCmd(prevTxt, m_name)); }
public IUndoRedoCmd Exec(Spreadsheet sheet) { Cell theCell = sheet.GetCell(_cellName); // get cell int oldColor = theCell.BGColor; // store old color theCell.BGColor = _cellColor; // set the color return(new BGColorCmd(_cellName, oldColor)); }
//execute redo for cell color public void Exec(object ss) { Spreadsheet redo = (Spreadsheet)ss; //get current cell Cell redoCell = redo.GetCell(row, column); redoCell.BgColor = redoColor; }
//implement execute interface public IUndoRedoCmd Execute(Spreadsheet sheet) { Cell theCell = sheet.GetCell(_cellName); int oldColor = theCell.BGColor; theCell.BGColor = _cellColor; //return cmd for redo/undo stack return new BGColorCmd(_cellName, oldColor); }
/// <summary> /// Undo/Redo command for the text. /// </summary> /// <param name="spreadsheet"></param> /// <returns></returns> public IUndoRedoCommand Execute(Spreadsheet spreadsheet) { string cellName = this.cell.ColumnIndex.ToString() + this.cell.RowIndex.ToString(); Cell cell = spreadsheet.GetCell(cellName); string currentText = cell.Text; cell.Text = this.text; return(new RestoreText(cell, currentText)); }
// restore cell with OG text public UndoRedoCwd Restore(Spreadsheet sheet) { Cell cell = sheet.GetCell(mCellName); string OGtext = cell.Text; cell.Text = mText; return(new RestoreText(OGtext, mCellName)); }
//execute function that redo the the cell text public void Exec(object ss) { Spreadsheet redo = (Spreadsheet)ss; //get current cell Cell redoCell = redo.GetCell(row, column); //change the cell text property redoCell.newCellText = redoText; }
// restore cell to OG background color public UndoRedoCwd Restore(Spreadsheet sheet) { Cell cell = sheet.GetCell(mCellName); int OGcolor = cell.BackGround; cell.BackGround = mBGcolor; return(new RestoreColor(OGcolor, mCellName)); }
/************************************************************* * Name: Exec(Spreadsheet ssheet) * Date Created: March 8, 2017 * Date Last Modified: March 8, 2017 * Description: Restores old color for a cell *************************************************************/ public IUndoRedoCmd Exec(Spreadsheet ssheet) { Cell cell = ssheet.GetCell(m_Name); int old = (int)cell.BGColor; cell.BGColor = (uint)m_Color; RestoreBGColor oldBGClass = new RestoreBGColor(old, m_Name); return(oldBGClass); }
/************************************************************* * Name: Exec(Spreadsheet ssheet) * Date Created: March 8, 2017 * Date Last Modified: March 8, 2017 * Description: Restores old text for a cell *************************************************************/ public IUndoRedoCmd Exec(Spreadsheet ssheet) { Cell cell = ssheet.GetCell(m_Name); string old = cell.Text; cell.Text = m_Text; RestoreText oldTextClass = new RestoreText(old, m_Name); return(oldTextClass); }
//Restores a cell with the text it had previously (undo OR redo) public IUndoRedoCommand Execute(Spreadsheet spreadsheet) { //determine the "name of the cell so we can get it from the spreadsheet and edit it! string cellName = this.cell.ColumnIndex.ToString() + this.cell.RowIndex.ToString(); // Cell cell = spreadsheet.GetCell(cellName); //get the text that is currently in the cell, we will want it in case we undo/redo string currentText = cell.Text; //set the cell's text to the updated text cell.Text = this.text; //return the old cell and old text return(new RestoreText(cell, currentText)); }
//Unexec function that undo the cell text public void UnExec(object ss) { Spreadsheet undo = (Spreadsheet)ss; Cell undoCell = undo.GetCell(row, column); //if redo is null then set the redo text equal to undo text if (redoText == null && undoCell.newCellText != null) { redoText = string.Copy(undoCell.newCellText); } else { redoText = null; } undoCell.newCellText = undoText; }
//implement execute interface public IUndoRedoCmd Execute(Spreadsheet sheet) { Cell theCell = sheet.GetCell(_cellName); string oldText = theCell.Text; theCell.Text = _cellText; //return cmd for redo/undo stack return new TextCmd(_cellName, oldText); }
/// <summary> /// HW5 demo: set text for cells with strings/equations /// </summary> private void RunDemo() { var Rand = new Random(DateTime.Now.Millisecond); for (int i = 0; i < 50; i++) { int columnIndex = Rand.Next(0, 25); int rowIndex = Rand.Next(0, 49); var cell = _spreadsheet.GetCell(rowIndex, columnIndex); cell.Text = "Hello, world!"; } for (int i = 0; i < _spreadsheet.RowCount; i++) { var cell = _spreadsheet.GetCell(i, 1); cell.Text = "This is cell B" + (i + 1); cell = _spreadsheet.GetCell(i, 0); cell.Text = "=B" + (i + 1); } }
private void dataGridView1_CellBeginEdit_1(object sender, DataGridViewCellCancelEventArgs e) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = SpSheet.GetCell(e.ColumnIndex, e.RowIndex).Text; }