/// <summary> /// Initializes the strategy field /// </summary> public StrategyLayout(Strategy strategy) { SlotPropertiesTipText = Language.T("Averaging, Trading size, Protection."); SlotToolTipText = Language.T("Long position logic."); ShowRemoveSlotButtons = true; ShowAddSlotButtons = true; this.strategy = strategy; slots = strategy.Slots; SlotMinMidMax = SlotSizeMinMidMax.mid; pnlStrategy = new FlowLayoutPanel(); scrollBar = new VScrollBar(); SlotPanelsList = new ContextPanel[slots]; PanelProperties = new Panel(); for (int slot = 0; slot < slots; slot++) SlotPanelsList[slot] = new ContextPanel(); // FlowLayoutStrategy pnlStrategy.Parent = this; pnlStrategy.AutoScroll = false; //VScrollBarStrategy scrollBar.Parent = this; scrollBar.TabStop = true; scrollBar.Scroll += VScrollBarStrategyScroll; if (ShowAddSlotButtons) { var toolTip = new ToolTip(); ButtonAddOpenFilter = new Button { Tag = strategy.OpenSlot, Text = Language.T("Add an Opening Logic Condition"), Margin = new Padding(30, 0, 0, Space), UseVisualStyleBackColor = true }; toolTip.SetToolTip(ButtonAddOpenFilter, Language.T("Add a new entry logic slot to the strategy.")); ButtonAddCloseFilter = new Button { Tag = strategy.CloseSlot, Text = Language.T("Add a Closing Logic Condition"), Margin = new Padding(30, 0, 0, Space), UseVisualStyleBackColor = true }; toolTip.SetToolTip(ButtonAddCloseFilter, Language.T("Add a new exit logic slot to the strategy.")); btnClosingFilterHelp = new Button { Image = Resources.info, Margin = new Padding(2, 2, 0, Space), TabStop = false }; btnClosingFilterHelp.Click += BtnClosingFilterHelpClick; btnClosingFilterHelp.UseVisualStyleBackColor = true; } }
/// <summary> /// Initializes the strategy slots /// </summary> private void InitializeStrategySlots() { SlotPanelsList = new ContextPanel[slots]; var toolTip = new ToolTip(); // Strategy properties panel PanelProperties = new Panel {Cursor = Cursors.Hand, Tag = 100, Margin = new Padding(0, 0, 0, Space)}; PanelProperties.Paint += PnlPropertiesPaint; PanelProperties.Resize += PnlSlotResize; toolTip.SetToolTip(PanelProperties, SlotPropertiesTipText); // Slot panels settings for (int slot = 0; slot < slots; slot++) { SlotPanelsList[slot] = new ContextPanel { Cursor = Cursors.Hand, Tag = slot, Margin = new Padding(0, 0, 0, Space) }; SlotPanelsList[slot].Paint += PnlSlotPaint; SlotPanelsList[slot].Resize += PnlSlotResize; toolTip.SetToolTip(SlotPanelsList[slot], SlotToolTipText); if (ShowRemoveSlotButtons && slot != strategy.OpenSlot && slot != strategy.CloseSlot) { SlotPanelsList[slot].CloseButton.Tag = slot; toolTip.SetToolTip(SlotPanelsList[slot].CloseButton, Language.T("Discard the logic condition.")); } } // Ads the controls to the flow layout pnlStrategy.Controls.Add(PanelProperties); for (int slot = 0; slot < slots; slot++) { if (ShowAddSlotButtons && slot == strategy.CloseSlot) pnlStrategy.Controls.Add(ButtonAddOpenFilter); pnlStrategy.Controls.Add(SlotPanelsList[slot]); } if (ShowAddSlotButtons) { pnlStrategy.Controls.Add(ButtonAddCloseFilter); pnlStrategy.Controls.Add(btnClosingFilterHelp); } }