Ejemplo n.º 1
0
        private void CreateBox(int i)
        {
            SizeBox sb = new SizeBox();
            int     x  = 1;
            int     y  = 1;

            if (_orientation == Orientation.Horizontal)
            {
                x = ((_boxSize.Width + 2) * i) + 1;
            }
            else
            {
                y = ((_boxSize.Height + 2) * i) + 1;
            }

            sb.Bounds         = new Rectangle(x, y, _boxSize.Width, _boxSize.Height);
            sb.BackColor      = _boxBackColor;
            sb.SelectionColor = _boxSelectionColor;
            sb.RoundingRadius = _roundingRadius;

            if (i == 0)
            {
                sb.Size = _minSize != null?_minSize.Copy() : new Size2D(4, 4);
            }
            else if (i == _numBoxes - 1)
            {
                sb.Size = _maxSize != null?_maxSize.Copy() : new Size2D(32, 32);
            }
            else
            {
                if (_minSize != null && _maxSize != null)
                {
                    // because of the elses, we know that the number must be greater than 2, and that the current item is not the min or max
                    // Use squaring so that bigger sizes have larger differences between them.
                    double cw = (_maxSize.Width - _minSize.Width) / _numBoxes;
                    double ch = (_maxSize.Height - _minSize.Height) / _numBoxes;
                    sb.Size = new Size2D(_minSize.Width + (cw * i), _minSize.Height + (ch * i));
                }
                else
                {
                    sb.Size = new Size2D(16, 16);
                }
            }

            _boxes.Add(sb);
        }
Ejemplo n.º 2
0
        private void CreateBox(int i)
        {
            SizeBox sb = new SizeBox();
            int x = 1;
            int y = 1;
            if (_orientation == Orientation.Horizontal)
            {
                x = (_boxSize.Width + 2) * i + 1;
            }
            else
            {
                y = (_boxSize.Height + 2) * i + 1;
            }
            sb.Bounds = new Rectangle(x, y, _boxSize.Width, _boxSize.Height);
            sb.BackColor = _boxBackColor;
            sb.SelectionColor = _boxSelectionColor;
            sb.RoundingRadius = _roundingRadius;

            if (i == 0)
            {
                if (_minSize != null)
                {
                    sb.Size = _minSize.Copy();
                }
                else
                {
                    sb.Size = new Size2D(4, 4);
                }
            }
            else if (i == _numBoxes - 1)
            {
                if (_maxSize != null)
                {
                    sb.Size = _maxSize.Copy();
                }
                else
                {
                    sb.Size = new Size2D(32, 32);
                }
            }
            else
            {
                if (_minSize != null && _maxSize != null)
                {
                    // because of the elses, we know that the number must be greater than 2, and that the current item is not the min or max
                    // Use squaring so that bigger sizes have larger differences between them.
                    double cw = (_maxSize.Width - _minSize.Width) / (_numBoxes);
                    double ch = (_maxSize.Height - _minSize.Height) / (_numBoxes);
                    sb.Size = new Size2D(_minSize.Width + cw * i, _minSize.Height + ch * i);
                }
                else
                {
                    sb.Size = new Size2D(16, 16);
                }
            }

            _boxes.Add(sb);
        }