/// <summary> /// Adds a new symbol to the list /// </summary> /// <param name="group">The group the symbol should be added as part of</param> /// <param name="symbol">The ticker symbol to add</param> /// <param name="infoPanel">A panel that displays information about the stock</param> private void AddInternal(string group, string symbol, SummaryPanel infoPanel) { DataAccessor.Subscription sub = null; if (infoPanel == null) { sub = DataAccessor.Subscribe(symbol, DataAccessor.SUBSCRIBE_FIVE_SEC); infoPanel = new PercentageChangeSummary(sub); } // Ensure the symbol is not already in the list bool isNew = true; List <StockLine> stockList; if (!Stocks.TryGetValue(group, out stockList)) { stockList = new List <StockLine>(); Stocks.Add(group, stockList); if (!GroupOrder.Contains(group)) { GroupOrder.Add(group); } GroupLabels.Add(group, new Label()); Controls.Add(GroupLabels[group]); } for (int i = 0; i < stockList.Count; i++) { if (stockList[i].Symbol.Equals(symbol)) { isNew = false; break; } } if (isNew) { StockLine newLine = new StockLine(symbol, this, infoPanel); newLine.Location = new System.Drawing.Point(5, (int)((Stocks.Count + 0.5) * (newLine.Height + 5))); newLine.MouseUp += (sender, e) => { AddStockUi(symbol); }; stockList.Add(newLine); this.Controls.Add(newLine); this.Refresh(); // Request data to fill the summary chart newLine.SummaryChart.RequestData(DateTime.Now.Date.AddHours(-12), DateTime.Now.Date.AddHours(16), new TimeSpan(0, 1, 0)); } }
public OrderSummary(Broker.Order orderInfo) : base(DataAccessor.Subscribe(orderInfo.Symbol, DataAccessor.SUBSCRIBE_FIVE_SEC)) { this.OrderInfo = orderInfo; OrderLabel = new Label(); //OrderLabel.Font = GuiStyle.Font; //OrderLabel.ForeColor = GuiStyle.DARK_GREY; OrderLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter; OrderLabel.Text = string.Format("{0} {1}", orderInfo.BuySell == Broker.Order.BuySellType.BUY ? "Buy" : "Sell", orderInfo.Quantity); OrderLabel.Size = new System.Drawing.Size(60, 15); OrderLabel.Location = new System.Drawing.Point(5, 5); Controls.Add(OrderLabel); CancelOrderButton = new GuiButton("Cancel"); CancelOrderButton.Location = new System.Drawing.Point(OrderLabel.Location.X, OrderLabel.Location.Y + OrderLabel.Height + 5); CancelOrderButton.MouseClick += (sender, e) => { Broker.Instance.CancelOrder(OrderInfo.Symbol); }; Controls.Add(CancelOrderButton); }
/// <summary> /// Performs a search on symbols close to the specified string /// </summary> /// <param name="symbol"></param> public void Search(string symbol) { DataAccessor.Search(symbol, (Dictionary <string, string> r) => { this.BeginInvoke((Action <Dictionary <string, string> >)((Dictionary <string, string> results) => { this.SuspendLayout(); ClearSearchResults(); int yPos = 35; foreach (var pair in results) { StockListItem item = new StockListItem(this, pair.Key, pair.Value); item.Location = new System.Drawing.Point(5, yPos); Controls.Add(item); yPos += 35; } this.ResumeLayout(); }), new object[] { r }); }); }