02-16-2011, 04:55 PM
Hello,
The MM_HIMETRIC mapping mode is currently not supported with Ab2d.ReaderWmf. I will try to add support for it in the future version (I cannot say when it will be available - I need to finish some other things first).
When using MM_HIMETRIC mapping mode the y asix is up instead of down. In this mode Ab2d.ReaderWmf wrongly adds bounds to the coordinates and wrongly calculates root canvas size.
The following code can be used as a workaround for your case (when you will use Paths or some other more complex objects it will not work any more):
The MM_HIMETRIC mapping mode is currently not supported with Ab2d.ReaderWmf. I will try to add support for it in the future version (I cannot say when it will be available - I need to finish some other things first).
When using MM_HIMETRIC mapping mode the y asix is up instead of down. In this mode Ab2d.ReaderWmf wrongly adds bounds to the coordinates and wrongly calculates root canvas size.
The following code can be used as a workaround for your case (when you will use Paths or some other more complex objects it will not work any more):
Code:
Viewbox viewbox = Ab2d.ReaderWmf.Instance.Read("testfilemftowpf.emf");
Canvas rootCanvas = (Canvas)viewbox.Child;
rootCanvas.Width = 2100;
rootCanvas.Height = 2970;
int boundsX = 473;
int boundsY = 260;
foreach (UIElement oneChild in rootCanvas.Children)
{
if (oneChild is Line)
{
Line oneLine = (Line)oneChild;
oneLine.X1 += boundsX;
oneLine.X2 += boundsX;
oneLine.Y1 = -oneLine.Y1 - boundsY;
oneLine.Y2 = -oneLine.Y2 - boundsY;
}
else
{
Canvas.SetTop(oneChild, -Canvas.GetTop(oneChild) - boundsY);
Canvas.SetLeft(oneChild, boundsX + Canvas.GetLeft(oneChild));
}
}
Andrej Benedik

