Forex_Strategy_Builder.Trading_Charges.OnResize C# (CSharp) Method

OnResize() protected method

Recalculates the sizes and positions of the controls after resizing.
protected OnResize ( EventArgs e ) : void
e System.EventArgs
return void
        protected override void OnResize(EventArgs e)
        {
            int buttonHeight = (int)(Data.VerticalDLU * 15.5);
            int buttonWidth  = (int)(Data.HorizontalDLU * 60);
            int btnVertSpace = (int)(Data.VerticalDLU * 5.5);
            int btnHrzSpace  = (int)(Data.HorizontalDLU * 3);
            int space        = btnHrzSpace;
            int border       = 2;
            int textHeight   = Font.Height;
            int nudWidth     = 70;

            // pnlBase
            pnlBase.Size     = new Size(ClientSize.Width - 2 * space, ClientSize.Height - 2 * btnVertSpace - buttonHeight - space);
            pnlBase.Location = new Point(space, space);

            // Labels
            lblSpread.Location     = new Point(btnHrzSpace + border, 0 * buttonHeight + 1 * space + 8);
            lblSwapLong.Location   = new Point(btnHrzSpace + border, 1 * buttonHeight + 2 * space + 2);
            lblSwapShort.Location  = new Point(btnHrzSpace + border, 2 * buttonHeight + 3 * space + 2);
            lblCommission.Location = new Point(btnHrzSpace + border, 3 * buttonHeight + 4 * space + 8);
            lblSlippage.Location   = new Point(btnHrzSpace + border, 4 * buttonHeight + 5 * space + 8);

            // NUD Parameters
            int nudLeft = pnlBase.ClientSize.Width - nudWidth - btnHrzSpace - border;
            nudSpread.Size          = new Size(nudWidth, buttonHeight);
            nudSpread.Location      = new Point(nudLeft, 0 * buttonHeight + 1 * space + 6);
            nudSwapLong.Size        = new Size(nudWidth, buttonHeight);
            nudSwapLong.Location    = new Point(nudLeft, 1 * buttonHeight + 2 * space + 6);
            nudSwapShort.Size       = new Size(nudWidth, buttonHeight);
            nudSwapShort.Location   = new Point(nudLeft, 2 * buttonHeight + 3 * space + 6);
            nudCommission.Size      = new Size(nudWidth, buttonHeight);
            nudCommission.Location  = new Point(nudLeft, 3 * buttonHeight + 4 * space + 6);
            nudSlippage.Size        = new Size(nudWidth, buttonHeight);
            nudSlippage.Location    = new Point(nudLeft, 4 * buttonHeight + 5 * space + 6);

            // Button btnEditInstrument
            btnEditInstrument.Size     = new Size(buttonWidth, buttonHeight);
            btnEditInstrument.Location = new Point(btnHrzSpace, ClientSize.Height - buttonHeight - btnVertSpace);

            // Button Cancel
            btnCancel.Size     = new Size(buttonWidth, buttonHeight);
            btnCancel.Location = new Point(ClientSize.Width - buttonWidth - btnHrzSpace, ClientSize.Height - buttonHeight - btnVertSpace);

            // Button Accept
            btnAccept.Size     = new Size(buttonWidth, buttonHeight);
            btnAccept.Location = new Point(btnCancel.Left - buttonWidth - btnHrzSpace, ClientSize.Height - buttonHeight - btnVertSpace);

            // Button Default
            //btnDefault.Size     = new Size(buttonWidth, buttonHeight);
            //btnDefault.Location = new Point(btnAccept.Left - buttonWidth - btnHrzSpace, ClientSize.Height - buttonHeight - btnVertSpace);

            // Resize if necessary
            int iMaxLblRight = lblSpread.Right;
            if (lblSwapLong.Right   > iMaxLblRight) iMaxLblRight = lblSwapLong.Right;
            if (lblSwapShort.Right  > iMaxLblRight) iMaxLblRight = lblSwapShort.Right;
            if (lblCommission.Right > iMaxLblRight) iMaxLblRight = lblCommission.Right;
            if (lblSlippage.Right   > iMaxLblRight) iMaxLblRight = lblSlippage.Right;

            if (nudLeft - iMaxLblRight < btnVertSpace)
                Width += btnVertSpace - nudLeft + iMaxLblRight;

            return;
        }