从 DataGridView 将源的 ID(人)更改为其昵称

问题描述 投票:0回答:0

我有一个用 c# 编写的程序,可以检索 Binance 交易员“排行榜”的位置。

在数据网格视图的第二列(“EncryptedUid”见图片)它检索交易者的 ID 但我想显示他的昵称而不是他的 ID

我已经尝试了几天但没有成功。告诉你,靠着寻找,我双眼发红,火辣辣的……

这是一段代码,也许有人可以帮助我

谢谢

Here is the screenshot

代码:

 private async Task<string> CreateTemplateMessage(string templateMessage, Position position)
{
  string orderType = position.Amount > 0.0 ? "BUY (LONG)" : "SELL (SHORT)";
  templateMessage = templateMessage.Contains(FMain.ENCRYPTED_UID) ? templateMessage.Replace(FMain.ENCRYPTED_UID, position.EncryptedUid) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.SYMBOL) ? templateMessage.Replace(FMain.SYMBOL, position.Symbol) : templateMessage;
  double num;
  string str3;
  if (!templateMessage.Contains(FMain.AMOUNT))
  {
    str3 = templateMessage;
  }
  else
  {
    string str4 = templateMessage;
    string amount = FMain.AMOUNT;
    num = position.Amount;
    string newValue = num.ToString();
    str3 = str4.Replace(amount, newValue);
  }
  templateMessage = str3;
  string str5;
  if (!templateMessage.Contains(FMain.ENTRY_PRICE))
  {
    str5 = templateMessage;
  }
  else
  {
    string str6 = templateMessage;
    string entryPrice = FMain.ENTRY_PRICE;
    num = position.EntryPrice;
    string newValue = num.ToString();
    str5 = str6.Replace(entryPrice, newValue);
  }
  templateMessage = str5;
  string str7;
  if (!templateMessage.Contains(FMain.MARK_PRICE))
  {
    str7 = templateMessage;
  }
  else
  {
    string str8 = templateMessage;
    string markPrice = FMain.MARK_PRICE;
    num = position.MarkPrice;
    string newValue = num.ToString();
    str7 = str8.Replace(markPrice, newValue);
  }
  templateMessage = str7;
  string str9;
  if (!templateMessage.Contains(FMain.PNL))
  {
    str9 = templateMessage;
  }
  else
  {
    string str10 = templateMessage;
    string pnl = FMain.PNL;
    num = Math.Round(position.Pnl, 2);
    string newValue = num.ToString();
    str9 = str10.Replace(pnl, newValue);
  }
  templateMessage = str9;
  string str11;
  if (!templateMessage.Contains(FMain.ROE))
  {
    str11 = templateMessage;
  }
  else
  {
    string str12 = templateMessage;
    string roe = FMain.ROE;
    num = Math.Round(position.Roe * 100.0, 2);
    string newValue = num.ToString();
    str11 = str12.Replace(roe, newValue);
  }
  templateMessage = str11;
  templateMessage = templateMessage.Contains(FMain.UPDATE_TIME) ? templateMessage.Replace(FMain.UPDATE_TIME, position.UpdateTime.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.ORDER_TYPE) ? templateMessage.Replace(FMain.ORDER_TYPE, orderType) : templateMessage;
  string str1;
  if (templateMessage.Contains(FMain.TRADER_NAME))
  {
    string str2 = templateMessage;
    string oldValue = FMain.TRADER_NAME;
    string newValue = await this.GetTraderName(position.EncryptedUid);
    str1 = str2.Replace(oldValue, newValue);
    str2 = (string) null;
    oldValue = (string) null;
    newValue = (string) null;
  }
  else
    str1 = templateMessage;
  templateMessage = str1;
  str1 = (string) null;
  templateMessage = templateMessage.Contains(FMain.LEVERAGE) ? templateMessage.Replace(FMain.LEVERAGE, position.Leverage.ToString()) : templateMessage;
  return templateMessage;
}

private async Task<string> CreateTemplateMessagePartialsOrder(
  string templateMessage,
  Position position,
  double percentSize,
  double pnl,
  double roi,
  double sizeChange)
{
  string orderType = position.Amount > 0.0 ? "BUY (LONG)" : "SELL (SHORT)";
  templateMessage = templateMessage.Contains(FMain.ENCRYPTED_UID) ? templateMessage.Replace(FMain.ENCRYPTED_UID, position.EncryptedUid) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.SYMBOL) ? templateMessage.Replace(FMain.SYMBOL, position.Symbol) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.AMOUNT) ? templateMessage.Replace(FMain.AMOUNT, sizeChange.ToString()) : templateMessage;
  double num;
  string str3;
  if (!templateMessage.Contains(FMain.ENTRY_PRICE))
  {
    str3 = templateMessage;
  }
  else
  {
    string str4 = templateMessage;
    string entryPrice = FMain.ENTRY_PRICE;
    num = position.EntryPrice;
    string newValue = num.ToString();
    str3 = str4.Replace(entryPrice, newValue);
  }
  templateMessage = str3;
  string str5;
  if (!templateMessage.Contains(FMain.MARK_PRICE))
  {
    str5 = templateMessage;
  }
  else
  {
    string str6 = templateMessage;
    string markPrice = FMain.MARK_PRICE;
    num = position.MarkPrice;
    string newValue = num.ToString();
    str5 = str6.Replace(markPrice, newValue);
  }
  templateMessage = str5;
  string str7;
  if (!templateMessage.Contains(FMain.PNL))
  {
    str7 = templateMessage;
  }
  else
  {
    string str8 = templateMessage;
    string pnl1 = FMain.PNL;
    num = Math.Round(pnl, 2);
    string newValue = num.ToString();
    str7 = str8.Replace(pnl1, newValue);
  }
  templateMessage = str7;
  string str9;
  if (!templateMessage.Contains(FMain.ROE))
  {
    str9 = templateMessage;
  }
  else
  {
    string str10 = templateMessage;
    string roe = FMain.ROE;
    num = Math.Round(roi, 2);
    string newValue = num.ToString();
    str9 = str10.Replace(roe, newValue);
  }
  templateMessage = str9;
  templateMessage = templateMessage.Contains(FMain.UPDATE_TIME) ? templateMessage.Replace(FMain.UPDATE_TIME, position.UpdateTime.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.ORDER_TYPE) ? templateMessage.Replace(FMain.ORDER_TYPE, orderType) : templateMessage;
  string str1;
  if (templateMessage.Contains(FMain.TRADER_NAME))
  {
    string str2 = templateMessage;
    string oldValue = FMain.TRADER_NAME;
    string newValue = await this.GetTraderName(position.EncryptedUid);
    str1 = str2.Replace(oldValue, newValue);
    str2 = (string) null;
    oldValue = (string) null;
    newValue = (string) null;
  }
  else
    str1 = templateMessage;
  templateMessage = str1;
  str1 = (string) null;
  templateMessage = templateMessage.Contains(FMain.PERCENT_POSITIONS) ? templateMessage.Replace(FMain.PERCENT_POSITIONS, percentSize.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.LEVERAGE) ? templateMessage.Replace(FMain.LEVERAGE, position.Leverage.ToString()) : templateMessage;
  return templateMessage;
}

private async Task<string> CreateTemplateMessagePositionChange(
  Position position,
  bool isBuy,
  bool isIncrease,
  double sizeChange,
  double percentChange,
  string templateMessage)
{
  string orderType = isBuy ? "BUY" : "SELL";
  templateMessage = templateMessage.Contains(FMain.ENCRYPTED_UID) ? templateMessage.Replace(FMain.ENCRYPTED_UID, position.EncryptedUid) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.SYMBOL) ? templateMessage.Replace(FMain.SYMBOL, position.Symbol) : templateMessage;
  double num;
  string str3;
  if (!templateMessage.Contains(FMain.ENTRY_PRICE))
  {
    str3 = templateMessage;
  }
  else
  {
    string str4 = templateMessage;
    string entryPrice = FMain.ENTRY_PRICE;
    num = position.EntryPrice;
    string newValue = num.ToString();
    str3 = str4.Replace(entryPrice, newValue);
  }
  templateMessage = str3;
  string str5;
  if (!templateMessage.Contains(FMain.MARK_PRICE))
  {
    str5 = templateMessage;
  }
  else
  {
    string str6 = templateMessage;
    string markPrice = FMain.MARK_PRICE;
    num = position.MarkPrice;
    string newValue = num.ToString();
    str5 = str6.Replace(markPrice, newValue);
  }
  templateMessage = str5;
  string str7;
  if (!templateMessage.Contains(FMain.PNL))
  {
    str7 = templateMessage;
  }
  else
  {
    string str8 = templateMessage;
    string pnl = FMain.PNL;
    num = Math.Round(position.Pnl, 2);
    string newValue = num.ToString();
    str7 = str8.Replace(pnl, newValue);
  }
  templateMessage = str7;
  string str9;
  if (!templateMessage.Contains(FMain.ROE))
  {
    str9 = templateMessage;
  }
  else
  {
    string str10 = templateMessage;
    string roe = FMain.ROE;
    num = Math.Round(position.Roe * 100.0, 2);
    string newValue = num.ToString();
    str9 = str10.Replace(roe, newValue);
  }
  templateMessage = str9;
  templateMessage = templateMessage.Contains(FMain.UPDATE_TIME) ? templateMessage.Replace(FMain.UPDATE_TIME, position.UpdateTime.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.ORDER_TYPE) ? templateMessage.Replace(FMain.ORDER_TYPE, orderType) : templateMessage;
  string str1;
  if (templateMessage.Contains(FMain.TRADER_NAME))
  {
    string str2 = templateMessage;
    string oldValue = FMain.TRADER_NAME;
    string newValue = await this.GetTraderName(position.EncryptedUid);
    str1 = str2.Replace(oldValue, newValue);
    str2 = (string) null;
    oldValue = (string) null;
    newValue = (string) null;
  }
  else
    str1 = templateMessage;
  templateMessage = str1;
  str1 = (string) null;
  templateMessage = templateMessage.Contains(FMain.LEVERAGE) ? templateMessage.Replace(FMain.LEVERAGE, position.Leverage.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.POSITION_TYPE_CHANGE) ? templateMessage.Replace(FMain.POSITION_TYPE_CHANGE, isIncrease ? "INCREASE" : "DECREASE") : templateMessage;
  templateMessage = templateMessage.Contains(FMain.AMOUNT_CHANGE) ? templateMessage.Replace(FMain.AMOUNT_CHANGE, sizeChange.ToString()) : templateMessage;
  templateMessage = templateMessage.Contains(FMain.PERCENT_CHANGE) ? templateMessage.Replace(FMain.PERCENT_CHANGE, percentChange.ToString()) : templateMessage;
  return templateMessage;
}

private async Task<string> GetTraderName(string id)
{
  TraderInfo traderInfo = await BinanceApi.GetBaseInfo(id);
  return traderInfo.NickName;
}

private void dtgvPositions_DataBindingComplete(
  object sender,
  DataGridViewBindingCompleteEventArgs e)
{
  List<string> lstUID = this.ReplaceDownTheLine(this.txtUIDs.Text.Trim());
  Dictionary<string, bool> lstUIDColor = new Dictionary<string, bool>();
  for (int index = 0; index < lstUID.Count; ++index)
    lstUIDColor.Add(lstUID[index], index % 2 == 0);
  this.dtgvPositions.Invoke((Action) (() =>
  {
    foreach (string str in lstUID)
    {
      foreach (DataGridViewRow row in (IEnumerable) this.dtgvPositions.Rows)
      {
        string key = row.Cells[1].Value.ToString();
        Decimal num = 0M;
        try
        {
          num = Decimal.Parse(row.Cells[7].Value.ToString());
        }
        catch
        {
        }
        bool flag;
        lstUIDColor.TryGetValue(key, out flag);
        row.DefaultCellStyle.ForeColor = num >= 0M ? Color.Green : Color.Red;
        row.DefaultCellStyle.BackColor = flag ? FMain.COLOR_A : FMain.COLOR_B;
      }
    }
  }));
}

private void btnStart_Click(object sender, EventArgs e)
{
  try
  {
    FMain.Log.Info((object) "Start auto check");
    if (string.IsNullOrEmpty(this.txtUIDs.Text.Trim()))
    {
      FMain.Log.Error((object) "No data UID list");
    }
    else
    {
      bool flag = this.cbUseTeleBot.Checked;
      bool flagSendAlertNewBuyOrder = this.cbAlertNewBuyOrder.Checked;
      bool flagSendAlertNewSellOrder = this.cbAlertNewSellOrder.Checked;
      bool flagSendAlertCancelOrder = this.cbAlertCancelOrder.Checked;
      bool flagSendAlertPartials = this.cbAlertPartialsCloseOrder.Checked;
      bool flagSendAlertPositionChange = this.cbAlertPositionIncrease.Checked;
      string templateMsgLongOrder = this.txtMessageLongOrder.Text.Trim();
      string templateMsgSellOrder = this.txtMessageSellOrder.Text.Trim();
      string templateMsgCancelOrder = this.txtMessageCancelOrder.Text.Trim();
      string templateMsgPartialsOrder = this.txtMsgPartialsClosedOrder.Text.Trim();
      string templateMsgPositionChange = this.txtMessagePositionIncrease.Text.Trim();
      if (flag)
      {
        if (string.IsNullOrEmpty(this.txtTelegramKey.Text.Trim()))
        {
          FMain.Log.Error((object) "No have config telegram key bot");
          return;
        }
        if (string.IsNullOrEmpty(this.txtChannelID.Text.Trim()))
        {
          FMain.Log.Error((object) "No have config channel ID");
          return;
        }
        if (flagSendAlertNewBuyOrder && string.IsNullOrEmpty(this.txtMessageLongOrder.Text.Trim()))
        {
          FMain.Log.Error((object) "No setting message new BUY order");
          return;
        }
        if (flagSendAlertNewSellOrder && string.IsNullOrEmpty(this.txtMessageSellOrder.Text.Trim()))
        {
          FMain.Log.Error((object) "No setting message new SELL order");
          return;
        }
        if (flagSendAlertCancelOrder && string.IsNullOrEmpty(this.txtMessageCancelOrder.Text.Trim()))
        {
          FMain.Log.Error((object) "No setting message new CANCEL order");
          return;
        }
        if (flagSendAlertPartials && string.IsNullOrEmpty(templateMsgPartialsOrder))
        {
          FMain.Log.Error((object) "No setting message PARTIALS closed order");
          return;
        }
        if (flagSendAlertPositionChange && string.IsNullOrEmpty(templateMsgPositionChange))
        {
          FMain.Log.Error((object) "No setting message position change");
          return;
        }
      }
      List<string> lstUID = this.ReplaceDownTheLine(this.txtUIDs.Text.Trim());
      if (lstUID == null || lstUID.Count == 0)
        throw new Exception("Input UID list");
      TradeSetting tradeSetting = this.GetTradeSetting();
      if (tradeSetting.FlagUseTrade && this.BybitClient == null)
        throw new Exception("Please connection account to use auto trade");
      this.grSettings.Enabled = false;
      this.grTelegramSetting.Enabled = false;
      this.grTradeSetting.Enabled = false;
      this.grAccountSetting.Enabled = false;
      this.btnCreateOrder.Enabled = false;
      this.cbCheckBlance.Enabled = false;
      this.btnClosePositionTest.Enabled = false;
      this.btnStart.Enabled = false;
      this.btnStop.Enabled = true;
      this.ResetPositionCached();
      string typeTrade = this.GetTradeType();
      this.ThreadAutoCheck = new Thread((ThreadStart) (async () =>
      {
        TelegramBotService telegramBotService = new TelegramBotService(this.txtTelegramKey.Text.Trim());
        string chatId = this.txtChannelID.Text.Trim();
        while (this.ThreadAutoCheck != null)
        {
          try
          {
            List<Position> otherPositions = new List<Position>();
            foreach (string str in lstUID)
            {
              string uid = str;
              List<Position> positions = await BinanceApi.GetPositions(uid, typeTrade);
              if (positions == null || positions.Count == 0)
              {
                FMain.Log.Warn((object) ("Data position of UID = " + uid + " is empty value"));
              }
              else
              {
                otherPositions.AddRange((IEnumerable<Position>) positions);
                bool isExistUID = this.PositionsCache.ContainsKey(uid);
                if (!isExistUID)
                {
                  this.PositionsCache.Add(uid, positions);
                }
                else
                {
                  List<Position> positionOld;
                  this.PositionsCache.TryGetValue(uid, out positionOld);
                  await this.HandleOrderChange(positionOld, positions, telegramBotService, flagSendAlertNewBuyOrder, flagSendAlertNewSellOrder, flagSendAlertCancelOrder, chatId, templateMsgLongOrder, templateMsgSellOrder, templateMsgCancelOrder, flagSendAlertPartials, templateMsgPartialsOrder, tradeSetting, flagSendAlertPositionChange, templateMsgPositionChange);
                  this.PositionsCache.Remove(uid);
                  this.PositionsCache.Add(uid, positions);
                  positions = (List<Position>) null;
                  positionOld = (List<Position>) null;
                  uid = (string) null;
                }
              }
            }
            this.dtgvPositions.BeginInvoke((Action) (() =>
            {
              this.dtgvPositions.DataSource = (object) otherPositions;
              this.positionBindingSource.DataSource = (object) otherPositions;
            }));
          }
          catch (Exception ex)
          {
            FMain.Log.Error((object) ex);
          }
          Thread.Sleep(int.Parse(this.nmDelay.Value.ToString()) * 1000);
        }
      }));
      this.ThreadAutoCheck.IsBackground = true;
      this.ThreadAutoCheck.Start();
    }
  }
  catch (Exception ex)
  {
    this.StopCheck();
    FMain.Log.Error((object) ex.Message);
  }
}

private void btnStop_Click(object sender, EventArgs e) => this.StopCheck();


private async void btnTestTeleBot_Click(object sender, EventArgs e)
{
  try
  {
    if (string.IsNullOrEmpty(this.txtTelegramKey.Text.Trim()))
      FMain.Log.Error((object) "No have config telegram key bot");
    else if (string.IsNullOrEmpty(this.txtChannelID.Text.Trim()))
    {
      FMain.Log.Error((object) "No have config channel ID");
    }
    else
    {
      TelegramBotService telegramBotService = new TelegramBotService(this.txtTelegramKey.Text.Trim());
      await telegramBotService.SendMessageAsync(this.txtChannelID.Text.Trim(), "Connection bot telegram success!!!");
      telegramBotService = (TelegramBotService) null;
    }
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) string.Format("Send bot test error: {0}", (object) ex));
  }
}

private void FMain_Load(object sender, EventArgs e)
{
  this.lbDemi.Text = "Remaining " + this.DateRemi + " days";
  this.cbbTypeFutures.SelectedText = "USDⓈ-M Futures";
}

private async void btnGetFeaturedUserRank_Click(object sender, EventArgs e)
{
  try
  {
    string typeTrade = "PERPETUAL";
    string typeFuturesValue = this.cbbTypeFutures.SelectedItem != null ? this.cbbTypeFutures.SelectedItem.ToString() : string.Empty;
    if (!string.IsNullOrEmpty(typeFuturesValue))
      typeTrade = typeFuturesValue.Equals("COIN-M Futures") ? "DELIVERY" : "PERPETUAL";
    List<UserRank> userRanks = await BinanceApi.GetFeaturedUserRank(typeTrade);
    if (userRanks == null || userRanks.Count == 0)
    {
      FMain.Log.Warn((object) "No have data user rank!");
    }
    else
    {
      FMain.Log.Info((object) string.Format("Result get features user rank type {0}: {1} EncryptedUid", (object) typeFuturesValue, (object) userRanks.Count));
      foreach (UserRank user in userRanks)
      {
        FMain.Log.Info((object) user.toString());
        RichTextBox txtUiDs = this.txtUIDs;
        txtUiDs.Text = txtUiDs.Text + user.EncryptedUid + "\n";
      }
      typeTrade = (string) null;
      typeFuturesValue = (string) null;
      userRanks = (List<UserRank>) null;
    }
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) string.Format("Get Featured User Rank: {0}", (object) ex));
  }
}

private void dtgvPositions_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) => this.dtgvPositions.Rows[e.RowIndex].Cells["No"].Value = (object) (e.RowIndex + 1).ToString();

private async void btnConnectAccount_ClickAsync(object sender, EventArgs e)
{
  try
  {
    if (string.IsNullOrEmpty(this.txtAPIKey.Text) || string.IsNullOrEmpty(this.txtSecretKey.Text))
      throw new Exception("API key or Sercet key invalid!");
    this.Setup(this.txtAPIKey.Text.Trim(), this.txtSecretKey.Text.Trim(), this.cbUseTestnet.Checked);
    if (await this.GetInfoAccount())
      FMain.Log.Info((object) "Connect account success!");
    else
      FMain.Log.Error((object) "Connect account fail!");
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) ex.Message);
  }
}

private void btnCreateOrder_Click(object sender, EventArgs e)
{
  try
  {
    int num = this.BybitClient != null ? (int) new FOrderTest(this.BybitClient).ShowDialog() : throw new Exception("Please connection account!");
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) ex.Message);
  }
}

private void cbUseAutoTrade_CheckedChanged(object sender, EventArgs e)
{
  this.cbCopyBuyOrder.Enabled = this.cbUseAutoTrade.Checked;
  this.cbCopySellOrder.Enabled = this.cbUseAutoTrade.Checked;
  this.nmLeveage.Enabled = this.cbUseAutoTrade.Checked;
  this.nmPercentSizeOrder.Enabled = this.cbUseAutoTrade.Checked;
  this.nmFixedSizeOrder.Enabled = this.cbUseAutoTrade.Checked;
  this.rdFixedSize.Enabled = this.cbUseAutoTrade.Checked;
  this.rdPercentSize.Enabled = this.cbUseAutoTrade.Checked;
  this.cbIsolated.Enabled = this.cbUseAutoTrade.Checked;
  this.cbCross.Enabled = this.cbUseAutoTrade.Checked;
  this.cbUseStopLoss.Enabled = this.cbUseAutoTrade.Checked;
  this.cbUseTakeProfit.Enabled = this.cbUseAutoTrade.Checked;
  this.cbAutoClosePosition.Enabled = this.cbUseAutoTrade.Checked;
  this.tbTakeProfit.Enabled = this.cbUseAutoTrade.Checked;
  this.tbStopLoss.Enabled = this.cbUseAutoTrade.Checked;
  this.cbAutoCreateOrderDCA.Enabled = this.cbUseAutoTrade.Checked;
}

private async void cbCheckBlance_Click(object sender, EventArgs e)
{
  try
  {
    if (this.BybitClient == null)
      throw new Exception("Not connection account, please connect");
    WebCallResult<Dictionary<string, BybitBalance>> resultBalances = await this.BybitClient.InverseFuturesApi.Account.GetBalancesAsync(receiveWindow: new long?(10000L));
    Dictionary<string, BybitBalance> result = resultBalances.Success ? resultBalances.Data : throw new Exception(resultBalances.Error.Message);
    foreach (KeyValuePair<string, BybitBalance> keyValuePair in result)
    {
      KeyValuePair<string, BybitBalance> data = keyValuePair;
      FMain.Log.Info((object) string.Format("Coin = {0}, Available balance = {1}, Wallet balance = {2}, Equity = {3}, Total PNL = {4}", (object) data.Key, (object) data.Value.AvailableBalance, (object) data.Value.WalletBalance, (object) data.Value.Equity, (object) data.Value.TotalRealizedPnl));
      data = new KeyValuePair<string, BybitBalance>();
    }
    result = (Dictionary<string, BybitBalance>) null;
    resultBalances = (WebCallResult<Dictionary<string, BybitBalance>>) null;
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) ex.Message);
  }
}

private void rdFixedSize_CheckedChanged(object sender, EventArgs e)
{
  this.nmFixedSizeOrder.Enabled = this.rdFixedSize.Checked;
  this.nmPercentSizeOrder.Enabled = !this.rdFixedSize.Checked;
}

private void rdPercentSize_CheckedChanged(object sender, EventArgs e)
{
  this.nmFixedSizeOrder.Enabled = !this.rdPercentSize.Checked;
  this.nmPercentSizeOrder.Enabled = this.rdPercentSize.Checked;
}

private void cbIsolated_CheckedChanged(object sender, EventArgs e) => this.cbCross.Checked = !this.cbIsolated.Checked;

private void cbCross_CheckedChanged(object sender, EventArgs e) => this.cbIsolated.Checked = !this.cbCross.Checked;

private async void btnGetLeaderboardRank_Click(object sender, EventArgs e)
{
  try
  {
    string typeTrade = "PERPETUAL";
    string typeFuturesValue = this.cbbTypeFutures.SelectedItem != null ? this.cbbTypeFutures.SelectedItem.ToString() : string.Empty;
    if (!string.IsNullOrEmpty(typeFuturesValue))
      typeTrade = typeFuturesValue.Equals("COIN-M Futures") ? "DELIVERY" : "PERPETUAL";
    List<UserRank> userRanks = await BinanceApi.GetLeaderboardRank(typeTrade);
    if (userRanks == null || userRanks.Count == 0)
    {
      FMain.Log.Warn((object) "No have data leaderboard rank!");
    }
    else
    {
      FMain.Log.Info((object) string.Format("Result get leaderboard user rank type {0}: {1} EncryptedUid", (object) typeFuturesValue, (object) userRanks.Count));
      foreach (UserRank user in userRanks)
      {
        FMain.Log.Info((object) user.toString());
        RichTextBox txtUiDs = this.txtUIDs;
        txtUiDs.Text = txtUiDs.Text + user.EncryptedUid + "\n";
      }
      typeTrade = (string) null;
      typeFuturesValue = (string) null;
      userRanks = (List<UserRank>) null;
    }
  }
  catch (Exception ex)
  {
    FMain.Log.Error((object) string.Format("Get Featured User Rank: {0}", (object) ex));
  }
}
c# visual-studio visual-studio-2010 visual-studio-2022
© www.soinside.com 2019 - 2024. All rights reserved.