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

109 lines
2.5 KiB
C#

using System;
namespace CPF.ReoGrid
{
[Serializable]
public class CellBorderProperty
{
internal CellBorderProperty(Cell cell)
{
this.cell = cell;
}
private void CheckForOwnerAssociated()
{
bool flag = this.cell == null;
if (flag)
{
throw new ReferenceObjectNotAssociatedException("Border property is not associated to any cells. Border might have been deleted from the cell. Try get this property from cell again.");
}
}
public RangeBorderStyle Left
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.Left, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.PositionAsRange, BorderPositions.Left, value);
}
}
public RangeBorderStyle Top
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.Top, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.PositionAsRange, BorderPositions.Top, value);
}
}
public RangeBorderStyle Right
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.Right, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.PositionAsRange, BorderPositions.Right, value);
}
}
public RangeBorderStyle Bottom
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.Bottom, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.PositionAsRange, BorderPositions.Bottom, value);
}
}
public RangeBorderStyle Outside
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.Outside, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.PositionAsRange, BorderPositions.Outside, value);
}
}
public RangeBorderStyle All
{
get
{
this.CheckForOwnerAssociated();
return this.cell.Worksheet.GetGridBorder(this.cell.Row, this.cell.Column, BorderPositions.All, true);
}
set
{
this.CheckForOwnerAssociated();
this.cell.Worksheet.SetRangeBorders(this.cell.Row, this.cell.Column, 1, 1, BorderPositions.All, value);
}
}
private Cell cell;
}
}