I draw an image from MetaFile (emf) and then apply some rotation transformations to everything inside the OnPaint UserControl. After applying these transformations, how can I calculate the normal non-transformed rectangular bounding rectangle of this in screen coordinates? I need this to be able to resize the rotated image to the size of a UserControl.
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TranslateTransform(this.Width / 2.0f, this.Height / 2.0f);
e.Graphics.RotateTransform(this.Rotation);
e.Graphics.TranslateTransform(this.Width / -2.0f, this.Height / -2.0f);
float left = (this.Width - ResourceManager.MyDrawingMetaFile.Width) / 2.0f;
float top = (this.Height - ResourceManager.MyDrawingMetaFile.Height) / 2.0f;
e.Graphics.DrawImage(Resources.MyDrawingMetaFile, left, top);
}
The whole idea is that I want to display the rotated .emf file in UserControl, and the emf picture always fills the available space in UserControl. Maybe there is a better approach?
/, , Uniform UniformToFill ( WPF Viewbox). . , , , . UniformToFill emf UserControl , aspectratios , emf .