/// <summary> /// Sets the size and position of the controls /// </summary> private void SetSizes() { orders = Data.IsResult ? StatsBuffer.Orders(selectedBar) : 0; rows = ClientSize.Height > 2 * rowHeight + Border ? (ClientSize.Height - 2 * rowHeight - Border) / rowHeight : 0; if (orders == 0) { firstOrd = 0; lastOrd = 0; shownOrd = 0; VScrollBar.Visible = false; visibleWidth = ClientSize.Width; } else if (orders < rows) { firstOrd = 0; lastOrd = rows; shownOrd = orders; VScrollBar.Visible = false; visibleWidth = ClientSize.Width; } else { VScrollBar.Visible = true; if (selectedBar != selectedBarOld) { VScrollBar.Value = 0; } VScrollBar.Maximum = orders - 1; visibleWidth = VScrollBar.Left; firstOrd = VScrollBar.Value; if (firstOrd + rows > orders) { lastOrd = orders - 1; shownOrd = lastOrd - firstOrd + 1; } else { shownOrd = rows; lastOrd = firstOrd + shownOrd - 1; } } if (visibleWidth <= xColumns[columns]) { xColumns.CopyTo(xScaled, 0); } else { // Scales the columns position float scale = (float)visibleWidth / xColumns[columns]; for (int i = 0; i <= columns; i++) { xScaled[i] = (int)(xColumns[i] * scale); } } if (visibleWidth < xColumns[columns]) { HScrollBar.Visible = true; int pointShort = xColumns[columns] - visibleWidth; if (HScrollBar.Value > pointShort) { HScrollBar.Value = pointShort; } HScrollBar.Maximum = pointShort + HScrollBar.LargeChange - 2; } else { HScrollBar.Value = 0; HScrollBar.Visible = false; } selectedBarOld = selectedBar; }
/// <summary> /// Sets the size and position of the controls /// </summary> private void SetSizes() { _orders = Data.IsResult ? StatsBuffer.Orders(_selectedBar) : 0; _rows = ClientSize.Height > 2 * _rowHeight + Border ? (ClientSize.Height - 2 * _rowHeight - Border) / _rowHeight : 0; if (_orders == 0) { _firstOrd = 0; _lastOrd = 0; _shownOrd = 0; VScrollBar.Visible = false; _visibleWidth = ClientSize.Width; } else if (_orders < _rows) { _firstOrd = 0; _lastOrd = _rows; _shownOrd = _orders; VScrollBar.Visible = false; _visibleWidth = ClientSize.Width; } else { VScrollBar.Visible = true; if (_selectedBar != _selectedBarOld) { VScrollBar.Value = 0; } VScrollBar.Maximum = _orders - 1; _visibleWidth = VScrollBar.Left; _firstOrd = VScrollBar.Value; if (_firstOrd + _rows > _orders) { _lastOrd = _orders - 1; _shownOrd = _lastOrd - _firstOrd + 1; } else { _shownOrd = _rows; _lastOrd = _firstOrd + _shownOrd - 1; } } if (_visibleWidth <= _xColumns[_columns]) { _xColumns.CopyTo(_xScaled, 0); } else { // Scales the columns position float scale = (float)_visibleWidth / _xColumns[_columns]; for (int i = 0; i <= _columns; i++) { _xScaled[i] = (int)(_xColumns[i] * scale); } } if (_visibleWidth < _xColumns[_columns]) { HScrollBar.Visible = true; int poinShort = _xColumns[_columns] - _visibleWidth; if (HScrollBar.Value > poinShort) { HScrollBar.Value = poinShort; } HScrollBar.Maximum = poinShort + HScrollBar.LargeChange - 2; } else { HScrollBar.Value = 0; HScrollBar.Visible = false; } _selectedBarOld = _selectedBar; }