79 lines
1.8 KiB
C#
79 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CPF.ReoGrid.Actions
|
|
{
|
|
public class SetRowsHeightAction : WorksheetReusableAction
|
|
{
|
|
public ushort Height
|
|
{
|
|
get
|
|
{
|
|
return this.height;
|
|
}
|
|
set
|
|
{
|
|
this.height = value;
|
|
}
|
|
}
|
|
|
|
public SetRowsHeightAction(int row, int count, ushort height) : base(new RangePosition(row, 0, count, -1))
|
|
{
|
|
this.height = height;
|
|
}
|
|
|
|
public override void Do()
|
|
{
|
|
int row = base.Range.Row;
|
|
int rows = base.Range.Rows;
|
|
this.backupRows.Clear();
|
|
int num = row + rows;
|
|
for (int i = row; i < num; i++)
|
|
{
|
|
RowHeader rowHeader = base.Worksheet.RetrieveRowHeader(i);
|
|
this.backupRows.Add(i, new SetRowsHeightAction.RowHeadData
|
|
{
|
|
autoHeight = rowHeader.IsAutoHeight,
|
|
row = rowHeader.Row,
|
|
height = rowHeader.InnerHeight
|
|
});
|
|
rowHeader.IsAutoHeight = false;
|
|
}
|
|
base.Worksheet.SetRowsHeight(row, rows, this.height);
|
|
}
|
|
|
|
public override void Undo()
|
|
{
|
|
base.Worksheet.SetRowsHeight(base.Range.Row, base.Range.Rows, (int r) => (int)this.backupRows[r].height, true);
|
|
foreach (int num in this.backupRows.Keys)
|
|
{
|
|
RowHeader rowHeader = base.Worksheet.RetrieveRowHeader(num);
|
|
rowHeader.IsAutoHeight = this.backupRows[num].autoHeight;
|
|
}
|
|
}
|
|
|
|
public override string GetName()
|
|
{
|
|
return "Set Rows Height: " + this.height.ToString();
|
|
}
|
|
|
|
public override WorksheetReusableAction Clone(RangePosition range)
|
|
{
|
|
return new SetRowsHeightAction(range.Row, range.Rows, this.height);
|
|
}
|
|
|
|
private ushort height;
|
|
|
|
private Dictionary<int, SetRowsHeightAction.RowHeadData> backupRows = new Dictionary<int, SetRowsHeightAction.RowHeadData>();
|
|
|
|
internal struct RowHeadData
|
|
{
|
|
internal int row;
|
|
|
|
internal ushort height;
|
|
|
|
internal bool autoHeight;
|
|
}
|
|
}
|
|
}
|