Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Implement Graphics BeginContainer(Rectangle, Rectangle, GraphicsUnit)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjpou1 committed Jan 5, 2016
1 parent a142450 commit 7b80f38
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions System.Drawing/Graphics.cs
Expand Up @@ -1080,12 +1080,29 @@ public GraphicsContainer BeginContainer ()

public GraphicsContainer BeginContainer (Rectangle dstRect, Rectangle srcRect, GraphicsUnit unit)
{
throw new NotImplementedException ();
return BeginContainer ((RectangleF)dstRect, (RectangleF)srcRect, unit);
}

public GraphicsContainer BeginContainer (RectangleF dstRect, RectangleF srcRect, GraphicsUnit unit)
{
throw new NotImplementedException ();
var container = BeginContainer();

var srcRect1 = srcRect;

// If the source units are not the same we need to convert them
// The reason we check for Pixel here is that our graphics already has the Pixel's baked into the model view transform
if (unit != graphicsUnit && unit != GraphicsUnit.Pixel)
{
ConversionHelpers.GraphicsUnitConversion (unit, graphicsUnit, DpiX, DpiX, ref srcRect1);
}

TranslateTransform(dstRect.X, dstRect.Y);

float scaleX = dstRect.Width/srcRect1.Width;
float scaleY = dstRect.Height/srcRect1.Height;
ScaleTransform(scaleX, scaleY);

return container;
}

public void EndContainer (GraphicsContainer container)
Expand Down

0 comments on commit 7b80f38

Please sign in to comment.