示例#1
0
        private Point2D CalculateOrigin(Point2D origin)
        {
            var rect = Simulation.SimulationArea.Area.ConvertTo(MeasurementUnit.Milimeter);

            origin = origin.ConvertTo(MeasurementUnit.Milimeter);
            var x = origin.X;
            var y = origin.Y;
            var widthMilimeter  = new Length(ClientSize.Width / DpiX / DrawScale, MeasurementUnit.Inch).ConvertTo(MeasurementUnit.Milimeter);
            var heightMilimeter = new Length(ClientSize.Height / DpiY / DrawScale, MeasurementUnit.Inch).ConvertTo(MeasurementUnit.Milimeter);
            var maxX            = -(rect.Right - widthMilimeter).Value;
            var maxY            = -(rect.Bottom - heightMilimeter).Value;

            x = (x <= maxX || rect.Width <= widthMilimeter) ? maxX : x;
            y = (y <= maxY || rect.Height <= heightMilimeter) ? maxY : y;
            x = (x >= -rect.Left.Value || rect.Width <= widthMilimeter) ? -rect.Left.Value : x;
            y = (y >= -rect.Top.Value || rect.Height <= heightMilimeter) ? -rect.Top.Value : y;
            return(new Point2D(x, y, MeasurementUnit.Milimeter));
        }
示例#2
0
        private Point CalcOriginPoint()
        {
            var origin = originPoint.ConvertTo(MeasurementUnit.Inch);

            return(new Point((int)Math.Ceiling(origin.X * DpiX * DrawScale), (int)Math.Ceiling(origin.Y * DpiY * DrawScale)));
        }