CPF/CPF.ReoGrid/Actions/AutoFillSerialAction.cs
2024-06-24 10:15:59 +08:00

52 lines
1.2 KiB
C#

using System;
namespace CPF.ReoGrid.Actions
{
public class AutoFillSerialAction : BaseWorksheetAction
{
public RangePosition SourceRange { get; set; }
public RangePosition TargetRange { get; set; }
public AutoFillSerialAction(RangePosition sourceRange, RangePosition targetRange)
{
this.SourceRange = sourceRange;
this.TargetRange = targetRange;
}
public override void Do()
{
this.backupedGrid = base.Worksheet.GetPartialGrid(this.TargetRange, PartialGridCopyFlag.CellData, ExPartialGridCopyFlag.None, false);
try
{
base.Worksheet.AutoFillSerial(this.SourceRange, this.TargetRange);
base.Worksheet.SelectionRange = RangePosition.Union(this.SourceRange, this.TargetRange);
}
catch (Exception ex)
{
base.Worksheet.NotifyExceptionHappen(ex);
}
}
public override void Undo()
{
try
{
base.Worksheet.SetPartialGrid(this.TargetRange, this.backupedGrid);
base.Worksheet.SelectionRange = this.SourceRange;
}
catch (Exception ex)
{
base.Worksheet.NotifyExceptionHappen(ex);
}
}
public override string GetName()
{
return "Fill Serial Action";
}
private PartialGrid backupedGrid;
}
}