namespace com.azkoss.excellite
{
using System;
using System.Drawing;
///
///Contains settings for a single cell border.
///
///
///Note that although diagonal-up (IndividualBorder.DiagonalUp
///or MultipleBorders.DiagonalUp) and diagonal-down
///(IndividualBorder.DiagonalDown or
///MultipleBorders.DiagonalDown) can be individually set,
///they share the same color and the same line style. This is a Microsoft Excel limitation.
///
///
public sealed class CellBorder
{
// Methods
internal CellBorder(CellStyle parent, IndividualBorder borderId)
{
this.parent = parent;
this.borderId = borderId;
this.borderIndex = CellBorder.IndexFromIndividualBorder(borderId);
}
internal static int IndexFromIndividualBorder(IndividualBorder individualBorder)
{
int num1 = (int) individualBorder;
if (num1 == 5)
{
num1 = 4;
}
return num1;
}
internal static MultipleBorders MultipleFromIndividualBorder(IndividualBorder individualBorder)
{
return (MultipleBorders) (((int) IndividualBorder.Bottom) << ((int)individualBorder & 0x1f));
}
public void SetBorder(Color lineColor, com.azkoss.excellite.LineStyle lineStyle)
{
this.LineColor = lineColor;
this.LineStyle = lineStyle;
}
private void SetUsedIfNotDefault()
{
CellStyleData data1 = this.parent.Element;
if ((data1.BorderStyle[this.borderIndex] != com.azkoss.excellite.LineStyle.None) || (data1.BorderColor[this.borderIndex].ToArgb() != Color.Black.ToArgb()))
{
data1.BordersUsed |= CellBorder.MultipleFromIndividualBorder(this.borderId);
}
}
// Properties
///
///Gets or sets border line color.
///
///
///Note that although diagonal-up (IndividualBorder.DiagonalUp
///or MultipleBorders.DiagonalUp) and diagonal-down
///(IndividualBorder.DiagonalDown or
///MultipleBorders.DiagonalDown) can be individually set,
///they share the same color and the same line style. This is a Microsoft Excel limitation.
///
public Color LineColor
{
get
{
return this.parent.Element.BorderColor[this.borderIndex];
}
set
{
this.parent.BeforeChange();
this.parent.Element.BorderColor[this.borderIndex] = value;
this.SetUsedIfNotDefault();
}
}
public com.azkoss.excellite.LineStyle LineStyle
{
get
{
return this.parent.Element.BorderStyle[this.borderIndex];
}
set
{
this.parent.BeforeChange();
this.parent.Element.BorderStyle[this.borderIndex] = value;
this.SetUsedIfNotDefault();
}
}
// Fields
private readonly IndividualBorder borderId;
private readonly int borderIndex;
private readonly CellStyle parent;
}
}