Пример #1
0
        private static bool CheckChanges(Worksheet worksheet, AreaUndoItems areaUndoItems)
        {
            var range  = GetRange(worksheet, areaUndoItems);
            var values = areaUndoItems.NewValues;

            if (!(range.Value is object[,] currentValue))
            {
                return(true);
            }

            int upperI = currentValue.GetUpperBound(0);             // Rows
            int upperJ = currentValue.GetUpperBound(1);             // Columns

            if (upperI != values.GetUpperBound(0) ||
                upperJ != values.GetUpperBound(1) ||
                currentValue.GetLowerBound(0) != values.GetLowerBound(0) ||
                currentValue.GetLowerBound(1) != values.GetLowerBound(1))
            {
                return(true);
            }

            for (int i = currentValue.GetLowerBound(0); i <= upperI; i++)
            {
                for (int j = currentValue.GetLowerBound(1); j <= upperJ; j++)
                {
                    if (currentValue[i, j] == null && values[i, j] == null)
                    {
                        continue;
                    }

                    if (currentValue[i, j] == null || values[i, j] == null)
                    {
                        return(true);
                    }

                    if (!currentValue[i, j].Equals(values[i, j]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #2
0
 private static Range GetRange(Worksheet worksheet, AreaUndoItems item)
 {
     return(worksheet.Range[
                worksheet.Cells[item.Row, item.Column],
                worksheet.Cells[item.Row + item.Height - 1, item.Column + item.Width - 1]]);
 }
Пример #3
0
 public void PushAreaUndoItem(AreaUndoItems undoItem)
 {
     areaUndoItems.Add(undoItem);
 }