public static FloatingObject[] GetFloatingObjectsInRange(CellRange range, Worksheet sheet) { List <FloatingObject> list = new List <FloatingObject>(); foreach (SpreadChart chart in sheet.Charts) { list.Add(chart); } foreach (Picture picture in sheet.Pictures) { list.Add(picture); } foreach (FloatingObject obj2 in sheet.FloatingObjects) { list.Add(obj2); } List <FloatingObject> list2 = new List <FloatingObject>(); foreach (FloatingObject obj3 in list) { CellRange range2 = new CellRange(obj3.StartRow, obj3.StartColumn, (obj3.EndRow - obj3.StartRow) + 1, (obj3.EndColumn - obj3.StartColumn) - 1); if (range.Contains(range2)) { list2.Add(obj3); } } return(list2.ToArray()); }
void IRangeSupport.Clear(int row, int column, int rowCount, int columnCount) { if (this.innerList != null) { List <SheetTable> list = new List <SheetTable>(); CellRange range = new CellRange(row, column, rowCount, columnCount); foreach (SheetTable table in this.innerList) { if (range.Contains(table.Range)) { list.Add(table); } } foreach (SheetTable table2 in list) { this.innerList.Remove(table2); } for (int i = 0; i < this.innerList.Count; i++) { SheetTable table3 = this.innerList[i]; if (table3 != null) { ((IRangeSupport)table3).Clear(row, column, rowCount, columnCount); } } } }
protected override RadExpression EvaluateOverride(FunctionEvaluationContext <object> context) { string reference = context.Arguments[0].ToString(); if (string.IsNullOrEmpty(reference)) { return(ErrorExpressions.ReferenceError); } List <CellReferenceRange> cellReferenceRanges = new List <CellReferenceRange>(); CellReferenceRangeExpression expression; if (NameConverter.TryConvertNamesToCellReferenceRangeExpression(reference, context.Worksheet, context.RowIndex, context.ColumnIndex, out expression)) { cellReferenceRanges.AddRange(expression.CellReferenceRanges); } if (cellReferenceRanges.Count == 1) { CellReferenceRange cellReferenceRange = cellReferenceRanges.First(); if (cellReferenceRange.Worksheet == context.Worksheet) { CellRange cellRange = cellReferenceRange.ToCellRange(); if (cellRange.Contains(context.RowIndex, context.ColumnIndex)) { return(ErrorExpressions.CyclicReference); } } } if (cellReferenceRanges.Count == 0) { return(ErrorExpressions.ReferenceError); } return(expression); }
/// <summary> /// 删除报表项后,若为正在编辑的对象,卸载属性Form /// </summary> /// <param name="p_item"></param> internal void AfterDelItem(RptItem p_item) { if ((_tabItem.Content == null && _tabCell.Content == null) || p_item == null || _curItem == null) { return; } if (p_item == _curItem) { ClearForms(); } else { CellRange oldItemRange = new CellRange(_curItem.Row, _curItem.Col, _curItem.RowSpan, _curItem.ColSpan); CellRange delItemRange = new CellRange(p_item.Row, p_item.Col, p_item.RowSpan, p_item.ColSpan); if (delItemRange.Contains(oldItemRange)) { ClearForms(); } } }
void MoveDataRange(Worksheet src, int fromRow, int fromColumn, int toRow, int toColumn, int rowCount, int columnCount) { if (src == (this.Sheet as Worksheet)) { this.MoveDataRange(fromRow, fromColumn, toRow, toColumn, rowCount, columnCount); } else { CellRange range = new CellRange(fromRow, fromColumn, rowCount, columnCount); int row = toRow - fromRow; int column = toColumn - fromColumn; using (List <SparklineGroup> .Enumerator enumerator = src.SheetSparklineGroupManager.Groups.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (Sparkline sparkline in enumerator.Current) { if (sparkline != null) { CalcExpression dateAxisReference = sparkline.DateAxisReference; CellRange expressionRange = GetExpressionRange(dateAxisReference); if (((expressionRange != null) && SameSource(src, dateAxisReference)) && (range.Contains(expressionRange) && range.Contains(sparkline.Row, sparkline.Column))) { sparkline.DateAxisReference = dateAxisReference.Offset(row, column, false, true); } CalcExpression dataReference = sparkline.DataReference; CellRange range3 = GetExpressionRange(dataReference); if (((range3 != null) && SameSource(src, dataReference)) && (range.Contains(range3) && range.Contains(sparkline.Row, sparkline.Column))) { sparkline.DataReference = dataReference.Offset(row, column, false, true); } } } } } } }
void Execute(Excel excel, string formula) { if (excel != null) { try { if (string.IsNullOrWhiteSpace(formula)) { if ((_arrayFormulaRange.ColumnCount == 1) && (_arrayFormulaRange.RowCount == 1)) { object[,] objArray = excel.ActiveSheet.FindFormulas(_arrayFormulaRange.Row, _arrayFormulaRange.Column, _arrayFormulaRange.RowCount, _arrayFormulaRange.ColumnCount); for (int i = 0; i < objArray.GetLength(0); i++) { CellRange range = objArray[i, 0] as CellRange; string str = (string)(objArray[i, 1] as string); if (((str.StartsWith("{") && (range.Row <= _arrayFormulaRange.Row)) && ((range.Column <= _arrayFormulaRange.Column) && ((range.Row + range.RowCount) >= (_arrayFormulaRange.Row + _arrayFormulaRange.RowCount)))) && ((range.Column + range.ColumnCount) >= (_arrayFormulaRange.Column + _arrayFormulaRange.ColumnCount))) { _arrayFormulaRange = range; using (((IUIActionExecuter)_workSheet).BeginUIAction()) { excel.ActiveSheet.SetArrayFormula(_arrayFormulaRange.Row, _arrayFormulaRange.Column, _arrayFormulaRange.RowCount, _arrayFormulaRange.ColumnCount, formula); break; } } } } } else { if ((formula.Length > 1) && formula.StartsWith("=")) { if ((_arrayFormulaRange.ColumnCount == 1) && (_arrayFormulaRange.RowCount == 1)) { object[,] objArray2 = excel.ActiveSheet.FindFormulas(_arrayFormulaRange.Row, _arrayFormulaRange.Column, _arrayFormulaRange.RowCount, _arrayFormulaRange.ColumnCount); for (int k = 0; k < objArray2.GetLength(0); k++) { CellRange range2 = objArray2[k, 0] as CellRange; string str2 = (string)(objArray2[k, 1] as string); if (str2.StartsWith("{")) { if (((range2.Row <= _arrayFormulaRange.Row) && (range2.Column <= _arrayFormulaRange.Column)) && (((range2.Row + range2.RowCount) >= (_arrayFormulaRange.Row + _arrayFormulaRange.RowCount)) && ((range2.Column + range2.ColumnCount) >= (_arrayFormulaRange.Column + _arrayFormulaRange.ColumnCount)))) { _arrayFormulaRange = range2; break; } if (((range2.Row == -1) && (range2.RowCount == -1)) && range2.Contains(_arrayFormulaRange)) { _arrayFormulaRange = range2; break; } if (((range2.Column == -1) && (range2.ColumnCount == -1)) && range2.Contains(_arrayFormulaRange)) { _arrayFormulaRange = range2; break; } } } } using (((IUIActionExecuter)_workSheet).BeginUIAction()) { excel.ActiveSheet.SetArrayFormula(_arrayFormulaRange.Row, _arrayFormulaRange.Column, _arrayFormulaRange.RowCount, _arrayFormulaRange.ColumnCount, formula); return; } } for (int j = 0; j < _arrayFormulaRange.RowCount; j++) { for (int m = 0; m < _arrayFormulaRange.ColumnCount; m++) { excel.ActiveSheet.SetValue(_arrayFormulaRange.Row + j, _arrayFormulaRange.Column + m, formula); } } } } finally { excel.StopCellEditing(true); excel.RefreshAll(); } } }
void BuildSelection() { _cachedSelectionLayout.Clear(); _cachedFocusCellLayout = _rcEmpty; _cachedSelectionFrameLayout = _rcEmpty; _cachedActiveSelectionLayout = _rcEmpty; _cachedActiveSelection = null; _activeRow = Excel.ActiveSheet.ActiveRowIndex; _activeCol = Excel.ActiveSheet.ActiveColumnIndex; _selectionLayer.IsAnchorCellInSelection = false; var indicator = _selectionLayer.FocusIndicator; RowLayoutModel rowLayoutModel = GetRowLayoutModel(); ColumnLayoutModel colLayoutModel = Excel.GetViewportColumnLayoutModel(ColumnViewportIndex); if (rowLayoutModel == null || rowLayoutModel.Count == 0 || colLayoutModel == null || colLayoutModel.Count == 0) { indicator.HideAll(); return; } CellRange activeCellRange = GetActiveCellRange(); List <CellRange> ranges = new List <CellRange>((IEnumerable <CellRange>)Excel.ActiveSheet.Selections); if (ranges.Count == 0) { ranges.Add(activeCellRange); } int rangeCount = ranges.Count; Size viewportSize = GetViewportSize(); Rect rectViewport = new Rect(0.0, 0.0, viewportSize.Width, viewportSize.Height); int topRow = rowLayoutModel[0].Row; int bottomRow = rowLayoutModel[rowLayoutModel.Count - 1].Row; int leftCol = colLayoutModel[0].Column; int rightCol = colLayoutModel[colLayoutModel.Count - 1].Column; for (int i = 0; i < rangeCount; i++) { CellRange range = ranges[i]; if (range.Contains(_activeRow, _activeCol)) { _selectionLayer.IsAnchorCellInSelection = true; } int num7 = (range.Row < 0) ? 0 : range.Row; int num8 = (range.Column < 0) ? 0 : range.Column; int rowCount = (range.RowCount < 0) ? Excel.ActiveSheet.RowCount : range.RowCount; int columnCount = (range.ColumnCount < 0) ? Excel.ActiveSheet.ColumnCount : range.ColumnCount; range = new CellRange(num7, num8, rowCount, columnCount); Rect rect2 = GetRangeBounds(range); rect2.Intersect(rectViewport); if (rect2.IsEmpty) { continue; } _cachedSelectionLayout.Add(new Rect(rect2.Left + 1.0, rect2.Top + 1.0, Math.Max((double)0.0, (double)(rect2.Width - 3.0)), Math.Max((double)0.0, (double)(rect2.Height - 3.0)))); if (range.Contains(activeCellRange)) { Rect rect3 = new Rect(rect2.Left + 1.0, rect2.Top + 1.0, Math.Max((double)0.0, (double)(rect2.Width - 3.0)), Math.Max((double)0.0, (double)(rect2.Height - 3.0))); if (_cachedActiveSelectionLayout.IsEmpty || (rangeCount == 1)) { _cachedActiveSelectionLayout = rect3; _cachedActiveSelection = range; } else { Rect rect4 = new Rect(rect3.Left, rect3.Top, rect3.Width, rect3.Height); rect4.Intersect(_cachedActiveSelectionLayout); if (rect4.IsEmpty) { _cachedActiveSelectionLayout = rect3; _cachedActiveSelection = range; } else if (ContainsRect(rect3, _cachedActiveSelectionLayout)) { _cachedActiveSelectionLayout = rect3; _cachedActiveSelection = range; } } } } Rect rangeBounds = GetRangeBounds(activeCellRange); if (!rangeBounds.IsEmpty) { rangeBounds = new Rect(rangeBounds.Left + 1.0, rangeBounds.Top + 1.0, Math.Max((double)0.0, (double)(rangeBounds.Width - 3.0)), Math.Max((double)0.0, (double)(rangeBounds.Height - 3.0))); } _cachedFocusCellLayout = rangeBounds; // 只一个选择区域 if (rangeCount == 1) { CellRange range = ranges[0]; if (!_selectionLayer.IsAnchorCellInSelection) { range = activeCellRange; } Rect bounds = GetRangeBounds(range); bounds.Intersect(rectViewport); if (bounds.IsEmpty) { indicator.HideAll(); return; } if ((range.Row == -1) && (range.Column == -1)) { // 全选 indicator.Thickness = 1.0; _cachedSelectionFrameLayout = bounds; } else if (!_selectionLayer.IsAnchorCellInSelection) { indicator.Thickness = 1.0; _cachedSelectionFrameLayout = new Rect(bounds.Left, bounds.Top, bounds.Width, bounds.Height); } else { indicator.Thickness = 3.0; _cachedSelectionFrameLayout = new Rect(bounds.Left - 2.0, bounds.Top - 2.0, bounds.Width + 3.0, bounds.Height + 3.0); } if (!Excel.IsDraggingFill && range.Intersects(topRow, leftCol, rowLayoutModel.Count, colLayoutModel.Count)) { if (range.Row == -1) { indicator.IsTopVisible = topRow == 0; indicator.IsBottomVisible = bottomRow == (Excel.ActiveSheet.RowCount - 1); } else { indicator.IsTopVisible = (range.Row >= topRow) && (range.Row <= bottomRow); int num11 = (range.Row + range.RowCount) - 1; indicator.IsBottomVisible = (num11 >= topRow) && (num11 <= bottomRow); } if (range.Column == -1) { indicator.IsLeftVisible = leftCol == 0; indicator.IsRightVisible = rightCol == (Excel.ActiveSheet.ColumnCount - 1); } else { indicator.IsLeftVisible = (range.Column >= leftCol) && (range.Column <= rightCol); int num12 = (range.Column + range.ColumnCount) - 1; indicator.IsRightVisible = (num12 >= leftCol) && (num12 <= rightCol); } } else { indicator.IsTopVisible = false; indicator.IsBottomVisible = false; indicator.IsLeftVisible = false; indicator.IsRightVisible = false; } if (Excel.CanUserDragFill) { if (!Excel.IsDraggingFill) { if (((bounds.Width == 0.0) || (bounds.Height == 0.0)) || (indicator.Thickness == 1.0)) { indicator.IsFillIndicatorVisible = false; } else if ((range.Row != -1) && (range.Column != -1)) { bool flag = indicator.IsRightVisible && indicator.IsBottomVisible; if (Excel.InputDeviceType == InputDeviceType.Touch) { flag = false; } indicator.IsFillIndicatorVisible = flag; if (flag) { indicator.FillIndicatorPosition = FillIndicatorPosition.BottomRight; } } else if ((range.Row != -1) && (range.Column == -1)) { ViewportInfo viewportInfo = Excel.GetViewportInfo(); bool flag2; if (Excel.ActiveSheet.FrozenColumnCount == 0) { flag2 = (ColumnViewportIndex >= 0) && (ColumnViewportIndex < viewportInfo.ColumnViewportCount); } else { flag2 = (ColumnViewportIndex == -1) || ((ColumnViewportIndex >= 1) && (ColumnViewportIndex < viewportInfo.ColumnViewportCount)); } flag2 = flag2 && indicator.IsBottomVisible; if (Excel.InputDeviceType == InputDeviceType.Touch) { flag2 = false; } indicator.IsFillIndicatorVisible = flag2; if (flag2) { indicator.FillIndicatorPosition = FillIndicatorPosition.BottomLeft; } } else if ((range.Column != -1) && (range.Row == -1)) { ViewportInfo info2 = Excel.GetViewportInfo(); bool flag3; if (Excel.ActiveSheet.FrozenRowCount == 0) { flag3 = (RowViewportIndex >= 0) && (RowViewportIndex < info2.RowViewportCount); } else { flag3 = (RowViewportIndex == -1) || ((RowViewportIndex >= 1) && (RowViewportIndex < info2.RowViewportCount)); } flag3 = flag3 && indicator.IsRightVisible; if (Excel.InputDeviceType == InputDeviceType.Touch) { flag3 = false; } indicator.IsFillIndicatorVisible = flag3; if (flag3) { indicator.FillIndicatorPosition = FillIndicatorPosition.TopRight; } } else { indicator.IsFillIndicatorVisible = false; } } } else { indicator.IsFillIndicatorVisible = false; } return; } // 多个选择区域 Rect rect7 = GetRangeBounds(activeCellRange); if (!rect7.IsEmpty) { indicator.Thickness = 1.0; _cachedSelectionFrameLayout = rect7; _cachedSelectionFrameLayout.Width = Math.Max((double)0.0, (double)(_cachedSelectionFrameLayout.Width - 1.0)); _cachedSelectionFrameLayout.Height = Math.Max((double)0.0, (double)(_cachedSelectionFrameLayout.Height - 1.0)); int num13 = 0; int num14 = 0; int num15 = 0; int num16 = 0; for (int j = 0; j < rangeCount; j++) { CellRange range4 = ranges[j]; if (range4 != null) { if (activeCellRange.Row == range4.Row) { num14 = 1; } if (activeCellRange.Column == range4.Column) { num13 = 1; } if (activeCellRange.Row == ((range4.Row + range4.RowCount) - 1)) { num16 = 1; } if (activeCellRange.Column == ((range4.Column + range4.ColumnCount) - 1)) { num15 = 1; } } } _cachedSelectionFrameLayout.Y += num14; _cachedSelectionFrameLayout.Height = Math.Max((double)0.0, (double)(_cachedSelectionFrameLayout.Height - (num14 + num16))); _cachedSelectionFrameLayout.X += num13; _cachedSelectionFrameLayout.Width = Math.Max((double)0.0, (double)(_cachedSelectionFrameLayout.Width - (num13 + num15))); } indicator.IsBottomVisible = true; indicator.IsTopVisible = true; indicator.IsLeftVisible = true; indicator.IsRightVisible = true; indicator.IsFillIndicatorVisible = false; }
void UpdateActiveSelectionLayouts() { Rect rcSelection = _owner._cachedActiveSelectionLayout; Rect rcFocus = _owner._cachedFocusCellLayout; CellRange range = null; _activeSelectionLayouts.Clear(); CellRange viewportRange = GetViewportRange(); if (_owner.IsActived && (_owner.Excel.ActiveSheet.ActiveCell != null)) { Worksheet ws = _owner.Excel.ActiveSheet; range = new CellRange(ws.ActiveRowIndex, ws.ActiveColumnIndex, 1, 1); CellRange range3 = ws.SpanModel.Find(range.Row, range.Column); if ((range3 != null) && viewportRange.Intersects(range3.Row, range3.Column, range3.RowCount, range3.ColumnCount)) { range = CellRange.GetIntersect(viewportRange, range3, viewportRange.RowCount, viewportRange.ColumnCount); } } if (_owner.IsActived) { if ((viewportRange.RowCount == 0) || (viewportRange.ColumnCount == 0)) { _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); } else if ((range != null) && !viewportRange.Contains(range)) { _activeSelectionLayouts.Add(rcSelection); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); } else if (_owner._cachedActiveSelection != null && range != null && IsActiveCellBoundsValid && _owner._cachedActiveSelection != range && _owner._cachedActiveSelection.Contains(range)) { Rect rect3 = new Rect(rcSelection.X, rcSelection.Y, rcSelection.Width, rcFocus.Y - rcSelection.Y); Rect rect4 = new Rect(rcSelection.X, rcFocus.Y, rcFocus.X - rcSelection.X, rcFocus.Height); double width = rcSelection.Right - rcFocus.Right; if (width < 0.0) { width = 0.0; } Rect rect5 = new Rect(rcFocus.Right, rcFocus.Y, width, rcFocus.Height); double height = rcSelection.Bottom - rcFocus.Bottom; if (height < 0.0) { height = 0.0; } Rect rect6 = new Rect(rcSelection.X, rcFocus.Bottom, rcSelection.Width, height); _activeSelectionLayouts.Add(rect3); _activeSelectionLayouts.Add(rect4); _activeSelectionLayouts.Add(rect5); _activeSelectionLayouts.Add(rect6); } else { _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); } } else if ((viewportRange.RowCount == 0) || (viewportRange.ColumnCount == 0)) { _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); } else { _activeSelectionLayouts.Add(rcSelection); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); _activeSelectionLayouts.Add(Rect.Empty); } }
/// <summary> /// Undoes the action of the saved information. /// </summary> /// <param name="parameter">The parameter to undo the action on. </param> /// <returns> /// <c>true</c> if the undo action succeeds; otherwise, <c>false</c>. /// </returns> public bool Undo(object parameter) { if (!Excel.IsValidRange(_dragDropExtent.FromRow, _dragDropExtent.FromColumn, _dragDropExtent.RowCount, _dragDropExtent.ColumnCount, _sheet.RowCount, _sheet.ColumnCount)) { return(false); } if (!_insert && !Excel.IsValidRange(_dragDropExtent.ToRow, _dragDropExtent.ToColumn, _dragDropExtent.RowCount, _dragDropExtent.ColumnCount, _sheet.RowCount, _sheet.ColumnCount)) { return(false); } bool flag = false; Excel sheetView = parameter as Excel; if (_insert) { if ((_dragDropExtent.FromColumn < 0) || (_dragDropExtent.FromRow < 0)) { if (_dragDropExtent.FromColumn >= 0) { int fromColumn = _dragDropExtent.FromColumn; int columnCount = _dragDropExtent.ColumnCount; base.SuspendInvalidate(parameter); try { if (_copy) { _sheet.RemoveColumns(_dragDropExtent.ToColumn, columnCount); } else { int toColumn = _dragDropExtent.ToColumn; int column = _dragDropExtent.FromColumn; if (_dragDropExtent.FromColumn < _dragDropExtent.ToColumn) { toColumn = _dragDropExtent.ToColumn - columnCount; } else { column = _dragDropExtent.FromColumn + columnCount; } _sheet.AddColumns(column, columnCount); _sheet.CopyTo(-1, (column <= toColumn) ? (toColumn + columnCount) : toColumn, -1, column, -1, columnCount, _option); _sheet.RemoveColumns((column <= toColumn) ? (toColumn + columnCount) : toColumn, columnCount); if (toColumn < column) { fromColumn = column - columnCount; } } } finally { base.ResumeInvalidate(parameter); } if (sheetView != null) { CellRange[] oldSelection = Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections); sheetView.SetSelection(-1, fromColumn, -1, columnCount); if (sheetView.RaiseSelectionChanging(oldSelection, Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections))) { sheetView.RaiseSelectionChanged(); } sheetView.RefreshRange(-1, -1, -1, -1, SheetArea.Cells | SheetArea.ColumnHeader | SheetArea.RowHeader); sheetView.RefreshFloatingObjects(); } flag = true; } else if (_dragDropExtent.FromRow >= 0) { int rowCount = _dragDropExtent.RowCount; int fromRow = _dragDropExtent.FromRow; base.SuspendInvalidate(parameter); try { if (_copy) { _sheet.RemoveRows(_dragDropExtent.ToRow, rowCount); } else { int toRow = _dragDropExtent.ToRow; int row = _dragDropExtent.FromRow; if (_dragDropExtent.FromRow < _dragDropExtent.ToRow) { toRow = _dragDropExtent.ToRow - rowCount; } else { row = _dragDropExtent.FromRow + rowCount; } _sheet.AddRows(row, rowCount); if (_savedFromViewportCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedFromViewportCells, row, 0, SheetArea.Cells); flag = true; } if (_savedFromRowHeaderCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedFromRowHeaderCells, row, 0, SheetArea.CornerHeader | SheetArea.RowHeader); flag = true; } if (_savedFromRows != null) { CopyMoveHelper.UndoRowsInfo(_sheet, _savedFromRows, row); flag = true; } if (!flag) { _sheet.MoveTo((row <= toRow) ? (toRow + rowCount) : toRow, -1, row, -1, rowCount, -1, _option); } _sheet.RemoveRows((row <= toRow) ? (toRow + rowCount) : toRow, rowCount); if (toRow < row) { fromRow = row - rowCount; } } } finally { base.ResumeInvalidate(parameter); } if (sheetView != null) { CellRange[] rangeArray2 = Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections); sheetView.SetSelection(fromRow, -1, rowCount, -1); if (sheetView.RaiseSelectionChanging(rangeArray2, Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections))) { sheetView.RaiseSelectionChanged(); } sheetView.RefreshAll(); sheetView.UpdateLayout(); sheetView.RefreshFloatingObjects(); } flag = true; } } } else { int num9 = (_dragDropExtent.FromRow < 0) ? 0 : _dragDropExtent.FromRow; int num10 = (_dragDropExtent.FromColumn < 0) ? 0 : _dragDropExtent.FromColumn; int num11 = (_dragDropExtent.ToRow < 0) ? 0 : _dragDropExtent.ToRow; int num12 = (_dragDropExtent.ToColumn < 0) ? 0 : _dragDropExtent.ToColumn; int num13 = (_dragDropExtent.FromRow < 0) ? _sheet.RowCount : _dragDropExtent.RowCount; int num14 = (_dragDropExtent.FromColumn < 0) ? _sheet.ColumnCount : _dragDropExtent.ColumnCount; List <CellData> oldValues = null; List <CellData> list2 = null; if ((!_copy && (_savedFromViewportCells != null)) && _savedFromViewportCells.IsValueSaved()) { list2 = CopyMoveHelper.GetValues(_sheet, num9, num10, num13, num14); } if ((_savedToViewportCells != null) && _savedToViewportCells.IsValueSaved()) { oldValues = CopyMoveHelper.GetValues(_sheet, num11, num12, num13, num14); } base.SuspendInvalidate(parameter); try { if (_savedToColumnHeaderCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedToColumnHeaderCells, 0, num12, SheetArea.ColumnHeader); flag = true; } if (_savedToColumns != null) { CopyMoveHelper.UndoColumnsInfo(_sheet, _savedToColumns, num12); flag = true; } if (_savedToViewportCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedToViewportCells, num11, num12, SheetArea.Cells); flag = true; } if (_savedToRowHeaderCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedToRowHeaderCells, num11, 0, SheetArea.CornerHeader | SheetArea.RowHeader); flag = true; } if (_savedToRows != null) { CopyMoveHelper.UndoRowsInfo(_sheet, _savedToRows, num11); flag = true; } if (_savedToFloatingObjects != null) { CopyMoveHelper.UndoFloatingObjectsInfo(_sheet, _savedToFloatingObjects); sheetView.RefreshFloatingObjects(); flag = true; } if (_savedFromColumnHeaderCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedFromColumnHeaderCells, 0, num10, SheetArea.ColumnHeader); flag = true; } if (_savedFromColumns != null) { CopyMoveHelper.UndoColumnsInfo(_sheet, _savedFromColumns, num10); flag = true; } if (_savedFromViewportCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedFromViewportCells, num9, num10, SheetArea.Cells); flag = true; } if (_savedFromRowHeaderCells != null) { CopyMoveHelper.UndoCellsInfo(_sheet, _savedFromRowHeaderCells, num9, 0, SheetArea.CornerHeader | SheetArea.RowHeader); flag = true; } if (_savedFromRows != null) { CopyMoveHelper.UndoRowsInfo(_sheet, _savedFromRows, num9); flag = true; } if (_savedFromFloatingObjects != null) { CopyMoveHelper.UndoFloatingObjectsInfo(_sheet, _savedFromFloatingObjects); sheetView.RefreshFloatingObjects(); flag = true; } } finally { base.ResumeInvalidate(parameter); } if (flag && (sheetView != null)) { CellRange[] rangeArray3 = Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections); sheetView.SetSelection(_dragDropExtent.FromRow, _dragDropExtent.FromColumn, _dragDropExtent.RowCount, _dragDropExtent.ColumnCount); if (sheetView.RaiseSelectionChanging(rangeArray3, Enumerable.ToArray <CellRange>((IEnumerable <CellRange>)sheetView.ActiveSheet.Selections))) { sheetView.RaiseSelectionChanged(); } if (oldValues != null) { CopyMoveHelper.RaiseValueChanged(sheetView, num11, num12, num13, num14, oldValues); } if (list2 != null) { CopyMoveHelper.RaiseValueChanged(sheetView, num9, num10, num13, num14, list2); } sheetView.RefreshRange(-1, -1, -1, -1, SheetArea.Cells | SheetArea.ColumnHeader | SheetArea.RowHeader); sheetView.RefreshFloatingObjects(); } } if (flag && (sheetView != null)) { if ((_savedAcitveRowViewportIndex != -2) && (_savedAcitveColumnViewportIndex != -2)) { sheetView.SetActiveRowViewportIndex(_savedAcitveRowViewportIndex); sheetView.SetActiveColumnViewportIndex(_savedAcitveColumnViewportIndex); } if ((_savedActiveRow != -1) && (_savedActiveColumn != -1)) { CellRange range = sheetView.ActiveSheet.Selections[0]; if (range.Contains(_savedActiveRow, _savedActiveColumn)) { sheetView.SetActiveCell(_savedActiveRow, _savedActiveColumn, false); } else { sheetView.SetActiveCell(Math.Max(0, range.Row), Math.Max(0, range.Column), false); } } if (((_savedAcitveRowViewportIndex != -2) && (_savedAcitveColumnViewportIndex != -2)) && ((_savedActiveRow != -1) && (_savedActiveColumn != -1))) { sheetView.ShowCell(_savedAcitveRowViewportIndex, _savedAcitveColumnViewportIndex, _savedActiveRow, _savedActiveColumn, VerticalPosition.Nearest, HorizontalPosition.Nearest); } } return(flag); }