示例#1
0
        internal void CenterPatch(LayoutPatch patch, double scale, HorizontalCenter hor, VerticalCenter ver)
        {
            // die Projektion ist ja zwei Anteile, unscaledProjection hält immer den Nullpunkt
            // fest und skaliert nicht, und Placement platziert
            BoundingRect areaext;

            if (patch.Area != null)
            {
                areaext = patch.Area.Extent;
            }
            else
            {
                areaext = new BoundingRect(0.0, 0.0, paperWidth, paperHeight);
            }
            BoundingRect modelext = patch.Model.GetExtent(patch.Projection);

            if (modelext.IsEmpty())
            {
                return;
            }
            GeoPoint2D modelcnt = modelext.GetCenter();
            GeoPoint2D areacnt = areaext.GetCenter();
            double     factor, dx, dy;

            patch.Projection.GetPlacement(out factor, out dx, out dy);
            if (scale != 0.0)
            {
                factor = scale;
            }
            switch (hor)
            {
            case HorizontalCenter.left:
                dx = areaext.Left - (modelext.Left * factor);
                break;

            case HorizontalCenter.center:
                dx = areacnt.x - (modelcnt.x * factor);
                break;

            case HorizontalCenter.right:
                dx = areaext.Right - (modelext.Right * factor);
                break;

            default:
                break;
            }
            switch (ver)
            {
            case VerticalCenter.bottom:
                dy = areaext.Bottom - (modelext.Bottom * factor);
                break;

            case VerticalCenter.center:
                dy = areacnt.y - (modelcnt.y * factor);
                break;

            case VerticalCenter.top:
                dy = areaext.Top - (modelext.Top * factor);
                break;

            default:
                break;
            }
            patch.Projection.SetPlacement(factor, dx, dy);
        }
示例#2
0
 /// <summary>
 /// Centers the patch with the given index according to the horizontal and vertical
 /// center mode. If scale is 0.0 the current scaling remains unchanged.
 /// </summary>
 /// <param name="index">index of the patch</param>
 /// <param name="scale">scaling factor or 0.0</param>
 /// <param name="hor">horizontal position mode</param>
 /// <param name="ver">vertical position mode</param>
 public void CenterPatch(int index, double scale, HorizontalCenter hor, VerticalCenter ver)
 {
     CenterPatch(patches[index], scale, hor, ver);
 }