private void M_dpthOnOnDataChange(object sender, ReadOnlyEventArgs <INTERACTIVE_ONLY_MBP> data)
        {
            if (Token.Text != IPAddress.HostToNetworkOrder(data.Parameter.Token).ToString())
            {
                return;
            }
            if (dgvMarketPicture.Rows.Count == 0)
            {
                return;
            }
            if (dgvMarketPicture.InvokeRequired)
            {
                dgvMarketPicture.Invoke(new OnLZOArrivedmktDelegate(M_dpthOnOnDataChange), sender, new ReadOnlyEventArgs <INTERACTIVE_ONLY_MBP>(data.Parameter));
                return;
            }
            try
            {
                if (data.Parameter.RecordBuffer != null && dgvMarketPicture.Rows.Count == 5)
                {
                    dgvMarketPicture.Rows.Clear();
                    for (int i = 0; i < 5; i++)
                    {
                        dgvMarketPicture.Rows.Insert(i);
                        dgvMarketPicture.Rows[i].Height = 20;
                    }

                    if (dgvMarketPicture.Rows.Count <= 0)
                    {
                        return;
                    }

                    for (int i = 0; i < 5; i++)
                    {
                        dgvMarketPicture[Constants.BuyOrders, i].Value = IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i].NumberOfOrders);
                        dgvMarketPicture[Constants.BQty, i].Value      = IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i].Quantity);
                        dgvMarketPicture[Constants.BuyPrice, i].Value  = (decimal)IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i].Price) / 100;      // PriceDivisor;

                        dgvMarketPicture[Constants.SellPrice, i].Value  = (decimal)IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i + 5].Price) / 100; // / PriceDivisor;
                        dgvMarketPicture[Constants.SQty, i].Value       = IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i + 5].Quantity);
                        dgvMarketPicture[Constants.SellOrders, i].Value = IPAddress.HostToNetworkOrder(data.Parameter.RecordBuffer[i + 5].NumberOfOrders);
                    }

                    lblLastTradeTime.Text = AtsMethods.SecondsToDateTime(IPAddress.HostToNetworkOrder(data.Parameter.LastTradeTime)).ToString(AtsConst.TimeFormatGrid);
                    lblLastTrdQty.Text    = Convert.ToString(IPAddress.HostToNetworkOrder(data.Parameter.LastTradeQuantity)) + "@" + Convert.ToDecimal(IPAddress.HostToNetworkOrder(data.Parameter.LastTradedPrice) / 100).ToString();
                    //lblLastUpdt.Text = AtsMethods.SecondsToDateTime(data.Header.ExchangeTimeStamp).ToString(AtsConst.TimeFormatGrid);

                    lblAvgTradePrice.Text = (IPAddress.HostToNetworkOrder(data.Parameter.AverageTradePrice) / 100).ToString();
                    lblHigh.Text          = (IPAddress.HostToNetworkOrder(data.Parameter.HighPrice) / 100).ToString();;
                    lbllow.Text           = (IPAddress.HostToNetworkOrder(data.Parameter.LowPrice) / 100).ToString();
                    //lblLtHigh.Text = (data.YearlyHigh / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    // lblLtlLow.Text = (data.YearlyLow / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);



                    //lblPrevClose.Text = (data.ClosePrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    lblOpen.Text = (IPAddress.HostToNetworkOrder(data.Parameter.OpenPrice) / 100).ToString();
                    if (IPAddress.HostToNetworkOrder(data.Parameter.ClosingPrice) != 0)
                    {
                        lblPercentage.Text = (((IPAddress.HostToNetworkOrder(data.Parameter.LastTradedPrice) - IPAddress.HostToNetworkOrder(data.Parameter.ClosingPrice)) / (decimal)IPAddress.HostToNetworkOrder(data.Parameter.ClosingPrice)) * AtsConst.PriceDivisor100).ToString();
                    }

                    lblTotalBuyQuantity.Text  = DoubleIndianChange(data.Parameter.TotalBuyQuantity).ToString();
                    lblTotalSellQuantity.Text = DoubleIndianChange(data.Parameter.TotalSellQuantity).ToString();

                    //lblOI.Text = Convert.ToString(data.Parameter.CurrentOpenInterest);
                    //lblTotalTrades.Text =

                    //                    lblValue.Text = (data.Parameter.TotalTradedValue / 100).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    lblVolume.Text = IPAddress.HostToNetworkOrder(data.Parameter.VolumeTradedToday).ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void SetData(INTERACTIVE_ONLY_MBP data)
        {
            try
            {
                if (data.RecordBuffer != null && dgvMarketPicture.Rows.Count != 5)
                {
                    dgvMarketPicture.Rows.Clear();
                    for (int i = 0; i < 5; i++)
                    {
                        dgvMarketPicture.Rows.Insert(i);
                        dgvMarketPicture.Rows[i].Height = 20;
                    }

                    if (dgvMarketPicture.Rows.Count <= 0)
                    {
                        return;
                    }

                    for (int i = 0; i < 5; i++)
                    {
                        dgvMarketPicture[Constants.BuyOrders, i].Value = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].NumberOfOrders);
                        dgvMarketPicture[Constants.BQty, i].Value      = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].Quantity);
                        dgvMarketPicture[Constants.BuyPrice, i].Value  = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].Price) / 100;      // PriceDivisor;

                        dgvMarketPicture[Constants.SellPrice, i + 5].Value  = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].Price) / 100; // / PriceDivisor;
                        dgvMarketPicture[Constants.SQty, i + 5].Value       = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].Quantity);
                        dgvMarketPicture[Constants.SellOrders, i + 5].Value = IPAddress.HostToNetworkOrder(data.RecordBuffer[i].NumberOfOrders);
                    }

                    lblLastTradeTime.Text = AtsMethods.SecondsToDateTime(data.LastTradeTime).ToString(AtsConst.TimeFormatGrid);
                    lblLastTrdQty.Text    = Convert.ToString(data.LastTradeQuantity) + "@" + Convert.ToDecimal(data.LastTradedPrice / 100).ToString();
                    //lblLastUpdt.Text = AtsMethods.SecondsToDateTime(data.Header.ExchangeTimeStamp).ToString(AtsConst.TimeFormatGrid);

                    lblAvgTradePrice.Text = (data.AverageTradePrice / 100).ToString();
                    lblHigh.Text          = (data.HighPrice / 100).ToString();;
                    lbllow.Text           = (data.LowPrice / 100).ToString();
                    //lblLtHigh.Text = (data.YearlyHigh / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    // lblLtlLow.Text = (data.YearlyLow / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);

                    //lblPrevClose.Text = (data.ClosePrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    lblOpen.Text = (data.OpenPrice / 100).ToString();
                    if (data.ClosingPrice != 0)
                    {
                        lblPercentage.Text = (((data.LastTradedPrice - data.ClosingPrice) / (decimal)data.ClosingPrice) * AtsConst.PriceDivisor100).ToString();
                    }

                    lblTotalBuyQuantity.Text  = data.TotalBuyQuantity.ToString();
                    lblTotalSellQuantity.Text = data.TotalSellQuantity.ToString();
                    //lblOI.Text = Convert.ToString(data.CurrentOpenInterest);
                    //lblTotalTrades.Text =

                    //lblValue.Text = (data.TotalTradedValue / 100).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    lblVolume.Text = data.VolumeTradedToday.ToString();
                }

                // if (ContractPanel != null && ContractPanel.ContractData != null && ContractPanel.ContractData.ContractInfo != null)
                {
                    //    if (ContractPanel.ContractData.ContractInfo.TokenNo == data.TokenNo
                    //        && ContractPanel.ContractData.ContractInfo.Exchange == data.Header.Exchange
                    //        && ContractPanel.ContractData.GatewayId == data.Header.GatewayID
                    //        )
                    //    {
                    //        if (data.Best5Buy != null && data.Best5Sell != null && dgvMarketPicture.Rows.Count != 5)
                    //        {
                    //            dgvMarketPicture.Rows.Clear();
                    //            for (int i = 0; i < 5; i++)
                    //            {
                    //                dgvMarketPicture.Rows.Insert(i);
                    //                dgvMarketPicture.Rows[i].Height = 20;
                    //            }
                    //        }
                    //        decimal PriceDivisor = data.PriceDivisor;
                    //        if (PriceDivisor == 0) return;

                    //        if (dgvMarketPicture.Rows.Count <= 0)
                    //            return;

                    //        for (int i = 0; i < 5; i++)
                    //        {
                    //            dgvMarketPicture[Constants.BuyOrders, i].Value = data.Best5Buy[i].TotalNumberOfOrders;
                    //            dgvMarketPicture[Constants.BQty, i].Value = data.Best5Buy[i].Quantity;
                    //            dgvMarketPicture[Constants.BuyPrice, i].Value = data.Best5Buy[i].OrderPrice / PriceDivisor;
                    //            dgvMarketPicture[Constants.SellPrice, i].Value = data.Best5Sell[i].OrderPrice / PriceDivisor;
                    //            dgvMarketPicture[Constants.SQty, i].Value = data.Best5Sell[i].Quantity;
                    //            dgvMarketPicture[Constants.SellOrders, i].Value = data.Best5Sell[i].TotalNumberOfOrders;
                    //        }

                    //        lblLastTradeTime.Text = AtsMethods.SecondsToDateTime(data.LastTradeTime).ToString(AtsConst.TimeFormatGrid);
                    //        lblLastTrdQty.Text = Convert.ToString(data.LastTradedQty) + "@" + Convert.ToDecimal(data.LastTradedPrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblLastUpdt.Text = AtsMethods.SecondsToDateTime(data.Header.ExchangeTimeStamp).ToString(AtsConst.TimeFormatGrid);

                    //        lblAvgTradePrice.Text = (data.AverageTradedPrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblHigh.Text = (data.HighPrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lbllow.Text = (data.LowPrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblLtHigh.Text = (data.YearlyHigh / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblLtlLow.Text = (data.YearlyLow / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);

                    //        lblPrevClose.Text = (data.ClosePrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblOpen.Text = (data.OpenPrice / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        if (data.ClosePrice != 0)
                    //            lblPercentage.Text = (((data.LastTradedPrice - data.ClosePrice) / (decimal)data.ClosePrice) * AtsConst.PriceDivisor100).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);

                    //        lblTotalBuyQuantity.Text = data.TotalBuyQty.ToString(AtsConst.PriceFormatN0);
                    //        lblTotalSellQuantity.Text = data.TotalSellQty.ToString(AtsConst.PriceFormatN0);
                    //        lblOI.Text = Convert.ToString(data.CurrentOpenInterest);
                    //        lblTotalTrades.Text = data.TotalTrades.ToString(AtsConst.PriceFormatN0);

                    //        lblValue.Text = (data.TotalTradedValue / PriceDivisor).ToString(ContractPanel.ContractData.ContractDetail.PriceFormat);
                    //        lblVolume.Text = (data.TotalQtyTraded).ToString(AtsConst.PriceFormatN0);

                    //        if (oldlasttradetime != data.LastTradeTime
                    //                    && oldLtp != 0 && data.LastTradedPrice != 0)
                    //        {
                    //            if (data.LastTradedPrice > oldLtp)
                    //            {
                    //               // pbtrend.BackgroundImage = Resources.TriangleGreen;
                    //            }
                    //            else if (data.LastTradedPrice < oldLtp)
                    //            {
                    //              //  pbtrend.BackgroundImage = Resources.TriangleRed;
                    //            }
                    //            else
                    //            {
                    //               // pbtrend.BackgroundImage = Resources.Pause;
                    //            }

                    //        }
                    //        oldLtp = data.LastTradedPrice;
                    //        oldlasttradetime = data.LastTradeTime;
                    //    }
                }
            }
            catch (Exception ex)
            {
                // AppGlobal.Logger.WriteinFileWindowAndBox(ex, LogEnums.WriteOption.LogWindow_ErrorLogFile, color: AppLog.RedColor);
            }
        }