private void objIndicesBowBroadCastProcessor_OnBroadCastRecievedNew(IdicesDetailsMain obj)
        {
            if (obj != null && ObjMinIndicesCollection.Count > 0)
            {
                foreach (var item in BroadcastMasterMemory.indicesDataDict)
                {
                    int?index;
                    index = ObjMinIndicesCollection.Where(i => i.IndexCode == item.Value.code).Select(x => ObjMinIndicesCollection.IndexOf(x)).FirstOrDefault();
                    if (index != null)
                    {
                        ObjMinIndicesCollection[(int)index].IndexValue = Convert.ToDouble(item.Value.value);
                        ObjMinIndicesCollection[(int)index].perChange  = Convert.ToString(item.Value.chngValue);

                        if (item.Value.chngValue >= 0)
                        {
                            ObjMinIndicesCollection[(int)index].PrevLTP1 = "Blue";
                            setColor = "Blue";
                        }
                        else if (item.Value.chngValue < 0)
                        {
                            ObjMinIndicesCollection[(int)index].PrevLTP1 = "OrangeRed";
                            setColor = "Red";
                        }
                        else
                        {
                            ObjMinIndicesCollection[(int)index].PrevLTP1 = "Blue";
                            setColor = "Blue";
                        }
                    }
                }
            }
        }
        private void AddIndicesbtn_Click()
        {
            if (window != null)
            {
                window.SizeToContent = SizeToContent.WidthAndHeight;
            }
            var IndexCode = MasterSharedMemory.objMasterDicSyb.Where(x => x.Value.IndexID == selectedIndex).Select(z => z.Key).FirstOrDefault();

            //var IndexID = MasterSharedMemory.objMasterDicSyb.Where(x=>)

            if (SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict.Keys.Contains(IndexCode))
            {
                //if (ObjMinIndicesCollection != null && ObjMinIndicesCollection.Count > 1)
                //{
                if (ObjMinIndicesCollection.Count != 0)
                {
                    foreach (var item in ObjMinIndicesCollection)
                    {
                        if (item.IndexCode == IndexCode)
                        {
                            int?i;
                            i = ObjMinIndicesCollection.Where(x => x.IndexCode == item.IndexCode).Select(y => ObjMinIndicesCollection.IndexOf(y)).FirstOrDefault();
                            if (i != null)
                            {
                                //ObjMinIndicesCollection[(int)i].IndexId = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexId;
                                ObjMinIndicesCollection[(int)i].IndexId            = selectedIndex.ToString().Trim();
                                ObjMinIndicesCollection[(int)i].IndexValue         = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexValue / Math.Pow(10, 2);
                                ObjMinIndicesCollection[(int)i].PreviousIndexClose = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].PreviousIndexClose / Math.Pow(10, 2);
                                if (ObjMinIndicesCollection[(int)i].IndexValue != 0 && ObjMinIndicesCollection[(int)i].PreviousIndexClose != 0)
                                {
                                    if (Math.Round(Convert.ToDouble((ObjMinIndicesCollection[(int)i].IndexValue - ObjMinIndicesCollection[(int)i].PreviousIndexClose) / ObjMinIndicesCollection[(int)i].PreviousIndexClose * 100), 2) > 0)
                                    {
                                        ObjMinIndicesCollection[(int)i].perChange = string.Format("{0}{1} {2}", "+", Math.Round(Convert.ToDouble((ObjMinIndicesCollection[(int)i].IndexValue - ObjMinIndicesCollection[(int)i].PreviousIndexClose) / ObjMinIndicesCollection[(int)i].PreviousIndexClose * 100), 2).ToString("0.00"), "%");
                                    }
                                    else
                                    {
                                        ObjMinIndicesCollection[(int)i].perChange = string.Format("{0} {1}", Math.Round(Convert.ToDouble((ObjMinIndicesCollection[(int)i].IndexValue - ObjMinIndicesCollection[(int)i].PreviousIndexClose) / ObjMinIndicesCollection[(int)i].PreviousIndexClose * 100), 2).ToString("0.00"), "%");
                                    }
                                }
                                //ObjMinIndicesCollection[(int)i].perChange = Math.Round((ObjMinIndicesCollection[(int)i].IndexValue - ObjMinIndicesCollection[(int)i].PreviousIndexClose) / ObjMinIndicesCollection[(int)i].PreviousIndexClose * 100, 2);
                                TrendDiff = ObjMinIndicesCollection[(int)i].IndexValue - ObjMinIndicesCollection[(int)i].PreviousIndexClose;
                                if (TrendDiff > 0)
                                {
                                    ObjMinIndicesCollection[(int)i].PrevLTP1      = "Blue";
                                    ObjMinIndicesCollection[(int)i].ChangeInValue = string.Format("{0}{1:0.00}", "+", TrendDiff);
                                    setColor = "Blue";
                                }
                                else if (TrendDiff < 0)
                                {
                                    ObjMinIndicesCollection[(int)i].PrevLTP1      = "OrangeRed";
                                    ObjMinIndicesCollection[(int)i].ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                                    setColor = "Red";
                                }
                                else
                                {
                                    ObjMinIndicesCollection[(int)i].PrevLTP1      = "Blue";
                                    ObjMinIndicesCollection[(int)i].ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                                    setColor = "Blue";
                                }
                            }
                            break;
                        }
                        else
                        {
                            AllIndicesWindow oAllIndicesModel = new AllIndicesWindow();
                            oAllIndicesModel.IndexCode = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexCode;
                            // oAllIndicesModel.IndexId = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexId;
                            oAllIndicesModel.IndexId            = selectedIndex.ToString().Trim();
                            oAllIndicesModel.IndexValue         = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexValue / Math.Pow(10, 2);
                            oAllIndicesModel.PreviousIndexClose = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].PreviousIndexClose / Math.Pow(10, 2);
                            if (oAllIndicesModel.IndexValue != 0 && oAllIndicesModel.PreviousIndexClose != 0)
                            {
                                if (Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2) > 0)
                                {
                                    oAllIndicesModel.perChange = string.Format("{0}{1} {2}", "+", Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2).ToString("0.00"), "%");
                                }
                                else
                                {
                                    oAllIndicesModel.perChange = string.Format("{0} {1}", Math.Round(Convert.ToDouble((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100), 2).ToString("0.00"), "%");
                                }
                            }

                            TrendDiff = oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose;
                            if (TrendDiff > 0)
                            {
                                oAllIndicesModel.PrevLTP1      = "Blue";
                                oAllIndicesModel.ChangeInValue = string.Format("{0}{1:0.00}", "+", TrendDiff);
                                setColor = "Blue";
                            }
                            else if (TrendDiff < 0)
                            {
                                oAllIndicesModel.PrevLTP1 = "OrangeRed";

                                oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                                setColor = "Red";
                            }
                            else
                            {
                                oAllIndicesModel.PrevLTP1      = "Blue";
                                oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                                setColor = "Blue";
                            }

                            // oAllIndicesModel.perChange = Math.Round((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100, 2);
                            //if (!ObjMinIndicesCollection<AllIndicesWindow>.Contains(oAllIndicesModel)){ }
                            if (ObjMinIndicesCollection.Any(p => p.IndexCode == oAllIndicesModel.IndexCode))
                            {
                            }
                            else
                            {
                                ObjMinIndicesCollection.Add(oAllIndicesModel);
                            }

                            break;
                        }


                        //assign values  to object and add the object to collectio n
                    }
                }
                else
                {
                    AllIndicesWindow oAllIndicesModel = new AllIndicesWindow();
                    oAllIndicesModel.IndexCode = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexCode;
                    //oAllIndicesModel.IndexId = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexId;
                    oAllIndicesModel.IndexId = selectedIndex.ToString().Trim();

                    oAllIndicesModel.IndexValue         = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].IndexValue / Math.Pow(10, 2);
                    oAllIndicesModel.PreviousIndexClose = SharedMemories.BroadcastMasterMemory.objIndexDetailsConDict[IndexCode].PreviousIndexClose / Math.Pow(10, 2);
                    //oAllIndicesModel.perChange = Math.Round((oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose) / oAllIndicesModel.PreviousIndexClose * 100, 2);
                    //ObjMinIndicesCollection.Add(oAllIndicesModel);
                    TrendDiff = oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose;
                    if (TrendDiff > 0)
                    {
                        oAllIndicesModel.PrevLTP1      = "Blue";
                        oAllIndicesModel.ChangeInValue = string.Format("{0}{1:0.00}", "+", TrendDiff);
                        setColor = "Blue";
                    }
                    else if (TrendDiff < 0)
                    {
                        oAllIndicesModel.PrevLTP1      = "OrangeRed";
                        oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                        setColor = "Red";
                    }
                    else
                    {
                        oAllIndicesModel.PrevLTP1      = "Blue";
                        oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                        setColor = "Blue";
                    }

                    if (ObjMinIndicesCollection.Any(p => p.IndexCode == oAllIndicesModel.IndexCode))
                    {
                    }
                    else
                    {
                        ObjMinIndicesCollection.Add(oAllIndicesModel);
                    }
                }
                //}
                //else {
                // ObjMinIndicesCollection[0].IndexId = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[IndexCode].IndexId;
                //ObjMinIndicesCollection[0].IndexValue = BroadcastMaster.BroadcastMasterMemory.objIndicesDetailsConDict[IndexCode].IndexValue;
                //ObjMinIndicesCollection[0].perChange = Math.Round((ObjMinIndicesCollection[0].IndexValue - ObjMinIndicesCollection[0].PreviousIndexClose) / ObjMinIndicesCollection[0].PreviousIndexClose * 100, 2);
                // }
            }
            else
            {
                AllIndicesWindow oAllIndicesModel = new AllIndicesWindow();
                oAllIndicesModel.IndexCode          = IndexCode;
                oAllIndicesModel.IndexId            = selectedIndex.ToString().Trim();
                oAllIndicesModel.IndexValue         = 0;
                oAllIndicesModel.PreviousIndexClose = 0;
                TrendDiff = oAllIndicesModel.IndexValue - oAllIndicesModel.PreviousIndexClose;
                if (TrendDiff > 0)
                {
                    oAllIndicesModel.PrevLTP1      = "Blue";
                    oAllIndicesModel.ChangeInValue = string.Format("{0}{1:0.00}", "+", TrendDiff);
                    setColor = "Blue";
                }
                else if (TrendDiff < 0)
                {
                    oAllIndicesModel.PrevLTP1      = "OrangeRed";
                    oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                    setColor = "Red";
                }
                else
                {
                    oAllIndicesModel.PrevLTP1      = "Blue";
                    oAllIndicesModel.ChangeInValue = string.Format("{0:0.00}", TrendDiff);
                    setColor = "Blue";
                }
                if (ObjMinIndicesCollection.Any(p => p.IndexCode == oAllIndicesModel.IndexCode))
                {
                }
                else
                {
                    ObjMinIndicesCollection.Add(oAllIndicesModel);
                }
            }
        }