Forex_Strategy_Builder.Instrument_Editor.Instrument_Editor C# (CSharp) Method

Instrument_Editor() public method

Constructor
public Instrument_Editor ( ) : System
return System
        public Instrument_Editor()
        {
            pnlInstruments   = new Fancy_Panel(Language.T("Instruments"));
            pnlProperties    = new Fancy_Panel(Language.T("Instrument Properties"));
            pnlAddInstrument = new Fancy_Panel(Language.T("Add an Instrument"));

            // Instruments' controls
            lbxInstruments = new ListBox();
            btnDelete      = new Button();
            btnUp          = new Button();
            btnDown        = new Button();

            // Properties' controls
            lblPropSymbol      = new Label();
            lblPropType        = new Label();
            lblPropComment     = new Label();
            lblPropDigits      = new Label();
            lblPropPoint       = new Label();
            lblPropLots        = new Label();
            lblPropSpread      = new Label();
            lblPropSwap        = new Label();
            lblPropCommission  = new Label();
            lblPropSlippage    = new Label();
            lblPropPriceIn     = new Label();
            lblPropAccountIn   = new Label();
            lblPropAccountRate = new Label();
            lblPropFileName    = new Label();
            lblPropDataFiles   = new Label();

            tbxPropSymbol      = new TextBox();
            tbxPropType        = new TextBox();
            tbxPropComment     = new TextBox();
            tbxPropPoint       = new TextBox();
            tbxPropSpread      = new TextBox();
            tbxPropSlippage    = new TextBox();
            tbxPropPriceIn     = new TextBox();
            tbxPropAccountIn   = new TextBox();
            tbxPropAccountRate = new TextBox();
            tbxPropFileName    = new TextBox();

            cbxPropSwap       = new ComboBox();
            cbxPropCommission = new ComboBox();
            cbxPropCommScope  = new ComboBox();
            cbxPropCommTime   = new ComboBox();

            nudPropDigits      = new NumericUpDown();
            nudPropLotSize     = new NumericUpDown();
            nudPropSpread      = new NumericUpDown();
            nudPropSwapLong    = new NumericUpDown();
            nudPropSwapShort   = new NumericUpDown();
            nudPropCommission  = new NumericUpDown();
            nudPropSlippage    = new NumericUpDown();
            nudPropAccountRate = new NumericUpDown();

            btnAccept = new Button();

            // Add an Instrument's controls
            lblAddInstrSymbol = new Label();
            lblAddInstrType   = new Label();
            tbxAddInstrSymbol = new TextBox();
            cbxAddInstrType   = new ComboBox();
            btnAddInstrAdd    = new Button();

            btnClose = new Button();

            font           = this.Font;
            fontCaption    = new Font(Font.FontFamily, 9);
            captionHeight = (float)Math.Max(fontCaption.Height, 18);
            colorText      = LayoutColors.ColorControlText;
            bNeedReset     = false;

            MaximizeBox     = false;
            MinimizeBox     = false;
            ShowInTaskbar   = false;
            Icon            = Data.Icon;
            BackColor       = LayoutColors.ColorFormBack;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            AcceptButton    = btnAccept;
            Text            = Language.T("Instrument Editor");
            FormClosing    += new FormClosingEventHandler(Instrument_Editor_FormClosing);

            // pnlInstruments
            pnlInstruments.Parent = this;

            // pnlProperties
            pnlProperties.Parent = this;

            // pnlAddInstrument
            pnlAddInstrument.Parent = this;

            // lbxInstruments
            lbxInstruments.Parent = pnlInstruments;
            lbxInstruments.BackColor = LayoutColors.ColorControlBack;
            //lbxInstruments.BorderStyle = BorderStyle.None;
            lbxInstruments.ForeColor = colorText;
            lbxInstruments.Items.AddRange(Instruments.SymbolList);

            // Button UP
            btnUp.Parent = pnlInstruments;
            btnUp.Text   = Language.T("Up");
            btnUp.UseVisualStyleBackColor = true;
            btnUp.Click += new EventHandler(BtnUp_Click);

            // Button Down
            btnDown.Parent = pnlInstruments;
            btnDown.Text   = Language.T("Down");
            btnDown.UseVisualStyleBackColor = true;
            btnDown.Click += new EventHandler(BtnDown_Click);

            // Button Delete
            btnDelete.Parent = pnlInstruments;
            btnDelete.Text   = Language.T("Delete");
            btnDelete.UseVisualStyleBackColor = true;
            btnDelete.Click += new EventHandler(BtnDelete_Click);

            // lblAddInstrSymbol
            lblAddInstrSymbol.Parent    = pnlAddInstrument;
            lblAddInstrSymbol.ForeColor = colorText;
            lblAddInstrSymbol.BackColor = Color.Transparent;
            lblAddInstrSymbol.AutoSize  = false;
            lblAddInstrSymbol.TextAlign = ContentAlignment.MiddleRight;
            lblAddInstrSymbol.Text      = Language.T("Symbol");

            // tbxAddInstrSymbol
            tbxAddInstrSymbol.Parent    = pnlAddInstrument;
            tbxAddInstrSymbol.ForeColor = colorText;

            // lblAddInstrType
            lblAddInstrType.Parent    = pnlAddInstrument;
            lblAddInstrType.ForeColor = colorText;
            lblAddInstrType.BackColor = Color.Transparent;
            lblAddInstrType.AutoSize  = false;
            lblAddInstrType.TextAlign = ContentAlignment.MiddleRight;
            lblAddInstrType.Text      = Language.T("Type");

            // cbxAddInstrType
            cbxAddInstrType.Parent        = pnlAddInstrument;
            cbxAddInstrType.Name          = "cbxAddInstrType";
            cbxAddInstrType.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxAddInstrType.Items.AddRange(Enum.GetNames(typeof(Instrumet_Type)));
            cbxAddInstrType.SelectedIndex = 0;

            // btnAddInstrAdd
            btnAddInstrAdd.Parent = pnlAddInstrument;
            btnAddInstrAdd.Name   = "btnAddInstrAdd";
            btnAddInstrAdd.Text   = Language.T("Add");
            btnAddInstrAdd.UseVisualStyleBackColor = true;
            btnAddInstrAdd.Click += new EventHandler(BtnAddInstrAdd_Click);

            // pnlProperties
            lblPropSymbol.Parent    = pnlProperties;
            lblPropSymbol.ForeColor = colorText;
            lblPropSymbol.BackColor = Color.Transparent;
            lblPropSymbol.AutoSize  = false;
            lblPropSymbol.TextAlign = ContentAlignment.MiddleRight;
            lblPropSymbol.Text      = Language.T("Symbol");

            // lblPropType
            lblPropType.Parent    = pnlProperties;
            lblPropType.ForeColor = colorText;
            lblPropType.BackColor = Color.Transparent;
            lblPropType.AutoSize  = false;
            lblPropType.TextAlign = ContentAlignment.MiddleRight;
            lblPropType.Text      = Language.T("Type");

            // lblPropComment
            lblPropComment.Parent    = pnlProperties;
            lblPropComment.ForeColor = colorText;
            lblPropComment.BackColor = Color.Transparent;
            lblPropComment.AutoSize  = false;
            lblPropComment.TextAlign = ContentAlignment.MiddleRight;
            lblPropComment.Text      = Language.T("Comment");

            // lblPropDigits
            lblPropDigits.Parent    = pnlProperties;
            lblPropDigits.ForeColor = colorText;
            lblPropDigits.BackColor = Color.Transparent;
            lblPropDigits.AutoSize  = false;
            lblPropDigits.TextAlign = ContentAlignment.MiddleRight;
            lblPropDigits.Text      = Language.T("Digits");

            // lblPropPoint
            lblPropPoint.Parent    = pnlProperties;
            lblPropPoint.ForeColor = colorText;
            lblPropPoint.BackColor = Color.Transparent;
            lblPropPoint.AutoSize  = false;
            lblPropPoint.TextAlign = ContentAlignment.MiddleRight;
            lblPropPoint.Text      = Language.T("Point value");

            // lblPropLots
            lblPropLots.Parent    = pnlProperties;
            lblPropLots.ForeColor = colorText;
            lblPropLots.BackColor = Color.Transparent;
            lblPropLots.AutoSize  = false;
            lblPropLots.TextAlign = ContentAlignment.MiddleRight;
            lblPropLots.Text      = Language.T("Lot size");

            // lblPropSpread
            lblPropSpread.Parent    = pnlProperties;
            lblPropSpread.ForeColor = colorText;
            lblPropSpread.BackColor = Color.Transparent;
            lblPropSpread.AutoSize  = false;
            lblPropSpread.TextAlign = ContentAlignment.MiddleRight;
            lblPropSpread.Text      = Language.T("Spread in");

            // lblPropSwap
            lblPropSwap.Parent    = pnlProperties;
            lblPropSwap.ForeColor = colorText;
            lblPropSwap.BackColor = Color.Transparent;
            lblPropSwap.AutoSize  = false;
            lblPropSwap.TextAlign = ContentAlignment.MiddleRight;
            lblPropSwap.Text      = Language.T("Swap in");

            // lblPropCommission
            lblPropCommission.Parent    = pnlProperties;
            lblPropCommission.ForeColor = colorText;
            lblPropCommission.BackColor = Color.Transparent;
            lblPropCommission.AutoSize  = false;
            lblPropCommission.TextAlign = ContentAlignment.MiddleRight;
            lblPropCommission.Text      = Language.T("Commission in");

            // lblPropSlippage
            lblPropSlippage.Parent    = pnlProperties;
            lblPropSlippage.ForeColor = colorText;
            lblPropSlippage.BackColor = Color.Transparent;
            lblPropSlippage.AutoSize  = false;
            lblPropSlippage.TextAlign = ContentAlignment.MiddleRight;
            lblPropSlippage.Text      = Language.T("Slippage in");

            // lblPropPriceIn
            lblPropPriceIn.Parent    = pnlProperties;
            lblPropPriceIn.ForeColor = colorText;
            lblPropPriceIn.BackColor = Color.Transparent;
            lblPropPriceIn.AutoSize  = false;
            lblPropPriceIn.TextAlign = ContentAlignment.MiddleRight;
            lblPropPriceIn.Text      = Language.T("Price in");

            // lblPropAccountIn
            lblPropAccountIn.Parent    = pnlProperties;
            lblPropAccountIn.ForeColor = colorText;
            lblPropAccountIn.BackColor = Color.Transparent;
            lblPropAccountIn.AutoSize  = false;
            lblPropAccountIn.TextAlign = ContentAlignment.MiddleRight;
            lblPropAccountIn.Text      = Language.T("Account in");

            // lblPropAccountRate
            lblPropAccountRate.Parent    = pnlProperties;
            lblPropAccountRate.ForeColor = colorText;
            lblPropAccountRate.BackColor = Color.Transparent;
            lblPropAccountRate.AutoSize  = false;
            lblPropAccountRate.TextAlign = ContentAlignment.MiddleRight;
            lblPropAccountRate.Text      = Language.T("Account exchange rate");

            // lblPropFileName
            lblPropFileName.Parent    = pnlProperties;
            lblPropFileName.BackColor = Color.Transparent;
            lblPropFileName.ForeColor = colorText;
            lblPropFileName.AutoSize  = false;
            lblPropFileName.TextAlign = ContentAlignment.MiddleRight;
            lblPropFileName.Text      = Language.T("Base name of the data files");

            // lblPropDataFiles
            lblPropDataFiles.Parent    = pnlProperties;
            lblPropDataFiles.BackColor = Color.Transparent;
            lblPropDataFiles.ForeColor = colorText;
            lblPropDataFiles.AutoSize  = false;
            lblPropDataFiles.TextAlign = ContentAlignment.TopLeft;
            lblPropDataFiles.Text      = "";

            // tbxPropSymbol
            tbxPropSymbol.Parent    = pnlProperties;
            tbxPropSymbol.BackColor = LayoutColors.ColorControlBack;
            tbxPropSymbol.ForeColor = colorText;
            tbxPropSymbol.Enabled   = false;

            // tbxPropType
            tbxPropType.Parent    = pnlProperties;
            tbxPropType.BackColor = LayoutColors.ColorControlBack;
            tbxPropType.ForeColor = colorText;
            tbxPropType.Enabled   = false;

            // tbxPropComment
            tbxPropComment.Parent    = pnlProperties;
            tbxPropComment.BackColor = LayoutColors.ColorControlBack;
            tbxPropComment.ForeColor = colorText;

            // tbxPropPoint
            tbxPropPoint.Parent    = pnlProperties;
            tbxPropPoint.BackColor = LayoutColors.ColorControlBack;
            tbxPropPoint.ForeColor = colorText;
            tbxPropPoint.Enabled   = false;

            // tbxPropSpread
            tbxPropSpread.Parent    = pnlProperties;
            tbxPropSpread.BackColor = LayoutColors.ColorControlBack;
            tbxPropSpread.ForeColor = colorText;
            tbxPropSpread.Enabled   = false;
            tbxPropSpread.Text      = Language.T("pips");

            // tbxPropSlippage
            tbxPropSlippage.Parent    = pnlProperties;
            tbxPropSlippage.BackColor = LayoutColors.ColorControlBack;
            tbxPropSlippage.ForeColor = colorText;
            tbxPropSlippage.Enabled   = false;
            tbxPropSlippage.Text      = Language.T("pips");

            // tbxPropPriceIn
            tbxPropPriceIn.Parent       = pnlProperties;
            tbxPropPriceIn.BackColor    = LayoutColors.ColorControlBack;
            tbxPropPriceIn.ForeColor    = colorText;
            tbxPropPriceIn.TextChanged += new EventHandler(TbxPropPriceIn_TextChanged);

            // tbxPropAccountIn
            tbxPropAccountIn.Parent    = pnlProperties;
            tbxPropAccountIn.BackColor = LayoutColors.ColorControlBack;
            tbxPropAccountIn.ForeColor = colorText;
            tbxPropAccountIn.Enabled   = false;
            tbxPropAccountIn.Text      = Configs.AccountCurrency;

            // tbxPropAccountRate
            tbxPropAccountRate.Parent    = pnlProperties;
            tbxPropAccountRate.BackColor = LayoutColors.ColorControlBack;
            tbxPropAccountRate.ForeColor = colorText;
            tbxPropAccountRate.Enabled   = false;
            tbxPropAccountRate.Text      = "Deal price";

            // tbxPropFileName
            tbxPropFileName.Parent       = pnlProperties;
            tbxPropFileName.BackColor    = LayoutColors.ColorControlBack;
            tbxPropFileName.ForeColor    = colorText;
            tbxPropFileName.TextChanged += new EventHandler(TbxPropFileName_TextChanged);

            // cbxPropSwap
            cbxPropSwap.Parent        = pnlProperties;
            cbxPropSwap.Name          = "cbxPropSwap";
            cbxPropSwap.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPropSwap.Items.AddRange(new string[] { Language.T("pips"), Language.T("percents"), Language.T("money") });
            cbxPropSwap.SelectedIndex = 0;

            // cbxPropCommission
            cbxPropCommission.Parent        = pnlProperties;
            cbxPropCommission.Name          = "cbxPropCommission";
            cbxPropCommission.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPropCommission.Items.AddRange(new string[] { Language.T("pips"), Language.T("percents"), Language.T("money") });
            cbxPropCommission.SelectedIndex = 0;
            cbxPropCommission.SelectedIndexChanged += new EventHandler(CbxPropCommission_SelectedIndexChanged);

            // cbxPropCommScope
            cbxPropCommScope.Parent        = pnlProperties;
            cbxPropCommScope.Name          = "cbxPropCommScope";
            cbxPropCommScope.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPropCommScope.Items.AddRange(new string[] { Language.T("per lot"), Language.T("per deal") });
            cbxPropCommScope.SelectedIndex = 0;

            // cbxPropCommTime
            cbxPropCommTime.Parent        = pnlProperties;
            cbxPropCommTime.Name          = "cbxPropCommTime";
            cbxPropCommTime.DropDownStyle = ComboBoxStyle.DropDownList;
            cbxPropCommTime.Items.AddRange(new string[] { Language.T("at opening"), Language.T("at open/close")});
            cbxPropCommTime.SelectedIndex = 0;

            // NumericUpDown Digits
            nudPropDigits.BeginInit();
            nudPropDigits.Parent    = pnlProperties;
            nudPropDigits.Name      = "nudPropDigits";
            nudPropDigits.Minimum   = 0;
            nudPropDigits.Maximum   = 5;
            nudPropDigits.Increment = 1;
            nudPropDigits.Value     = 4;
            nudPropDigits.TextAlign = HorizontalAlignment.Center;
            nudPropDigits.ValueChanged += new EventHandler(NudPropDigits_ValueChanged);
            nudPropDigits.EndInit();

            // nudPropLotSize
            nudPropLotSize.BeginInit();
            nudPropLotSize.Parent    = pnlProperties;
            nudPropLotSize.Name      = "nudPropLotSize";
            nudPropLotSize.Minimum   = 0;
            nudPropLotSize.Maximum   = 100000;
            nudPropLotSize.Increment = 1;
            nudPropLotSize.Value     = 10000;
            nudPropLotSize.TextAlign = HorizontalAlignment.Center;
            nudPropLotSize.EndInit();

            // nudPropSpread
            nudPropSpread.BeginInit();
            nudPropSpread.Parent        = pnlProperties;
            nudPropSpread.Name          = "nudPropSpread";
            nudPropSpread.TextAlign     = HorizontalAlignment.Center;
            nudPropSpread.Minimum       = 0;
            nudPropSpread.Maximum       = 500;
            nudPropSpread.Increment     = 0.01M;
            nudPropSpread.DecimalPlaces = 2;
            nudPropSpread.Value         = 4;
            nudPropSpread.EndInit();
            toolTip.SetToolTip(nudPropSpread, Language.T("Difference between Bid and Ask prices."));

            // NumericUpDown Swap Long
            nudPropSwapLong.BeginInit();
            nudPropSwapLong.Parent        = pnlProperties;
            nudPropSwapLong.Name          = "nudPropSwapLong";
            nudPropSwapLong.TextAlign     = HorizontalAlignment.Center;
            nudPropSwapLong.Minimum       = -500;
            nudPropSwapLong.Maximum       = 500;
            nudPropSwapLong.Increment     = 0.01M;
            nudPropSwapLong.DecimalPlaces = 2;
            nudPropSwapLong.Value         = 1;
            nudPropSwapLong.EndInit();
            toolTip.SetToolTip(nudPropSwapLong, Language.T("Swap number for a long position rollover") + Environment.NewLine + Language.T("A positive value decreases your profit."));

            // NumericUpDown Swap Short
            nudPropSwapShort.BeginInit();
            nudPropSwapShort.Parent        = pnlProperties;
            nudPropSwapShort.Name          = "nudPropSwapShort";
            nudPropSwapShort.TextAlign     = HorizontalAlignment.Center;
            nudPropSwapShort.Minimum       = -500;
            nudPropSwapShort.Maximum       = 500;
            nudPropSwapShort.Increment     = 0.01M;
            nudPropSwapShort.DecimalPlaces = 2;
            nudPropSwapShort.Value         = -1;
            nudPropSwapShort.EndInit();
            toolTip.SetToolTip(nudPropSwapShort, Language.T("Swap number for a short position rollover") + Environment.NewLine + Language.T("A negative value decreases your profit."));

            // NumericUpDown nudPropCommission
            nudPropCommission.BeginInit();
            nudPropCommission.Parent        = pnlProperties;
            nudPropCommission.Name          = "nudPropCommission";
            nudPropCommission.TextAlign     = HorizontalAlignment.Center;
            nudPropCommission.Minimum       = -500;
            nudPropCommission.Maximum       = 500;
            nudPropCommission.Increment     = 0.01M;
            nudPropCommission.DecimalPlaces = 2;
            nudPropCommission.Value         = 0;
            nudPropCommission.EndInit();

            // NumericUpDown nudPropSlippage
            nudPropSlippage.BeginInit();
            nudPropSlippage.Parent        = pnlProperties;
            nudPropSlippage.Name          = "nudPropSlippage";
            nudPropSlippage.TextAlign     = HorizontalAlignment.Center;
            nudPropSlippage.Minimum       = 0;
            nudPropSlippage.Maximum       = 200;
            nudPropSlippage.Increment     = 1;
            nudPropSlippage.DecimalPlaces = 0;
            nudPropSlippage.Value         = 0;
            nudPropSlippage.EndInit();
            toolTip.SetToolTip(nudPropSlippage, Language.T("Number of pips you lose due to an inaccurate order execution."));

            // NumericUpDown nudPropAccountRate
            nudPropAccountRate.BeginInit();
            nudPropAccountRate.Parent        = pnlProperties;
            nudPropAccountRate.Name          = "nudPropAccountRate";
            nudPropAccountRate.TextAlign     = HorizontalAlignment.Center;
            nudPropAccountRate.Minimum       = 0;
            nudPropAccountRate.Maximum       = 100000;
            nudPropAccountRate.Increment     = 0.0001M;
            nudPropAccountRate.DecimalPlaces = 4;
            nudPropAccountRate.Value         = 1;
            nudPropAccountRate.ValueChanged += new EventHandler(nudPropAccountRate_ValueChanged);
            nudPropAccountRate.EndInit();

            // Button Accept
            btnAccept.Parent = pnlProperties;
            btnAccept.Name   = "btnAccept";
            btnAccept.Text   = Language.T("Accept");
            btnAccept.Click += new EventHandler(BtnAccept_Click);
            btnAccept.UseVisualStyleBackColor = true;

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