using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using TradeIdeas.TIProGUI; using TradeIdeas.TIProData.Configuration; using TradeIdeas.TIProData; using TradeIdeas.XML; using System.Xml; namespace TIScottradeAddin { public partial class EliteMenuPanel : UserControl, INeedsStrategyTree { public event LinkerChannelSelectedHandler LinkerChannelSelected; private Control _menuControl = null; private EliteChannelChooser _eliteChannelChooser = new EliteChannelChooser(); private TickPanel _tickPanel = null; public bool ExcludeChannelChooser = false; public bool ExcludeTickPanel = false; private StrategyNode _strategyNode = null; /// /// Used to populate the Channels menu. /// public StrategyNode StrategyNode { get { return _strategyNode; } set { _strategyNode = value; INeedsStrategyTree needsStrategyTree = _menuControl as INeedsStrategyTree; if (null != needsStrategyTree) needsStrategyTree.StrategyNode = _strategyNode; } } private EliteAddinHelper.LinkerChannel _linkerChannel = EliteAddinHelper.LinkerChannel.OFF; public EliteAddinHelper.LinkerChannel LinkerChannel { get { return _linkerChannel; } set { _linkerChannel = value; _eliteChannelChooser.LinkerChannel = _linkerChannel; } } public EliteMenuPanel() { InitializeComponent(); if (!ExcludeTickPanel) InitializeTickPanel(); SetupChannelChangeNotifications(); } private void InitializeTickPanel() { _tickPanel = new TickPanel(); _tickPanel.InitializeConnection(GuiEnvironment.FindConnectionMaster("")); int tickPanelHeight = GuiEnvironment.XmlConfig.Node("SCOTTRADE_DLL").Node("TICKPANEL_SIZE").Property("HEIGHT", 20); int tickPanelWidth = GuiEnvironment.XmlConfig.Node("SCOTTRADE_DLL").Node("TICKPANEL_SIZE").Property("WIDTH", 100); _tickPanel.CustomPingStringColor = Color.White; _tickPanel.BackColor = Color.FromArgb(123, 68, 165); _tickPanel.BottomColor = Color.FromArgb(98, 47, 136); _tickPanel.UseGradient = true; _tickPanel.Height = tickPanelHeight; _tickPanel.Width = tickPanelWidth; } private void SetupChannelChangeNotifications() { _eliteChannelChooser.LinkerChannelSelected += new LinkerChannelSelectedHandler(_eliteChannelChooser_LinkerChannelSelected); } void _eliteChannelChooser_LinkerChannelSelected(EliteAddinHelper.LinkerChannel linkerChannel) { if (null != LinkerChannelSelected) { _linkerChannel = linkerChannel; LinkerChannelSelected(linkerChannel); } } private void AddButtons(TIFormMenuButtons buttons) { buttons.Padding = Padding.Empty; buttons.Margin = Padding.Empty; buttons.Dock = DockStyle.Fill; if (buttons.MainForm as MultiStrategy != null || buttons.MainForm as CompareCount != null || buttons.MainForm as SingleStockWindow != null) { buttons.ShowBacktest = false; buttons.ShowChannels = false; } tableLayoutPanel1.Controls.Add(buttons, 0, 0); _menuControl = buttons; } public void SetMainControl(Control control) { TIFormMenuButtons buttons = new TIFormMenuButtons(); if (control as AlertForm != null) { buttons.AlertForm = control as AlertForm; buttons.MainForm = control as AlertForm; } else if (control as TopListForm != null) { buttons.TopListForm = control as TopListForm; buttons.MainForm = control as TopListForm; } else if (control as MultiStrategy != null) buttons.MainForm = control as MultiStrategy; else if (control as CompareCount != null) buttons.MainForm = control as CompareCount; else if (control as SingleStockWindow != null) buttons.MainForm = control as SingleStockWindow; AddButtons(buttons); if (!ExcludeTickPanel) tableLayoutPanel1.Controls.Add(_tickPanel, 1, 0); if (!ExcludeChannelChooser) { _eliteChannelChooser.Dock = DockStyle.Fill; tableLayoutPanel1.Controls.Add(_eliteChannelChooser, 2, 0); } } } }