示例#1
0
文件: Text.cs 项目: zeroyou/LitCAD
        public void UpdateBounding(double width, double height)
        {
            switch (_alignment)
            {
            case TextAlignment.LeftBottom:
                _bounding = new Bounding(
                    _position,
                    new LitMath.Vector2(_position.x + width, _position.y + height));
                break;

            case TextAlignment.LeftMiddle:
                _bounding = new Bounding(
                    new LitMath.Vector2(_position.x, _position.y - height / 2),
                    new LitMath.Vector2(_position.x + width, _position.y + height / 2));
                break;

            case TextAlignment.LeftTop:
                _bounding = new Bounding(
                    _position,
                    new LitMath.Vector2(_position.x + width, _position.y - height));
                break;

            case TextAlignment.CenterBottom:
                _bounding = new Bounding(
                    new LitMath.Vector2(_position.x - width / 2, _position.y),
                    new LitMath.Vector2(_position.x + width / 2, _position.y + height));
                break;

            case TextAlignment.CenterMiddle:
                _bounding = new Bounding(
                    _position, width, height);
                break;

            case TextAlignment.CenterTop:
                _bounding = new Bounding(
                    new LitMath.Vector2(_position.x - width / 2, _position.y),
                    new LitMath.Vector2(_position.x + width / 2, _position.y - height));
                break;

            case TextAlignment.RightBottom:
                _bounding = new Bounding(
                    _position,
                    new LitMath.Vector2(_position.x - width, _position.y + height));
                break;

            case TextAlignment.RightMiddle:
                _bounding = new Bounding(
                    new LitMath.Vector2(_position.x, _position.y + height / 2),
                    new LitMath.Vector2(_position.x - width, _position.y - height / 2));
                break;

            case TextAlignment.RightTop:
                _bounding = new Bounding(
                    _position,
                    new LitMath.Vector2(_position.x - width, _position.y - height));
                break;

            default:
                _bounding = new Bounding(_position, 0, 0);
                break;
            }
        }
示例#2
0
 /// <summary>
 /// Check whether contains bounding
 /// </summary>
 public bool Contains(Bounding bounding)
 {
     return(this.Contains(bounding.left, bounding.bottom) &&
            this.Contains(bounding.right, bounding.top));
 }