Пример #1
0
 void AddToCurrentRow(double size)
 {
     _curRow      = new RowSlice(_curRow.Begin, _curRow.End + 1);
     _curAreaSum += size;
     if (size > _curMax)
     {
         _curMax = size;
     }
     if (size < _curMin)
     {
         _curMin = size;
     }
 }
Пример #2
0
        void LayoutRow()
        {
            double x = _curRect.X;
            double y = _curRect.Y;

            if (_curOrientation == Orientation.Vertical)
            {
                double width = _curAreaSum / _curRect.Height;
                for (int i = _curRow.Begin, icnt = _curRow.End; i < icnt; ++i)
                {
                    double area   = _sizes[i];
                    double height = area / width;
                    _rects[i] = new Rect(x, y, width, height);
                    y        += height;
                }
                _curRect = new Rect(x + width, _curRect.Y, _curRect.Width - width, _curRect.Height);
            }
            else
            {
                double height = _curAreaSum / _curRect.Width;
                for (int i = _curRow.Begin, icnt = _curRow.End; i < icnt; ++i)
                {
                    double area  = _sizes[i];
                    double width = area / height;
                    _rects[i] = new Rect(x, y, width, height);
                    x        += width;
                }
                _curRect = new Rect(_curRect.X, y + height, _curRect.Width, _curRect.Height - height);
            }
            _curAreaSum = 0;
            _curMax     = double.MinValue;
            _curMin     = double.MaxValue;
            _curRow     = new RowSlice(_curRow.End, _curRow.End);
            if (_curRect.Width >= _curRect.Height)
            {
                _curOrientation = Orientation.Vertical;
                _shortSideSq    = _curRect.Height * _curRect.Height;
            }
            else
            {
                _curOrientation = Orientation.Horizontal;
                _shortSideSq    = _curRect.Width * _curRect.Width;
            }
            ++_layoutCount;
            _usedRect.Add(_curRect);
        }