Ejemplo n.º 1
0
        public static double GetScalingFactor(this Artivity.DataModel.Rectangle r, RectangleF target)
        {
            double w = target.Width / r.Width;
            double h = target.Height / r.Height;

            return(w >= h ? h : w);
        }
Ejemplo n.º 2
0
        public static RectangleF ToRectangle(this Artivity.DataModel.Rectangle r)
        {
            RectangleF rectangle = new RectangleF();

            rectangle.Location = r.Position.ToPoint();
            rectangle.Width    = Convert.ToSingle(r.Width);
            rectangle.Height   = Convert.ToSingle(r.Height);

            return(rectangle);
        }
Ejemplo n.º 3
0
        public static RectangleF Fit(this Artivity.DataModel.Rectangle r, RectangleF target)
        {
            double s = r.GetScalingFactor(target);

            RectangleF result = new RectangleF();

            result.Width  = Convert.ToSingle(Math.Round(r.Width * s, 0));
            result.Height = Convert.ToSingle(Math.Round(r.Height * s, 0));

            return(result);
        }