private static Point PositionCellContent(RightToLeft rtl,
PaletteRelativeAlign drawH,
PaletteRelativeAlign drawV,
Size contentSize,
int spacingGap,
ref Rectangle cellRect)
{
Point location = Point.Empty;
// If drawing from right to left...
if (rtl == RightToLeft.Yes)
{
// Then invert the near and far positioning
if (drawH == PaletteRelativeAlign.Near)
drawH = PaletteRelativeAlign.Far;
else if (drawH == PaletteRelativeAlign.Far)
drawH = PaletteRelativeAlign.Near;
}
switch (drawH)
{
case PaletteRelativeAlign.Near:
location.X = cellRect.Left;
cellRect.X += (contentSize.Width + spacingGap);
cellRect.Width -= (contentSize.Width + spacingGap);
break;
case PaletteRelativeAlign.Center:
int halfHorz = (cellRect.Width - contentSize.Width) / 2;
location.X = cellRect.Left + halfHorz;
break;
case PaletteRelativeAlign.Far:
location.X = cellRect.Right - contentSize.Width;
cellRect.Width -= (contentSize.Width + spacingGap);
break;
}
switch (drawV)
{
case PaletteRelativeAlign.Near:
location.Y = cellRect.Top;
break;
case PaletteRelativeAlign.Center:
int halfVert = (cellRect.Height - contentSize.Height) / 2;
location.Y = cellRect.Top + halfVert;
break;
case PaletteRelativeAlign.Far:
location.Y = cellRect.Bottom - contentSize.Height;
break;
}
return location;
}