Forex_Strategy_Builder.Dialogs.Generator.Generator.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)
        {
            base.OnResize(e);

            int buttonHeight   = (int)(Data.VerticalDLU * 15.5);
            int buttonWidth    = (int)(Data.HorizontalDLU * 60 * buttonWidthMultiplier);
            int btnVertSpace   = (int)(Data.VerticalDLU * 5.5);
            int btnHrzSpace    = (int)(Data.HorizontalDLU * 3);
            int border         = btnHrzSpace;
            int textHeight     = Font.Height;
            int rightSideWidth = 3 * buttonWidth + 2 * btnHrzSpace;
            int rightSideLocation = ClientSize.Width - rightSideWidth - btnHrzSpace;
            int leftSideWidth  = ClientSize.Width - 3 * buttonWidth - 5 * btnHrzSpace;
            int nudWidth       = 55;
            int optionsHeight  = 228;

            //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 Generate
            btnGenerate.Size     = new Size(buttonWidth, buttonHeight);
            btnGenerate.Location = new Point(btnAccept.Left - buttonWidth - btnHrzSpace, ClientSize.Height - buttonHeight - btnVertSpace);

            // Progress Bar
            progressBar.Size     = new Size(ClientSize.Width - leftSideWidth - 3 * border, (int)(Data.VerticalDLU * 9));
            progressBar.Location = new Point(leftSideWidth + 2 * border, btnAccept.Top - progressBar.Height - btnVertSpace);

            // Tool Strip Strategy
            tsStrategy.Width = leftSideWidth + border;
            tsStrategy.Location = Point.Empty;

            // Tool Strip Strategy
            tsGenerator.Width = ClientSize.Width - leftSideWidth - border;
            tsGenerator.Location = new Point(tsStrategy.Right + border, 0);

            // Panel Common
            pnlCommon.Size = new Size(rightSideWidth, optionsHeight);
            pnlCommon.Location = new Point(rightSideLocation, tsStrategy.Bottom + border);

            // Panel pnlLimitations
            pnlLimitations.Size = new Size(rightSideWidth, optionsHeight);
            pnlLimitations.Location = new Point(rightSideLocation, tsStrategy.Bottom + border);

            // Panel Settings
            pnlSettings.Size = new Size(rightSideWidth, optionsHeight);
            pnlSettings.Location = new Point(rightSideLocation, tsStrategy.Bottom + border);

            // Panel Top 10
            pnlTop10.Size = new Size(rightSideWidth, optionsHeight);
            pnlTop10.Location = new Point(rightSideLocation, tsStrategy.Bottom + border);

            // Panel Indicators
            pnlIndicators.Size = new Size(rightSideWidth, optionsHeight);
            pnlIndicators.Location = new Point(rightSideLocation, tsStrategy.Bottom + border);

            // Panel StrategyLayout
            strategyLayout.Size = new Size(leftSideWidth, ClientSize.Height - border - tsStrategy.Bottom - border);
            strategyLayout.Location = new Point(border, tsStrategy.Bottom + border);

            // Panel Balance Chart
            smallBalanceChart.Size     = new Size(ClientSize.Width - leftSideWidth - 3 * border, progressBar.Top - 3 * border - pnlCommon.Bottom);
            smallBalanceChart.Location = new Point(strategyLayout.Right + border, pnlCommon.Bottom + border);

            // Account Statistics
            infpnlAccountStatistics.Size = new Size(ClientSize.Width - leftSideWidth - 3 * border, progressBar.Top - 3 * border - pnlCommon.Bottom);
            infpnlAccountStatistics.Location = new Point(strategyLayout.Right + border, pnlCommon.Bottom + border);

            //chbGenerateNewStrategy
            chbGenerateNewStrategy.Location = new Point(border + 2, 26);

            //chbPreservPermSL
            chbPreservPermSL.Location = new Point(border + 2, chbGenerateNewStrategy.Bottom + border + 4);

            //chbPreservPermTP
            chbPreservPermTP.Location = new Point(border + 2, chbPreservPermSL.Bottom + border + 4);

            // chbPseudoOpt
            chbInitialOptimisation.Location = new Point(border + 2, chbPreservPermTP.Bottom + border + 4);

            // chbMaxOpeningLogicSlots
            chbMaxOpeningLogicSlots.Location = new Point(border + 2, chbInitialOptimisation.Bottom + border + 4);

            // nudMaxOpeningLogicSlots
            nudMaxOpeningLogicSlots.Width    = nudWidth;
            nudMaxOpeningLogicSlots.Location = new Point(nudAmbiguousBars.Left, chbMaxOpeningLogicSlots.Top - 1);

            // chbMaxClosingLogicSlots
            chbMaxClosingLogicSlots.Location = new Point(border + 2, chbMaxOpeningLogicSlots.Bottom + border + 4);

            // nudMaxClosingLogicSlots
            nudMaxClosingLogicSlots.Width    = nudWidth;
            nudMaxClosingLogicSlots.Location = new Point(nudAmbiguousBars.Left, chbMaxClosingLogicSlots.Top - 1);

            // Labels Strategy Calculations
            lblCalcStrInfo.Location = new Point(border - 1, pnlCommon.Height - nudMaxOpeningLogicSlots.Height - border);
            lblCalcStrNumb.Size     = new Size(nudWidth, nudMaxOpeningLogicSlots.Height - 1);
            lblCalcStrNumb.Location = new Point(lblCalcStrInfo.Right + border, lblCalcStrInfo.Top - 3);

            //Working Minutes
            nudWorkingMinutes.Width    = nudWidth;
            nudWorkingMinutes.Location = new Point(nudMaxOpeningLogicSlots.Right - nudWidth, lblCalcStrInfo.Top - 2);
            lblWorkingMinutes.Location = new Point(nudWorkingMinutes.Left - lblWorkingMinutes.Width - 3, lblCalcStrInfo.Top);

            // chbAmbiguousBars
            chbAmbiguousBars.Location = new Point(border + 2, 25);

            // nudAmbiguousBars
            nudAmbiguousBars.Width    = nudWidth;
            nudAmbiguousBars.Location = new Point(pnlLimitations.ClientSize.Width - nudWidth - border - 2, chbAmbiguousBars.Top - 1);

            // MaxDrawdown
            chbMaxDrawdown.Location = new Point(border + 2, chbAmbiguousBars.Bottom + border + 4);
            nudMaxDrawdown.Width    = nudWidth;
            nudMaxDrawdown.Location = new Point(nudAmbiguousBars.Left , chbMaxDrawdown.Top - 1);

            // MaxDrawdown %
            chbEquityPercent.Location = new Point(border + 2, nudMaxDrawdown.Bottom + border + 4);
            nudEquityPercent.Width    = nudWidth;
            nudEquityPercent.Location = new Point(nudAmbiguousBars.Left, chbEquityPercent.Top - 1);

            // MinTrades
            chbMinTrades.Location = new Point(border + 2, chbEquityPercent.Bottom + border + 4);
            nudMinTrades.Width    = nudWidth;
            nudMinTrades.Location = new Point(nudAmbiguousBars.Left, chbMinTrades.Top - 1);

            // MaxTrades
            chbMaxTrades.Location = new Point(border + 2, chbMinTrades.Bottom + border + 4);
            nudMaxTrades.Width    = nudWidth;
            nudMaxTrades.Location = new Point(nudAmbiguousBars.Left, chbMaxTrades.Top - 1);

            // WinLossRatios
            chbWinLossRatio.Location = new Point(border + 2, chbMaxTrades.Bottom + border + 4);
            nudWinLossRatio.Width    = nudWidth;
            nudWinLossRatio.Location = new Point(nudAmbiguousBars.Left, chbWinLossRatio.Top - 1);

            // OOS Pattern Filter
            chbOOSPatternFilter.Location = new Point(border + 2, chbWinLossRatio.Bottom + border + 4);
            nudOOSPatternPercent.Width = nudWidth;
            nudOOSPatternPercent.Location = new Point(nudAmbiguousBars.Left, chbOOSPatternFilter.Top - 1);

            // Balance lines pattern
            chbSmoothBalanceLines.Location = new Point(border + 2, chbOOSPatternFilter.Bottom + border + 4);
            nudSmoothBalancePercent.Width = nudWidth;
            nudSmoothBalancePercent.Location = new Point(nudAmbiguousBars.Left, chbSmoothBalanceLines.Top - 1);
            nudSmoothBalanceCheckPoints.Width = nudWidth;
            nudSmoothBalanceCheckPoints.Location = new Point(nudSmoothBalancePercent.Left - nudWidth - border, chbSmoothBalanceLines.Top - 1);

            // chbOutOfSample
            chbOutOfSample.Location = new Point(border + 2, 25);
            nudOutOfSample.Width = nudWidth;
            nudOutOfSample.Location = new Point(nudAmbiguousBars.Left, chbOutOfSample.Top - 1);

            // Use default indicator values
            chbUseDefaultIndicatorValues.Location = new Point(border + 2, chbOutOfSample.Bottom + border + 4);

            // Hide FSB when generator starts
            chbHideFSB.Location = new Point(border + 2, chbUseDefaultIndicatorValues.Bottom + border + 4);

            // Button Reset
            btnReset.Width = pnlSettings.ClientSize.Width - 2 * (border + 2);
            btnReset.Location = new Point(border + 2, pnlSettings.Height - btnReset.Height - border - 2);

            // Top 10 Layout
            top10Layout.Size = new Size(pnlTop10.Width - 2 * 2, pnlTop10.Height - (int)pnlTop10.CaptionHeight - 2);
            top10Layout.Location = new Point(2, (int)pnlTop10.CaptionHeight);

            // Indicators Layout
            indicatorsLayout.Size = new Size(pnlIndicators.Width - 2 * 2, pnlIndicators.Height - (int)pnlIndicators.CaptionHeight - 2);
            indicatorsLayout.Location = new Point(2, (int)pnlIndicators.CaptionHeight);
            return;
        }