private static void DrawGraphic(Graphics zGraphics, string sFile, ProjectLayoutElement zElement)
{
string sPath = sFile;
if (sPath.Equals("none", StringComparison.CurrentCultureIgnoreCase))
{
return;
}
if (!File.Exists(sPath))
{
sPath = ProjectManager.Instance.ProjectPath + sFile;
}
if (File.Exists(sPath))
{
var zBmp = 255 != zElement.opacity
? LoadOpacityImageFromCache(sPath, zElement)
: LoadImageFromCache(sPath);
int nWidth = zElement.width;
int nHeight = zElement.height;
if (zElement.keeporiginalsize)
{
DrawGraphicOriginalSize(zGraphics, zBmp, zElement);
return;
}
if (zElement.lockaspect)
{
var fAspect = (float)zBmp.Tag;
var nTargetHeight = (int)((float)nWidth / fAspect);
if (nTargetHeight < nHeight)
{
nHeight = (int)((float)nWidth / fAspect);
}
else
{
nWidth = (int)((float)nHeight * fAspect);
}
}
int nX = 0;
int nY = 0;
// standard alignment adjustment
UpdateAlignmentValue(zElement.GetHorizontalAlignment(), ref nX, zElement.width, nWidth);
UpdateAlignmentValue(zElement.GetVerticalAlignment(), ref nY, zElement.height, nHeight);
zGraphics.DrawImage(zBmp, nX, nY, nWidth, nHeight);
}
else
{
IssueManager.Instance.FireAddIssueEvent("Image file not found: " + sFile);
}
// draw nothing
}