Forex_Strategy_Builder.Indicator_Dialog.Indicator_Dialog C# (CSharp) Метод

Indicator_Dialog() публичный Метод

Constructor
public Indicator_Dialog ( int slotNumb, SlotTypes slotType, bool isDefined ) : System
slotNumb int
slotType SlotTypes
isDefined bool
Результат System
        public Indicator_Dialog(int slotNumb, SlotTypes slotType, bool isDefined)
        {
            this.slot      = slotNumb;
            this.slotType   = slotType;
            this.isDefined = isDefined;

            if (slotType == SlotTypes.Open)
            {
                slotCation      = Language.T("Opening Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpen);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpen);
            }
            else if (slotType == SlotTypes.OpenFilter)
            {
                slotCation      = Language.T("Opening Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackOpenFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackOpenFilter);
            }
            else if (slotType == SlotTypes.Close)
            {
                slotCation      = Language.T("Closing Point of the Position");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackClose);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackClose);
            }
            else
            {
                slotCation      = Language.T("Closing Logic Condition");
                pnlParameters   = new Fancy_Panel(slotCation, LayoutColors.ColorSlotCaptionBackCloseFilter);
                pnlTreeViewBase = new Fancy_Panel(Language.T("Indicators"), LayoutColors.ColorSlotCaptionBackCloseFilter);
            }

            trvIndicators        = new TreeView();
            pnlSmallBalanceChart = new Small_Balance_Chart();
            btnAccept            = new Button();
            btnHelp              = new Button();
            btnDefault           = new Button();
            btnCancel            = new Button();

            lblIndicatorInfo     = new Label();
            lblIndicatorWarning  = new Label();
            lblIndicator         = new Label();
            lblGroup             = new Label();
            cbxGroup             = new ComboBox();
            aLblList             = new Label[5];
            aCbxList             = new ComboBox[5];
            aLblNumeric          = new Label[6];
            aNudNumeric          = new NUD[6];
            aChbCheck            = new CheckBox[2];

            BackColor            = LayoutColors.ColorFormBack;
            FormBorderStyle      = FormBorderStyle.FixedDialog;
            Icon                 = Data.Icon;
            MaximizeBox          = false;
            MinimizeBox          = false;
            ShowInTaskbar        = false;
            AcceptButton         = btnAccept;
            CancelButton         = btnCancel;
            Text                 = Language.T("Logic and Parameters of the Indicators");

            // Panel TreeViewBase
            pnlTreeViewBase.Parent  = this;
            pnlTreeViewBase.Padding = new Padding(border, (int)pnlTreeViewBase.CaptionHeight, border, border);

            // TreeView trvIndicators
            trvIndicators.Parent      = pnlTreeViewBase;
            trvIndicators.Dock        = DockStyle.Fill;
            trvIndicators.BackColor   = LayoutColors.ColorControlBack;
            trvIndicators.ForeColor   = LayoutColors.ColorControlText;
            trvIndicators.BorderStyle = BorderStyle.None;
            trvIndicators.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(TrvIndicators_NodeMouseDoubleClick);
            trvIndicators.KeyPress   += new KeyPressEventHandler(TrvIndicators_KeyPress);

            pnlParameters.Parent = this;

            // pnlSmallBalanceChart
            pnlSmallBalanceChart.Parent = this;

            // lblIndicatorInfo
            lblIndicatorInfo.Parent          = pnlParameters;
            lblIndicatorInfo.Size            = new Size(16, 16);
            lblIndicatorInfo.BackColor       = Color.Transparent;
            lblIndicatorInfo.BackgroundImage = Properties.Resources.information;
            lblIndicatorInfo.Click          += new EventHandler(LblIndicatorInfo_Click);
            lblIndicatorInfo.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorInfo.MouseLeave     += new EventHandler(Label_MouseLeave);

            // lblIndicatorWarning
            lblIndicatorWarning.Parent          = pnlParameters;
            lblIndicatorWarning.Size            = new Size(16, 16);
            lblIndicatorWarning.BackColor       = Color.Transparent;
            lblIndicatorWarning.BackgroundImage = Properties.Resources.warning;
            lblIndicatorWarning.Visible         = false;
            lblIndicatorWarning.Click          += new EventHandler(LblIndicatorWarning_Click);
            lblIndicatorWarning.MouseEnter     += new EventHandler(Label_MouseEnter);
            lblIndicatorWarning.MouseLeave     += new EventHandler(Label_MouseLeave);

            // Label Indicator
            lblIndicator.Parent    = pnlParameters;
            lblIndicator.TextAlign = ContentAlignment.MiddleCenter;
            lblIndicator.Font      = new Font(Font.FontFamily, 14, FontStyle.Bold);
            lblIndicator.ForeColor = LayoutColors.ColorSlotIndicatorText;
            lblIndicator.BackColor = Color.Transparent;

            // Label aLblList[0]
            aLblList[0]           = new Label();
            aLblList[0].Parent    = pnlParameters;
            aLblList[0].TextAlign = ContentAlignment.BottomCenter;
            aLblList[0].ForeColor = LayoutColors.ColorControlText;
            aLblList[0].BackColor = Color.Transparent;

            // ComboBox aCbxList[0]
            aCbxList[0]               = new ComboBox();
            aCbxList[0].Parent        = pnlParameters;
            aCbxList[0].DropDownStyle = ComboBoxStyle.DropDownList;
            aCbxList[0].SelectedIndexChanged  += new EventHandler(Param_Changed);

            // Logical Group
            lblGroup = new Label();
            lblGroup.Parent    = pnlParameters;
            lblGroup.TextAlign = ContentAlignment.BottomCenter;
            lblGroup.ForeColor = LayoutColors.ColorControlText;
            lblGroup.BackColor = Color.Transparent;
            lblGroup.Text      = Language.T("Group");

            cbxGroup = new ComboBox();
            cbxGroup.Parent  = pnlParameters;
            if(slotType == SlotTypes.OpenFilter)
                cbxGroup.Items.AddRange(new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "All"});
            if(slotType == SlotTypes.CloseFilter)
                cbxGroup.Items.AddRange(new string[] {"a", "b", "c", "d", "e", "f", "g", "h", "all"});
            cbxGroup.SelectedIndexChanged += new EventHandler(Group_Changed);
            cbxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
            toolTip.SetToolTip(cbxGroup, Language.T("The logical group of the slot."));

            // ListParams
            for (int i = 1; i < 5; i++)
            {
                aLblList[i] = new Label();
                aLblList[i].Parent    = pnlParameters;
                aLblList[i].TextAlign = ContentAlignment.BottomCenter;
                aLblList[i].ForeColor = LayoutColors.ColorControlText;
                aLblList[i].BackColor = Color.Transparent;

                aCbxList[i]               = new ComboBox();
                aCbxList[i].Parent        = pnlParameters;
                aCbxList[i].Enabled       = false;
                aCbxList[i].SelectedIndexChanged += new EventHandler(Param_Changed);
                aCbxList[i].DropDownStyle = ComboBoxStyle.DropDownList;
            }

            // NumParams
            for (int i = 0; i < 6; i++)
            {
                aLblNumeric[i] = new Label();
                aLblNumeric[i].Parent    = pnlParameters;
                aLblNumeric[i].TextAlign = ContentAlignment.MiddleRight;
                aLblNumeric[i].ForeColor = LayoutColors.ColorControlText;
                aLblNumeric[i].BackColor = Color.Transparent;

                aNudNumeric[i] = new NUD();
                aNudNumeric[i].Parent        = pnlParameters;
                aNudNumeric[i].TextAlign     = HorizontalAlignment.Center;
                aNudNumeric[i].Enabled       = false;
                aNudNumeric[i].ValueChanged += new EventHandler(Param_Changed);
            }

            // CheckParams
            for (int i = 0; i < 2; i++)
            {
                aChbCheck[i]                 = new CheckBox();
                aChbCheck[i].Parent          = pnlParameters;
                aChbCheck[i].CheckAlign      = ContentAlignment.MiddleLeft;
                aChbCheck[i].TextAlign       = ContentAlignment.MiddleLeft;
                aChbCheck[i].CheckedChanged += new EventHandler(Param_Changed);
                aChbCheck[i].ForeColor       = LayoutColors.ColorControlText;
                aChbCheck[i].BackColor       = Color.Transparent;
                aChbCheck[i].Enabled         = false;
            }

            //Button Accept
            btnAccept.Parent       = this;
            btnAccept.Text         = Language.T("Accept");
            btnAccept.DialogResult = DialogResult.OK;
            btnAccept.Click       += new EventHandler(BtnOk_Click);
            btnAccept.UseVisualStyleBackColor = true;

            //Button Default
            btnDefault.Parent      = this;
            btnDefault.Text        = Language.T("Default");
            btnDefault.Click      += new EventHandler(BtnDefault_Click);
            btnDefault.UseVisualStyleBackColor = true;

            //Button Help
            btnHelp.Parent         = this;
            btnHelp.Text           = Language.T("Help");
            btnHelp.Click         += new EventHandler(BtnHelp_Click);
            btnHelp.UseVisualStyleBackColor = true;

            //Button Cancel
            btnCancel.Parent       = this;
            btnCancel.Text         = Language.T("Cancel");
            btnCancel.DialogResult = DialogResult.Cancel;
            btnCancel.UseVisualStyleBackColor = true;

            SetTreeViewIndicators();

            // ComboBoxindicator index selection.
            if (isDefined)
            {
                TreeNode [] atrn = trvIndicators.Nodes.Find(Data.Strategy.Slot[slot].IndParam.IndicatorName, true);
                trvIndicators.SelectedNode = atrn[0];
                UpdateFromIndicatorParam(Data.Strategy.Slot[slot].IndParam);
                SetLogicalGroup();
                CalculateIndicator(false);
                pnlSmallBalanceChart.SetChartData();
                pnlSmallBalanceChart.InitChart();
                pnlSmallBalanceChart.Invalidate();
            }
            else
            {
                string defaultIndicator;
                if (slotType == SlotTypes.Open)
                    defaultIndicator = "Bar Opening";
                else if (slotType == SlotTypes.OpenFilter)
                    defaultIndicator = "Accelerator Oscillator";
                else if (slotType == SlotTypes.Close)
                    defaultIndicator = "Bar Closing";
                else
                    defaultIndicator = "Accelerator Oscillator";

                TreeNode[] atrn = trvIndicators.Nodes.Find(defaultIndicator, true);
                trvIndicators.SelectedNode = atrn[0];
                TrvIndicatorsLoadIndicator(atrn[0]);
            }

            oppSignalBehaviour = Data.Strategy.OppSignalAction;

            if (slotType == SlotTypes.Close && Data.Strategy.CloseFilters > 0)
                for (int iSlot = Data.Strategy.CloseSlot + 1; iSlot < Data.Strategy.Slots; iSlot++)
                    closingConditions.Add(Data.Strategy.Slot[iSlot].Clone());

            return;
        }