Example #1
0
        /// <summary>
        /// sets the bounding curve scaled to fit the targetBounds
        /// </summary>
        /// <param name="targetBounds"></param>
        protected void FitBoundaryCurveToTarget(Rectangle targetBounds)
        {
            if (BoundaryCurve != null)
            {
                // RoundedRect is special, rather than simply scaling the geometry we want to keep the corner radii constant
                RoundedRect rr = BoundaryCurve as RoundedRect;
                if (rr == null)
                {
                    Debug.Assert(BoundaryCurve.BoundingBox.Width > 0);
                    Debug.Assert(BoundaryCurve.BoundingBox.Height > 0);
                    double scaleX = targetBounds.Width / BoundaryCurve.BoundingBox.Width;
                    double scaleY = targetBounds.Height / BoundaryCurve.BoundingBox.Height;

                    BoundaryCurve.Translate(-BoundaryCurve.BoundingBox.LeftBottom);
                    BoundaryCurve = BoundaryCurve.ScaleFromOrigin(scaleX, scaleY);
                    BoundaryCurve.Translate(targetBounds.LeftBottom);
                }
                else
                {
                    BoundaryCurve = rr.FitTo(targetBounds);
                }
                Debug.Assert(ApproximateComparer.Close(BoundaryCurve.BoundingBox, targetBounds, ApproximateComparer.UserDefinedTolerance),
                             "FitToBounds didn't succeed in scaling/translating to target bounds");
            }
        }
Example #2
0
 ///<summary>
 ///</summary>
 ///<param name="transformation"></param>
 public void Transform(PlaneTransformation transformation)
 {
     if (BoundaryCurve != null)
     {
         BoundaryCurve = BoundaryCurve.Transform(transformation);
     }
 }