bool Undo(Excel excel) { bool flag; CellRange[] oldSelection = (_workSheet.Selections != null) ? Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)_workSheet.Selections) : null; List <CellData> oldValues = null; CellRange fillRange = _dragFillExtent.FillRange; if ((_savedFilledViewportCells != null) && _savedFilledViewportCells.IsValueSaved()) { oldValues = CopyMoveHelper.GetValues(_workSheet, fillRange.Row, fillRange.Column, fillRange.RowCount, fillRange.ColumnCount); } if (_dragFillExtent.AutoFillType == AutoFillType.ClearValues) { flag = UndoDragClear(excel); } else { flag = UndoDragFill(excel); } excel.CloseDragFillPopup(); if ((oldValues != null) && object.ReferenceEquals(excel.ActiveSheet, _workSheet)) { CopyMoveHelper.RaiseValueChanged(excel, fillRange.Row, fillRange.Column, fillRange.RowCount, fillRange.ColumnCount, oldValues); } CellRange[] newSelection = (_workSheet.Selections != null) ? Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)_workSheet.Selections) : null; if (excel.RaiseSelectionChanging(oldSelection, newSelection)) { excel.RaiseSelectionChanged(); } excel.RefreshCellAreaViewport(0, 0, _workSheet.RowCount, _workSheet.ColumnCount); return(flag); }