185 lines
3.1 KiB
C#
185 lines
3.1 KiB
C#
![]() |
using System;
|
|||
|
using System.Diagnostics;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.ReoGrid.Events;
|
|||
|
|
|||
|
namespace CPF.ReoGrid
|
|||
|
{
|
|||
|
public class RowHeader : ReoGridHeader
|
|||
|
{
|
|||
|
internal RowHeader(Worksheet sheet) : base(sheet)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public int Top { get; internal set; }
|
|||
|
|
|||
|
internal ushort InnerHeight { get; set; }
|
|||
|
|
|||
|
public ushort Height
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.InnerHeight;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
this.VerifyWorksheet();
|
|||
|
base.Worksheet.SetRowsHeight(this.Row, 1, value);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal ushort LastHeight { get; set; }
|
|||
|
|
|||
|
public int Bottom
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.Top + (int)this.InnerHeight;
|
|||
|
}
|
|||
|
internal set
|
|||
|
{
|
|||
|
int num = value - this.Top;
|
|||
|
bool flag = num < 0;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
num = 0;
|
|||
|
}
|
|||
|
this.InnerHeight = (ushort)num;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal int Row { get; set; }
|
|||
|
|
|||
|
public override int Index
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.Row;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string Text
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.text;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
this.text = value;
|
|||
|
bool flag = base.Worksheet != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
base.Worksheet.RequestInvalidate();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public Color? TextColor
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.textColor;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
bool flag = this.textColor != value;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.textColor = value;
|
|||
|
bool flag2 = base.Worksheet != null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
base.Worksheet.RequestInvalidate();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal WorksheetRangeStyle InnerStyle { get; set; }
|
|||
|
|
|||
|
public RowHeaderStyle Style
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
bool flag = this.refStyle == null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.refStyle = new RowHeaderStyle(base.Worksheet, this);
|
|||
|
}
|
|||
|
return this.refStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool IsAutoHeight { get; set; }
|
|||
|
|
|||
|
public override bool IsVisible
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.InnerHeight > 0;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
this.VerifyWorksheet();
|
|||
|
if (value)
|
|||
|
{
|
|||
|
base.Worksheet.ShowRows(this.Row, 1);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
base.Worksheet.HideRows(this.Row, 1);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void VerifyWorksheet()
|
|||
|
{
|
|||
|
bool flag = base.Worksheet == null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
throw new Exception("Row header must be associated to a grid instance.");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void FitHeightToCells(bool byAction = false)
|
|||
|
{
|
|||
|
base.Worksheet.AutoFitRowHeight(this.Row, byAction);
|
|||
|
}
|
|||
|
|
|||
|
internal RowHeader Clone(Worksheet newSheet)
|
|||
|
{
|
|||
|
return new RowHeader(newSheet)
|
|||
|
{
|
|||
|
Top = this.Top,
|
|||
|
InnerHeight = this.InnerHeight,
|
|||
|
InnerStyle = ((this.InnerStyle == null) ? null : WorksheetRangeStyle.Clone(this.InnerStyle)),
|
|||
|
IsAutoHeight = this.IsAutoHeight,
|
|||
|
TextColor = this.TextColor,
|
|||
|
text = this.text,
|
|||
|
Body = base.Body,
|
|||
|
Row = this.Row,
|
|||
|
LastHeight = this.LastHeight
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|||
|
public event EventHandler<RowsHeightChangedEventArgs> HeightChanged;
|
|||
|
|
|||
|
internal void RaiseHeightChangedEvent()
|
|||
|
{
|
|||
|
bool flag = this.HeightChanged != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.HeightChanged(this, new RowsHeightChangedEventArgs(this.Row, 1, (int)this.InnerHeight));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private string text;
|
|||
|
|
|||
|
private Color? textColor;
|
|||
|
|
|||
|
private RowHeaderStyle refStyle = null;
|
|||
|
}
|
|||
|
}
|