Esempio n. 1
0
 //pushes new undo onto the stack
 public void addRedo(UndoRedoCollection redo)
 {
     _redos.Push(redo);
     SpreadSheet_StackPropertyChange("Redos");
 }
Esempio n. 2
0
        private void redoOperation()
        {
            //if the stack is not empty
            if (_spreadSheet.hasRedo())
            {
                UndoRedoCollection myRedo = _spreadSheet.getRedo();
                List<UndoRedo> myUndoList = new List<UndoRedo>();

                //for every object in the changedProperty list
                foreach (UndoRedo property in myRedo.changedProperty)
                {
                    //undo their function
                    myUndoList.Add(property.Reverse(_spreadSheet));
                    property.Execute(_spreadSheet);
                }

                UndoRedoCollection myUndo = new UndoRedoCollection(myUndoList);
                _spreadSheet.addUndo(myUndo);
            }
        }
Esempio n. 3
0
 //pushes new undo onto the stack
 public void addUndo(UndoRedoCollection undo)
 {
     _undos.Push(undo);
     SpreadSheet_StackPropertyChange("Undos");
 }
Esempio n. 4
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                var dgv = (DataGridView)sender;
                Cell myCell = _spreadSheet.getCell(dgv.CurrentCell.ColumnIndex, dgv.CurrentCell.RowIndex);

                //if the cells value ends as null, set the value to "".
                if (dgv.CurrentCell.Value == null)
                {
                    dgv.CurrentCell.Value = "";
                }

                //HANDLES THE UNDOING OF THIS FUNCTION
                if (dgv.CurrentCell.Value.ToString() != myCell.Text)
                {
                    //creates an undo redo collection of a text chage object that contains this specific cell
                    //and containsn the text of the cell before it has been altered
                    List<UndoRedo> changedProperties = new List<UndoRedo>();
                    changedProperties.Add(new textChange(myCell, myCell.Text));
                    UndoRedoCollection text = new UndoRedoCollection(changedProperties);

                    //adds it to the stack
                    _spreadSheet.addUndo(text);

                    //clears redo stack
                    _spreadSheet.clearRedo();
                }

                //at the end of edit, set myCell to the value ""
                _spreadSheet.setCellText(myCell, dgv.CurrentCell.Value.ToString());

                //Set the value of the cell to the evaluated myCell value.
                dgv.CurrentCell.Value = myCell.Value;
            }
        }