private void UpdateBTCList() { if (symbol.Length > 0 && market.Length > 0) { List <ExchangeManager.ExchangeTicker> list = ExchangeManager.GetPriceWatchlist("BTC", symbol); if (list.Count > 0) { toolStrip_btc_btc.Visible = true; toolStrip_btc_usd.Visible = true; toolStrip_btc_symbol.Visible = true; Decimal high = 0; Decimal low = 0; high = list[0].last; foreach (ExchangeManager.ExchangeTicker ticker in list) { if (ticker.last > 0) { low = ticker.last; } } Decimal spread = high - low; toolStripLabel_btc_symbol.Text = CoinMarketCap.GetMarketCapBTCAmount(symbol, spread).ToString("N8"); if (listView_btc.Items.Count > 0) { //listView_btc.RefreshObjects(list); listView_btc.BuildList(); //listView_btc.UpdateObjects(iEnumerable); } else { listView_btc.SetObjects(list); } //LogManager.AddLogMessage(Name, "UpdateUI", "symbol=" + symbol + " | " + market + " | " + high + " | " + low + " | " + spread); toolStripLabel_btc_usd.Text = CoinMarketCap.GetMarketCapUSDAmount("BTC", spread).ToString("C"); toolStripLabel_btc_btc.Text = spread.ToString("N8"); toolStripLabel_symbol.Text = CoinMarketCap.GetMarketCapCoinAmount(symbol, "BTC", spread).ToString("N8"); } if (list.Sum(item => item.last) > 0) { Enabled = true; } else { Enabled = false; } } }
public void UpdateUI(bool resize = false) { if (this.InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); this.Invoke(d, new object[] { resize }); } else { try { List <ExchangeManager.ExchangeTicker> list = ExchangeManager.GetPriceWatchlist(market, symbol); LogManager.AddLogMessage(Name, "UpdateUI", "count=" + list.Count, LogManager.LogMessageType.DEBUG); /* * if (list.Count > 0 && tableLayoutPanel.RowCount > 1) * { * int rowIndex = 0; * Decimal high = list[0].last; * Decimal low = 0; * * foreach (ExchangeManager.ExchangeTicker ticker in list) * { * Button button = tableLayoutPanel.GetControlFromPosition(0, rowIndex) as Button; * Label label = tableLayoutPanel.GetControlFromPosition(1, rowIndex) as Label; * //Control c = tableLayoutPanel.GetControlFromPosition(1, rowIndex); * //LogManager.AddLogMessage(Name, "UpdateUI", "Name=" + c.Name + " | " + c.GetType() + " | " + label.Text, LogManager.LogMessageType.DEBUG); * toolTip.SetToolTip(button, ticker.exchange); * button.Tag = ticker.exchange; * //button. * * button.BackgroundImage = ContentManager.ResizeImage(ExchangeManager.getExchangeIcon(ticker.exchange), iconSize, iconSize); * * if (market.Contains("USD")) * { * //return e.last.ToString("C"); * label.Text = ticker.last.ToString("C"); * } * else * { * //return String.Format("{0:#,#.00000000}", e.last); * label.Text = ticker.last.ToString("N8"); * } * * if (ticker.last > 0) * { * low = ticker.last; * } * rowIndex++; * } * Decimal spread = high - low; * * Label btcLabel = tableLayoutPanel.GetControlFromPosition(0, list.Count) as Label; * Label usdLabel = tableLayoutPanel.GetControlFromPosition(0, list.Count + 1) as Label; * * if (market.Contains("USD")) * { * usdLabel.Text = spread.ToString("C"); * btcLabel.Text = CoinMarketCap.GetMarketCapBTCAmount("BTC", spread).ToString("N8"); * } * else * { * usdLabel.Text = CoinMarketCap.GetMarketCapUSDAmount("BTC", spread).ToString("C"); * btcLabel.Text = spread.ToString("N8"); * } * } */ if (resize) { ResizeUI(); } } catch (Exception ex) { LogManager.AddLogMessage(Name, "UpdateUI", ex.Message, LogManager.LogMessageType.EXCEPTION); } } }
public void UpdateUI(bool resize = false) { if (InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); Invoke(d, new object[] { resize }); } else { try { if (symbol.Length > 0 && market.Length > 0) { List <ExchangeManager.ExchangeTicker> list = ExchangeManager.GetPriceWatchlist(market, symbol); if (list.Count > 0) { toolStrip_btc.Visible = true; toolStrip_usd.Visible = true; toolStrip_symbol.Visible = true; Decimal high = 0; Decimal low = 0; high = list[0].last; foreach (ExchangeManager.ExchangeTicker ticker in list) { if (ticker.last > 0) { low = ticker.last; } } Decimal spread = high - low; listView.SetObjects(list); /* * if (list.Count > PreferenceManager.ArbitragePreferences.maxListCount) * { * PreferenceManager.ArbitragePreferences.maxListCount = list.Count; * } */ //arbitrageItem.SetListCount(listView.Items.Count); toolStripLabel_symbol.Text = CoinMarketCap.GetMarketCapBTCAmount(symbol, spread).ToString("N8"); //LogManager.AddLogMessage(Name, "UpdateUI", "symbol=" + symbol + " | " + market + " | " + high + " | " + low + " | " + spread); if (market.Contains("USD")) { // SPREAD IS IN USD //LogManager.AddLogMessage(Name, "UpdateUI", "SPREAD IN USD - symbol=" + symbol + " | " + market + " | " + high + " | " + low + " | " + spread); toolStripLabel_usd.Text = spread.ToString("C"); toolStripLabel_btc.Text = CoinMarketCap.GetMarketCapBTCAmount("USDT", spread).ToString("N8"); toolStripLabel_symbol.Text = CoinMarketCap.GetMarketCapCoinAmount(symbol, "USDT", spread).ToString("N8"); } else { // SPREAD IS IN BTC //LogManager.AddLogMessage(Name, "UpdateUI", "SPREAD IN BTC - symbol=" + symbol + " | " + market + " | " + high + " | " + low + " | " + spread); toolStripLabel_usd.Text = CoinMarketCap.GetMarketCapUSDAmount("BTC", spread).ToString("C"); toolStripLabel_btc.Text = spread.ToString("N8"); toolStripLabel_symbol.Text = CoinMarketCap.GetMarketCapCoinAmount(symbol, "BTC", spread).ToString("N8"); } } if (list.Sum(item => item.last) > 0) { Enabled = true; } else { Enabled = false; } if (resize) { ResizeUI(); } } } catch (Exception) { //LogManager.AddLogMessage(Name, "UpdateUI", symbol + " | " + market + " | " + ex.Message, LogManager.LogMessageType.EXCEPTION); } } }