Ejemplo n.º 1
0
        // Find the zoom centre relative to the image bounds, depending on zoom mode.
        private Point FindZoomCenter(ZoomLocation location)
        {
            Point p = new Point();

            switch (location)
            {
            case ZoomLocation.MousePosition:
                Point mp = this.PointToClient(MousePosition);
                p.X = mp.X - _imageBounds.X;
                p.Y = mp.Y - _imageBounds.Y;
                break;

            case ZoomLocation.ControlCenter:
                p.X = this.Width / 2 - _imageBounds.X;
                p.Y = this.Height / 2 - _imageBounds.Y;
                break;

            case ZoomLocation.ImageCenter:
                p.X = _imageBounds.Width / 2;
                p.Y = _imageBounds.Height / 2;
                break;

            default:
                p = Point.Empty;
                break;
            }
            return(p);
        }
    void OnEnable()
    {
        scriptTarget = (ZoomLocation)target;
        autoParent   = scriptTarget.parent == null;

        rotationEuler   = scriptTarget.rotation.eulerAngles;
        rotationEuler.x = (float)decimal.Round((decimal)rotationEuler.x, 2, MidpointRounding.AwayFromZero);
        rotationEuler.y = (float)decimal.Round((decimal)rotationEuler.y, 2, MidpointRounding.AwayFromZero);
        rotationEuler.z = (float)decimal.Round((decimal)rotationEuler.z, 2, MidpointRounding.AwayFromZero);
    }