using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml; using TradeIdeas.TIProData; using TradeIdeas.ServerConnection; using TradeIdeas.TIProGUI; using TradeIdeas.XML; namespace TradeIdeas.Dashboard { public partial class MainForm : Form { private IConnectionMaster _connectionMaster; private void InitializeXmlFiles() { List appConfig = new List(3); try { // This file is shared. It contains data that we think will be useful to all // versions of the client. Primarily that's the translations. XmlDocument doc = new XmlDocument(); doc.Load("Common.xml"); XmlNode node = doc.Node(0); if (null != node) appConfig.Add(node); } catch { // This should probably be a warning, if not an error. You can't do a lot without // this file. The software will try to proceed, but it will be hard to use to // say the least. We often display "***" on the GUI, instead of a reasonable // default, if we can't find this file. This helps us find errors more quickly. string debug = System.IO.Directory.GetCurrentDirectory(); } try { // This is a bit of a hack to say the least. But it should help in the debugger. XmlDocument doc = new XmlDocument(); doc.Load(@"..\..\..\TIPro\bin\Debug\Common.xml"); XmlNode node = doc.Node(0); if (null != node) appConfig.Add(node); } catch { string debug = System.IO.Directory.GetCurrentDirectory(); } // Do we need NorthAmerica.XML? I don't think so. GuiEnvironment.XmlConfig = appConfig.Node("GUI_LIB"); } public MainForm() { InitializeXmlFiles(); _connectionMaster = new ConnectionMaster(); _connectionMaster.ConnectionBase.ConnectionFactory = new TcpIpConnectionFactory("www.trade-ideas.com", 8888); InitializeComponent(); Controls.Add(GuiEnvironment.GetSymbolListsCacheManager(_connectionMaster)); _connectionMaster.LoginManager.AccountStatusUpdate += new AccountStatusUpdate(LoginManager_AccountStatusUpdate); } void LoginManager_AccountStatusUpdate(LoginManager source, AccountStatusArgs args) { this.InvokeIfRequired((MethodInvoker)delegate { GuiEnvironment.GetSymbolListsCacheManager(_connectionMaster).RefreshFromServer(); StringBuilder sb = new StringBuilder(); sb.Append(DateTime.Now.ToString()); sb.Append(": "); sb.Append(args.accountStatus.English()); if (args.nextPayment.HasValue) { sb.Append(", next payment = "); sb.Append(args.nextPayment.Value); } sb.Append(", oddsmaker = "); sb.Append(args.oddsmakerAvailable); accountStatusLabel.Text = sb.ToString(); }); } private void showWatchlistButton_Click(object sender, EventArgs e) { new SelectWatchList(_connectionMaster).Show(); } private void loginButton_Click(object sender, EventArgs e) { _connectionMaster.LoginManager.Username = usernameTextBox.Text; _connectionMaster.LoginManager.Password = passwordTextBox.Text; } } }