Exemplo n.º 1
0
        public void CalculateRect(Rectangle rectDraw, out Rectangle rectScreen, out Rectangle rectGenerate)
        {
            RectangleF rect  = rectDraw;
            SizeF      ratio = ZoomRatio;

            //rect = rectScreen;
            rect /= ratio;
            rect.Align(1, 1);
            rect.Inflate(1, 1);
            Size size = Size;

            while (rect.Top > 0 && ((rect.Top * ratio.Height) % 1.0F) > 0.2F)
            {
                rect.Top--;
            }
            while (rect.Left > 0 && ((rect.Left * ratio.Width) % 1.0F) > 0.2F)
            {
                rect.Left--;
            }

            while (rect.InnerBottom < size.Height && ((rect.InnerBottom * ratio.Height) % 1.0F) > 0.2F)
            {
                rect.InnerBottom++;
            }
            while (rect.InnerRight < size.Width && ((rect.InnerRight * ratio.Width) % 1.0F) > 0.2F)
            {
                rect.InnerRight++;
            }
            rect.Restrict(PointF.Empty, Size);
            rectGenerate = Rectangle.Round(rect);

            rect       = rectGenerate;
            rect      *= ratio;
            rectScreen = Rectangle.Round(rect);

            /*
             */
            //Console.WriteLine("{0} - {1}", rectScreen, rectGenerate);
        }