예제 #1
0
파일: LayoutElement.cs 프로젝트: vinla/cgwo
        public LayoutElement Clone()
        {
            var clone = new LayoutElement();

            clone.CopyValuesFrom(this);
            return(clone);
        }
예제 #2
0
        public void Update(Vector delta)
        {
            var tempPoint = _trackingPoint;

            if (_direction.Contains("Left") || _direction.Contains("Right"))
            {
                _trackingPoint.Offset(delta.X, 0);
                tempPoint.X = _guidelines.SnapVerticalEdge(_trackingPoint.X);
            }

            if (_direction.Contains("Bottom") || _direction.Contains("Top"))
            {
                _trackingPoint.Offset(0, delta.Y);
                tempPoint.Y = _guidelines.SnapHorizontalEdge(_trackingPoint.Y);
            }

            _guidelines.Update();

            var overallDelta = tempPoint - _referencePoint;

            if (_direction.Contains("Right"))
            {
                _element.Width = Math.Max(_original.Width + overallDelta.X, 1);
            }

            if (_direction.Contains("Bottom"))
            {
                _element.Height = Math.Max(_original.Height + overallDelta.Y, 1);
            }

            if (_direction.Contains("Left"))
            {
                double newWidth = Math.Max(_original.Width - overallDelta.X, 1);

                _element.Left  = _element.Left - (newWidth - _element.Width);
                _element.Width = newWidth;
            }

            if (_direction.Contains("Top"))
            {
                double newHeight = Math.Max(_original.Height - overallDelta.Y, 1);

                _element.Top    = _element.Top - (newHeight - _element.Height);
                _element.Height = newHeight;
            }

            _final.CopyValuesFrom(_element);
        }
예제 #3
0
 public override void Undo()
 {
     _element.CopyValuesFrom(_original);
 }