private static void AllocateImageSpace(StandardContentMemento memento,
IPaletteContent paletteContent,
IContentValues contentValues,
PaletteState state,
Rectangle displayRect,
RightToLeft rtl,
ref Size[,] allocation)
{
// By default, we cannot draw the image
memento.DrawImage = false;
// Get the image details
memento.Image = contentValues.GetImage(state);
memento.ImageTransparentColor = contentValues.GetImageTransparentColor(state);
// Is there any image to be drawn?
if (memento.Image != null)
{
try
{
// Cache the size of the image
memento.ImageRect.Size = memento.Image.Size;
// Check for enough space to show all of the image
if ((displayRect.Width >= memento.ImageRect.Width) &&
(displayRect.Height >= memento.ImageRect.Height))
{
// Convert from alignment enums to integers
int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentImageH(state));
int alignVIndex = (int)paletteContent.GetContentImageV(state);
// Bump the allocated space in the destination grid cell
allocation[alignHIndex, alignVIndex].Width += memento.ImageRect.Width;
allocation[alignHIndex, alignVIndex].Height += memento.ImageRect.Height;
// Yes, we do want to draw the image/icon
memento.DrawImage = true;
}
}
catch
{
// Image is not valid, so do not use it!
memento.Image = null;
memento.DrawImage = false;
}
}
}