Forex_Strategy_Builder.Journal_Ord.SetSizes C# (CSharp) Method

SetSizes() protected method

Sets the size and position of the controls
protected SetSizes ( ) : void
return void
        void SetSizes()
        {
            if (orders == 0)
            {
                firstOrd = 0;
                lastOrd  = 0;
                shownOrd = 0;

                vScrollBar.Visible = false;
                visibalWidth = ClientSize.Width;
            }
            else if (orders < rows)
            {
                firstOrd = 0;
                lastOrd  = rows;
                shownOrd = orders;

                vScrollBar.Visible = false;
                visibalWidth = ClientSize.Width;
            }
            else
            {
                vScrollBar.Visible = true;
                if (selectedBar != selectedBarOld)
                    vScrollBar.Value = 0;
                vScrollBar.Maximum = orders - 1;
                visibalWidth = vScrollBar.Left;

                firstOrd = vScrollBar.Value;
                if (firstOrd + rows > orders)
                {
                    lastOrd  = orders - 1;
                    shownOrd = lastOrd - firstOrd + 1;
                }
                else
                {
                    shownOrd = rows;
                    lastOrd  = firstOrd + shownOrd - 1;
                }
            }

            if (visibalWidth <= aiColumnX[columns])
                aiColumnX.CopyTo(aiX, 0);
            else
            {   // Scales the columns position
                float scale = (float)visibalWidth / aiColumnX[columns];
                for (int i = 0; i <= columns; i++)
                    aiX[i] = (int)(aiColumnX[i] * scale);
            }

            if (visibalWidth < aiColumnX[columns])
            {
                hScrollBar.Visible = true;
                int iPoinShort = aiColumnX[columns] - visibalWidth;
                if (hScrollBar.Value > iPoinShort)
                    hScrollBar.Value = iPoinShort;
                hScrollBar.Maximum = iPoinShort + hScrollBar.LargeChange - 2;
            }
            else
            {
                hScrollBar.Value   = 0;
                hScrollBar.Visible = false;
            }

            selectedBarOld = selectedBar;
            btnRemoveJournal.Location = new Point(ClientSize.Width - btnRemoveJournal.Width - 1, 1);
            btnToggleJournal.Location = new Point(btnRemoveJournal.Left - btnToggleJournal.Width - 1, 1);

            return;
        }