85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
![]() |
using System;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.ReoGrid.Rendering;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.CellTypes
|
|||
|
{
|
|||
|
public abstract class ContentCellBody : CellBody
|
|||
|
{
|
|||
|
public virtual Rect ContentBounds { get; set; }
|
|||
|
|
|||
|
protected virtual Size GetContentSize()
|
|||
|
{
|
|||
|
float num = 17f;
|
|||
|
float num2 = 17f;
|
|||
|
return new Size(ref num, ref num2);
|
|||
|
}
|
|||
|
|
|||
|
public override void OnBoundsChanged()
|
|||
|
{
|
|||
|
base.OnBoundsChanged();
|
|||
|
float num = 0f;
|
|||
|
float num2 = 0f;
|
|||
|
Point point = new Point(ref num, ref num2);
|
|||
|
Size contentSize = this.GetContentSize();
|
|||
|
Rect contentBounds = new Rect(ref point, ref contentSize);
|
|||
|
bool flag = base.Cell != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
float num3 = 0f;
|
|||
|
float num4 = 0f;
|
|||
|
switch (base.Cell.InnerStyle.HAlign)
|
|||
|
{
|
|||
|
case ReoGridHorAlign.Left:
|
|||
|
num3 = this.Bounds.X + 1f;
|
|||
|
break;
|
|||
|
case ReoGridHorAlign.Center:
|
|||
|
num3 = this.Bounds.X + (this.Bounds.Width - contentBounds.Width) / 2f;
|
|||
|
break;
|
|||
|
case ReoGridHorAlign.Right:
|
|||
|
num3 = this.Bounds.Right - contentBounds.Width - 1f;
|
|||
|
break;
|
|||
|
}
|
|||
|
switch (base.Cell.InnerStyle.VAlign)
|
|||
|
{
|
|||
|
case ReoGridVerAlign.Top:
|
|||
|
num4 = this.Bounds.Y + 1f;
|
|||
|
break;
|
|||
|
case ReoGridVerAlign.Middle:
|
|||
|
num4 = this.Bounds.Y + (this.Bounds.Height - contentBounds.Height) / 2f;
|
|||
|
break;
|
|||
|
case ReoGridVerAlign.Bottom:
|
|||
|
num4 = this.Bounds.Bottom - contentBounds.Height - 1f;
|
|||
|
break;
|
|||
|
}
|
|||
|
num = contentBounds.Width;
|
|||
|
num2 = contentBounds.Height;
|
|||
|
contentBounds = new Rect(ref num3, ref num4, ref num, ref num2);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num = base.Bounds.X + (base.Bounds.Width - contentBounds.Width) / 2f;
|
|||
|
num2 = base.Bounds.Y + (base.Bounds.Height - contentBounds.Height) / 2f;
|
|||
|
float width = contentBounds.Width;
|
|||
|
float height = contentBounds.Height;
|
|||
|
contentBounds = new Rect(ref num, ref num2, ref width, ref height);
|
|||
|
}
|
|||
|
this.ContentBounds = contentBounds;
|
|||
|
}
|
|||
|
|
|||
|
public override void OnPaint(CellDrawingContext dc)
|
|||
|
{
|
|||
|
dc.DrawCellBackground();
|
|||
|
bool flag = this.ContentBounds.Width > 0f || this.ContentBounds.Height > 0f;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.OnContentPaint(dc);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void OnContentPaint(CellDrawingContext dc)
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
}
|