/// <summary> /// Initializes the strategy field /// </summary> private void InitializeStrategy() { // Button Overview var tsbtOverview = new ToolStripButton {Name = "Overview", Text = Language.T("Overview")}; tsbtOverview.Click += BtnToolsOnClick; tsbtOverview.ToolTipText = Language.T("See the strategy overview."); ToolStripStrategy.Items.Add(tsbtOverview); // Button Generator var tsbtGenerator = new ToolStripButton {Name = "Generator", Text = Language.T("Generator")}; tsbtGenerator.Click += BtnToolsOnClick; tsbtGenerator.ToolTipText = Language.T("Generate or improve a strategy."); ToolStripStrategy.Items.Add(tsbtGenerator); // Button Strategy Size 1 ButtonStrategySize1 = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.slot_size_max, Tag = 1, ToolTipText = Language.T("Show detailed info in the slots."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategySize1.Click += BtnSlotSizeClick; ToolStripStrategy.Items.Add(ButtonStrategySize1); // Button Strategy Size 2 ButtonStrategySize2 = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.slot_size_min, Tag = 2, ToolTipText = Language.T("Show minimum info in the slots."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategySize2.Click += BtnSlotSizeClick; ToolStripStrategy.Items.Add(ButtonStrategySize2); // Button Strategy Info ButtonStrategyInfo = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.str_info_infook, Tag = SlotSizeMinMidMax.min, ToolTipText = Language.T("Show the strategy description."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategyInfo.Click += BtnStrategyDescriptionClick; ToolStripStrategy.Items.Add(ButtonStrategyInfo); // Button Optimizer var tsbtOptimizer = new ToolStripButton {Name = "Optimizer", Text = Language.T("Optimizer")}; tsbtOptimizer.Click += BtnToolsOnClick; tsbtOptimizer.ToolTipText = Language.T("Optimize the strategy parameters."); ToolStripStrategy.Items.Add(tsbtOptimizer); // Strategy Layout StrategyField = new StrategyLayout(Data.Strategy.Clone()) {Parent = PanelStrategy}; StrategyField.ButtonAddOpenFilter.Click += BtnAddOpenFilterClick; StrategyField.ButtonAddCloseFilter.Click += BtnAddCloseFilterClick; ButtonShowJournalByPos = new Button { Parent = PanelStrategy, Text = Language.T("Journal by Positions"), UseVisualStyleBackColor = true }; ButtonShowJournalByPos.Click += BtnShowJournalByPosClick; ButtonShowJournalByBars = new Button { Parent = PanelStrategy, Text = Language.T("Journal by Bars"), UseVisualStyleBackColor = true }; ButtonShowJournalByBars.Click += BtnShowJournalByBarsClick; PanelStrategy.Resize += PnlStrategyResize; }
/// <summary> /// Initializes the strategy field /// </summary> private void InitializeStrategy() { // Button Overview var tsbtOverview = new ToolStripButton { Name = "Overview", Text = Language.T("Overview") }; tsbtOverview.Click += BtnToolsOnClick; tsbtOverview.ToolTipText = Language.T("See the strategy overview."); ToolStripStrategy.Items.Add(tsbtOverview); // Button Generator var tsbtGenerator = new ToolStripButton { Name = "Generator", Text = Language.T("Generator") }; tsbtGenerator.Click += BtnToolsOnClick; tsbtGenerator.ToolTipText = Language.T("Generate or improve a strategy."); ToolStripStrategy.Items.Add(tsbtGenerator); // Button Strategy Size 1 ButtonStrategySize1 = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.slot_size_max, Tag = 1, ToolTipText = Language.T("Show detailed info in the slots."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategySize1.Click += BtnSlotSizeClick; ToolStripStrategy.Items.Add(ButtonStrategySize1); // Button Strategy Size 2 ButtonStrategySize2 = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.slot_size_min, Tag = 2, ToolTipText = Language.T("Show minimum info in the slots."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategySize2.Click += BtnSlotSizeClick; ToolStripStrategy.Items.Add(ButtonStrategySize2); // Button Strategy Info ButtonStrategyInfo = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.str_info_infook, Tag = SlotSizeMinMidMax.min, ToolTipText = Language.T("Show the strategy description."), Alignment = ToolStripItemAlignment.Right }; ButtonStrategyInfo.Click += BtnStrategyDescriptionClick; ToolStripStrategy.Items.Add(ButtonStrategyInfo); // Button Optimizer var tsbtOptimizer = new ToolStripButton { Name = "Optimizer", Text = Language.T("Optimizer") }; tsbtOptimizer.Click += BtnToolsOnClick; tsbtOptimizer.ToolTipText = Language.T("Optimize the strategy parameters."); ToolStripStrategy.Items.Add(tsbtOptimizer); // Strategy Layout StrategyField = new StrategyLayout(Data.Strategy.Clone()) { Parent = PanelStrategy }; StrategyField.ButtonAddOpenFilter.Click += BtnAddOpenFilterClick; StrategyField.ButtonAddCloseFilter.Click += BtnAddCloseFilterClick; ButtonShowJournalByPos = new Button { Parent = PanelStrategy, Text = Language.T("Journal by Positions"), UseVisualStyleBackColor = true }; ButtonShowJournalByPos.Click += BtnShowJournalByPosClick; ButtonShowJournalByBars = new Button { Parent = PanelStrategy, Text = Language.T("Journal by Bars"), UseVisualStyleBackColor = true }; ButtonShowJournalByBars.Click += BtnShowJournalByBarsClick; PanelStrategy.Resize += PnlStrategyResize; }
/// <summary> /// Sets the controls in tabPageStrategy /// </summary> private void InitializePageStrategy() { // tabPageStrategy TabPageStrategy.Name = "tabPageStrategy"; TabPageStrategy.Text = Language.T("Strategy"); TabPageStrategy.ImageIndex = 1; TabPageStrategy.Resize += TabPageStrategyResize; PnlOverviewBase = new Panel { Parent = TabPageStrategy, Dock = DockStyle.Fill }; PnlStrategyBase = new Panel { Parent = TabPageStrategy, Dock = DockStyle.Left }; // Panel Browser Base PnlBrawserBase = new FancyPanel(Language.T("Strategy Overview")); PnlBrawserBase.Padding = new Padding(2, (int)PnlBrawserBase.CaptionHeight, 2, 2); PnlBrawserBase.Parent = PnlOverviewBase; PnlBrawserBase.Dock = DockStyle.Fill; // BrowserOverview BrowserOverview = new WebBrowser { Parent = PnlBrawserBase, Dock = DockStyle.Fill, WebBrowserShortcutsEnabled = false, AllowWebBrowserDrop = false }; // StrategyLayout StrategyLayout = new StrategyLayout(Data.Strategy.Clone()) { Parent = PnlStrategyBase }; StrategyLayout.BtnAddOpenFilter.Click += BtnAddOpenFilterClick; StrategyLayout.BtnAddCloseFilter.Click += BtnAddCloseFilterClick; // ToolStrip Strategy TsStrategy = new ToolStrip { Parent = PnlStrategyBase, Dock = DockStyle.None, AutoSize = false }; // Button tsbtStrategyNew var tsbtStrategyNew = new ToolStripButton { Name = "New", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_new }; tsbtStrategyNew.Click += BtnStrategyIoClick; tsbtStrategyNew.ToolTipText = Language.T("Open the default strategy \"New.xml\"."); TsStrategy.Items.Add(tsbtStrategyNew); // Button tsbtStrategyOpen var tsbtStrategyOpen = new ToolStripButton { Name = "Open", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_open }; tsbtStrategyOpen.Click += BtnStrategyIoClick; tsbtStrategyOpen.ToolTipText = Language.T("Open a strategy."); TsStrategy.Items.Add(tsbtStrategyOpen); // Button tsbtStrategySave var tsbtStrategySave = new ToolStripButton { Name = "Save", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_save }; tsbtStrategySave.Click += BtnStrategyIoClick; tsbtStrategySave.ToolTipText = Language.T("Save the strategy."); TsStrategy.Items.Add(tsbtStrategySave); // Button tsbtStrategySaveAs var tsbtStrategySaveAs = new ToolStripButton { Name = "SaveAs", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_save_as }; tsbtStrategySaveAs.Click += BtnStrategyIoClick; tsbtStrategySaveAs.ToolTipText = Language.T("Save a copy of the strategy."); TsStrategy.Items.Add(tsbtStrategySaveAs); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyUndo var tsbtStrategyUndo = new ToolStripButton { Name = "Undo", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_undo }; tsbtStrategyUndo.Click += MenuStrategyUndo_OnClick; tsbtStrategyUndo.ToolTipText = Language.T("Undo the last change in the strategy."); TsStrategy.Items.Add(tsbtStrategyUndo); // Button tsbtStrategyCopy var tsbtStrategyCopy = new ToolStripButton { Name = "Copy", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.copy }; tsbtStrategyCopy.Click += MenuStrategyCopy_OnClick; tsbtStrategyCopy.ToolTipText = Language.T("Copy the entire strategy to the clipboard."); TsStrategy.Items.Add(tsbtStrategyCopy); // Button tsbtStrategyPaste var tsbtStrategyPaste = new ToolStripButton { Name = "Paste", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.paste }; tsbtStrategyPaste.Click += MenuStrategyPaste_OnClick; tsbtStrategyPaste.ToolTipText = Language.T("Load a strategy from the clipboard."); TsStrategy.Items.Add(tsbtStrategyPaste); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyZoomIn var tsbtStrategyZoomIn = new ToolStripButton { Name = "ZoomIn", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_zoom_in }; tsbtStrategyZoomIn.Click += BtnStrategyZoomClick; tsbtStrategyZoomIn.ToolTipText = Language.T("Expand the information in the strategy slots."); TsStrategy.Items.Add(tsbtStrategyZoomIn); // Button tsbtStrategyZoomOut var tsbtStrategyZoomOut = new ToolStripButton { Name = "ZoomOut", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_zoom_out }; tsbtStrategyZoomOut.Click += BtnStrategyZoomClick; tsbtStrategyZoomOut.ToolTipText = Language.T("Reduce the information in the strategy slots."); TsStrategy.Items.Add(tsbtStrategyZoomOut); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyDescription var tsbtStrategyDescription = new ToolStripButton { Name = "Description", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_description }; tsbtStrategyDescription.Click += BtnStrategyDescriptionClick; tsbtStrategyDescription.ToolTipText = Language.T("Edit the strategy description."); TsStrategy.Items.Add(tsbtStrategyDescription); // Button tsbtStrategyPublish var tsbtStrategyPublish = new ToolStripButton { Name = "Publish", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_publish }; tsbtStrategyPublish.Click += MenuStrategyBBcode_OnClick; tsbtStrategyPublish.ToolTipText = Language.T("Publish the strategy in the program's forum."); TsStrategy.Items.Add(tsbtStrategyPublish); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategySettings var tsbtStrategySettings = new ToolStripButton { Name = "Settings", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_settings }; tsbtStrategySettings.Click += BtnStrategySettings_Click; tsbtStrategySettings.ToolTipText = Language.T("Trade settings."); TsStrategy.Items.Add(tsbtStrategySettings); SetStrategyColors(); RebuildStrategyLayout(); SetSrategyOverview(); }
/// <summary> /// Rearranges the strategy slots without changing its kind and count. /// </summary> private void RearangeStrategyLayout() { StrategyLayout.RearangeStrategyControls(); }
/// <summary> /// Repaint the strategy slots without changing its kind and count. /// </summary> protected void RepaintStrategyLayout() { StrategyLayout.RepaintStrategyControls(Data.Strategy.Clone()); }
/// <summary> /// Creates a new strategy layout using Data.Strategy /// </summary> protected void RebuildStrategyLayout() { StrategyLayout.RebuildStrategyControls(Data.Strategy.Clone()); StrategyLayout.PnlProperties.Click += PnlAveragingClick; for (int slot = 0; slot < Data.Strategy.Slots; slot++) { var miEdit = new ToolStripMenuItem { Text = Language.T("Edit") + "...", Image = Resources.edit, Name = "Edit", Tag = slot }; miEdit.Click += SlotContextMenuClick; var miUpwards = new ToolStripMenuItem { Text = Language.T("Move Up"), Image = Resources.up_arrow, Name = "Upwards", Tag = slot }; miUpwards.Click += SlotContextMenuClick; miUpwards.Enabled = (slot > 1 && Data.Strategy.Slot[slot].SlotType == Data.Strategy.Slot[slot - 1].SlotType); var miDownwards = new ToolStripMenuItem { Text = Language.T("Move Down"), Image = Resources.down_arrow, Name = "Downwards", Tag = slot }; miDownwards.Click += SlotContextMenuClick; miDownwards.Enabled = (slot < Data.Strategy.Slots - 1 && Data.Strategy.Slot[slot].SlotType == Data.Strategy.Slot[slot + 1].SlotType); var miDuplicate = new ToolStripMenuItem { Text = Language.T("Duplicate"), Image = Resources.duplicate, Name = "Duplicate", Tag = slot }; miDuplicate.Click += SlotContextMenuClick; miDuplicate.Enabled = (Data.Strategy.Slot[slot].SlotType == SlotTypes.OpenFilter && Data.Strategy.OpenFilters < Strategy.MaxOpenFilters || Data.Strategy.Slot[slot].SlotType == SlotTypes.CloseFilter && Data.Strategy.CloseFilters < Strategy.MaxCloseFilters); var miDelete = new ToolStripMenuItem { Text = Language.T("Delete"), Image = Resources.close_button, Name = "Delete", Tag = slot }; miDelete.Click += SlotContextMenuClick; miDelete.Enabled = (Data.Strategy.Slot[slot].SlotType == SlotTypes.OpenFilter || Data.Strategy.Slot[slot].SlotType == SlotTypes.CloseFilter); StrategyLayout.ApnlSlot[slot].ContextMenuStrip = new ContextMenuStrip(); StrategyLayout.ApnlSlot[slot].ContextMenuStrip.Items.AddRange(new ToolStripItem[] { miEdit, miUpwards, miDownwards, miDuplicate, miDelete }); StrategyLayout.ApnlSlot[slot].MouseClick += PnlSlotMouseUp; if (slot != Data.Strategy.OpenSlot && slot != Data.Strategy.CloseSlot) { StrategyLayout.AbtnRemoveSlot[slot].Click += BtnRemoveSlotClick; } } }
/// <summary> /// Sets the controls in tabPageStrategy /// </summary> private void InitializePageStrategy() { // tabPageStrategy TabPageStrategy.Name = "tabPageStrategy"; TabPageStrategy.Text = Language.T("Strategy"); TabPageStrategy.ImageIndex = 1; TabPageStrategy.Resize += TabPageStrategyResize; PnlOverviewBase = new Panel {Parent = TabPageStrategy, Dock = DockStyle.Fill}; PnlStrategyBase = new Panel {Parent = TabPageStrategy, Dock = DockStyle.Left}; // Panel Browser Base PnlBrawserBase = new FancyPanel(Language.T("Strategy Overview")); PnlBrawserBase.Padding = new Padding(2, (int) PnlBrawserBase.CaptionHeight, 2, 2); PnlBrawserBase.Parent = PnlOverviewBase; PnlBrawserBase.Dock = DockStyle.Fill; // BrowserOverview BrowserOverview = new WebBrowser { Parent = PnlBrawserBase, Dock = DockStyle.Fill, WebBrowserShortcutsEnabled = false, AllowWebBrowserDrop = false }; // StrategyLayout StrategyLayout = new StrategyLayout(Data.Strategy.Clone()) {Parent = PnlStrategyBase}; StrategyLayout.BtnAddOpenFilter.Click += BtnAddOpenFilterClick; StrategyLayout.BtnAddCloseFilter.Click += BtnAddCloseFilterClick; // ToolStrip Strategy TsStrategy = new ToolStrip {Parent = PnlStrategyBase, Dock = DockStyle.None, AutoSize = false}; // Button tsbtStrategyNew var tsbtStrategyNew = new ToolStripButton { Name = "New", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_new }; tsbtStrategyNew.Click += BtnStrategyIoClick; tsbtStrategyNew.ToolTipText = Language.T("Open the default strategy \"New.xml\"."); TsStrategy.Items.Add(tsbtStrategyNew); // Button tsbtStrategyOpen var tsbtStrategyOpen = new ToolStripButton { Name = "Open", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_open }; tsbtStrategyOpen.Click += BtnStrategyIoClick; tsbtStrategyOpen.ToolTipText = Language.T("Open a strategy."); TsStrategy.Items.Add(tsbtStrategyOpen); // Button tsbtStrategySave var tsbtStrategySave = new ToolStripButton { Name = "Save", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_save }; tsbtStrategySave.Click += BtnStrategyIoClick; tsbtStrategySave.ToolTipText = Language.T("Save the strategy."); TsStrategy.Items.Add(tsbtStrategySave); // Button tsbtStrategySaveAs var tsbtStrategySaveAs = new ToolStripButton { Name = "SaveAs", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_save_as }; tsbtStrategySaveAs.Click += BtnStrategyIoClick; tsbtStrategySaveAs.ToolTipText = Language.T("Save a copy of the strategy."); TsStrategy.Items.Add(tsbtStrategySaveAs); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyUndo var tsbtStrategyUndo = new ToolStripButton { Name = "Undo", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_undo }; tsbtStrategyUndo.Click += MenuStrategyUndo_OnClick; tsbtStrategyUndo.ToolTipText = Language.T("Undo the last change in the strategy."); TsStrategy.Items.Add(tsbtStrategyUndo); // Button tsbtStrategyCopy var tsbtStrategyCopy = new ToolStripButton { Name = "Copy", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.copy }; tsbtStrategyCopy.Click += MenuStrategyCopy_OnClick; tsbtStrategyCopy.ToolTipText = Language.T("Copy the entire strategy to the clipboard."); TsStrategy.Items.Add(tsbtStrategyCopy); // Button tsbtStrategyPaste var tsbtStrategyPaste = new ToolStripButton { Name = "Paste", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.paste }; tsbtStrategyPaste.Click += MenuStrategyPaste_OnClick; tsbtStrategyPaste.ToolTipText = Language.T("Load a strategy from the clipboard."); TsStrategy.Items.Add(tsbtStrategyPaste); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyZoomIn var tsbtStrategyZoomIn = new ToolStripButton { Name = "ZoomIn", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_zoom_in }; tsbtStrategyZoomIn.Click += BtnStrategyZoomClick; tsbtStrategyZoomIn.ToolTipText = Language.T("Expand the information in the strategy slots."); TsStrategy.Items.Add(tsbtStrategyZoomIn); // Button tsbtStrategyZoomOut var tsbtStrategyZoomOut = new ToolStripButton { Name = "ZoomOut", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_zoom_out }; tsbtStrategyZoomOut.Click += BtnStrategyZoomClick; tsbtStrategyZoomOut.ToolTipText = Language.T("Reduce the information in the strategy slots."); TsStrategy.Items.Add(tsbtStrategyZoomOut); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategyDescription var tsbtStrategyDescription = new ToolStripButton { Name = "Description", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_description }; tsbtStrategyDescription.Click += BtnStrategyDescriptionClick; tsbtStrategyDescription.ToolTipText = Language.T("Edit the strategy description."); TsStrategy.Items.Add(tsbtStrategyDescription); // Button tsbtStrategyPublish var tsbtStrategyPublish = new ToolStripButton { Name = "Publish", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_publish }; tsbtStrategyPublish.Click += MenuStrategyBBcode_OnClick; tsbtStrategyPublish.ToolTipText = Language.T("Publish the strategy in the program's forum."); TsStrategy.Items.Add(tsbtStrategyPublish); TsStrategy.Items.Add(new ToolStripSeparator()); // Button tsbtStrategySettings var tsbtStrategySettings = new ToolStripButton { Name = "Settings", DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.strategy_settings }; tsbtStrategySettings.Click += BtnStrategySettings_Click; tsbtStrategySettings.ToolTipText = Language.T("Trade settings."); TsStrategy.Items.Add(tsbtStrategySettings); SetStrategyColors(); RebuildStrategyLayout(); SetSrategyOverview(); }