コード例 #1
0
        public static void SafelyApplyChanges <T>(SyncList <T> lSource, SyncObservableCollection <T> collTarget)
        {
            ExcpHelper.ThrowIf <InvalidOperationException>(ViewObjectBase.Dispatcher == null, "SafelyApplyChanges<{0}> ERROR", typeof(T).Name);

            if (!ViewObjectBase.Dispatcher.CheckAccess())
            {
                ViewObjectBase.Dispatcher.Invoke(new DelegateSafelyApplyChanges <T>(SafelyApplyChanges), lSource, collTarget);
            }
            else
            {
                collTarget.ApplyChanges(lSource);
            }
        }
コード例 #2
0
        protected void RefreshOddViews()
        {
#if DEBUG
            if (this.BetDomainId == 811116)
            {
            }
#endif

            var lOdds = m_objLine.Odds.Clone();
            lOdds.Sort(delegate(OddLn o1, OddLn o2) { return(o1.Sort.Value.CompareTo(o2.Sort.Value)); });

            SyncList <IOddVw> lOddViews = new SyncList <IOddVw>();

            foreach (var odd in lOdds)
            {
                lOddViews.Add(odd.OddView);
            }

            m_socOdds.ApplyChanges(lOddViews);
        }
コード例 #3
0
        public void Rotate()
        {
            if (ChangeTracker.LiveMonitors.Count <= 0)
            {
                return;
            }

            if (this.rotationCounter >= 1000)
            {
                rotationCounter = 0;
            }

            this.rotationCounter++;

            LiveMonitorViewModel lmvm = null;

            SyncList <IMatchVw> lMatches = Matches.ToSyncList();

            for (int i = 0; i < LiveMonitorsCollectionList.Count; i++)
            {
                if (!lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed)
                {
                    continue;
                }

                //check interval
                if (this.rotationCounter % lmViewModels[i].rotationInterval != 0 && this.rotationCounter != 0)
                {
                    continue;
                }

                lmvm = ChangeTracker.LiveMonitors[i].DataContext as LiveMonitorViewModel;
                Debug.Assert(lmvm != null);

                double dblItemHeight       = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT;
                double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT;

                if (LiveMonitorRotationCounters[i] >= lMatches.Count)
                {
                    LiveMonitorRotationCounters[i] = LiveMonitorRotationCounters[i] - lMatches.Count;
                }

                int iMatchIdx = LiveMonitorRotationCounters[i];

                if (iMatchIdx >= lMatches.Count)
                {
                    iMatchIdx = 0;
                }

                IMatchVw matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;



                SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i];
                double dblCurrentMonitorFilledHeight           = 0;

                SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>();

                string oldSport     = "";
                bool   isPreLiveOld = false;

                while (matchVw != null)
                {
                    if (matchVw == null || lMatchesTemp.Contains(matchVw))
                    {
                        break;
                    }

                    string currentSport = matchVw.SportDescriptor;
                    var    isPreLive    = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet;
                    if (!string.IsNullOrEmpty(currentSport))
                    {
                        if (currentSport != oldSport)
                        {
                            matchVw.IsHeaderForRotation = true;
                        }
                        else if (isPreLive && !isPreLiveOld)
                        {
                            matchVw.IsHeaderForRotation = true;
                        }
                        else
                        {
                            matchVw.IsHeaderForRotation = false;
                        }
                        oldSport     = currentSport;
                        isPreLiveOld = isPreLive;
                    }

                    dblCurrentMonitorFilledHeight += matchVw.IsHeaderForRotation ? dblHeaderItemHeight : dblItemHeight;

                    if (dblCurrentMonitorFilledHeight > lmViewModels[i].LiveOddsHeight) //lmViewModels[i].LiveOddsHeight)
                    {
                        break;
                    }
                    else
                    {
                        lMatchesTemp.Add(matchVw);
                    }

                    iMatchIdx++;

                    if (iMatchIdx >= lMatches.Count)
                    {
                        iMatchIdx = 0;
                    }

                    matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;

                    LiveMonitorRotationCounters[i]++;
                }

                Dispatcher.Invoke(() =>
                {
                    socMonitor.ApplyChanges(lMatchesTemp);     //damn thing does not applay normally changes for collections with duplicate matches with it...
                });
            }
        }
コード例 #4
0
        private void SplitCollection()
        {
            if (ChangeTracker.LiveMonitors.Count <= 0)
            {
                return;
            }

            SyncList <IMatchVw> lMatches = Matches.ToSyncList();
            int iMatchIdx = 0;

            int page = -1;

            for (int i = 0; i < LiveMonitorsCollectionList.Count; i++)
            {
                if (lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed)
                {
                    continue;
                }

                LiveMonitorViewModel lmvm = null;
                Dispatcher.Invoke(() =>
                {
                    lmvm = ChangeTracker.LiveMonitors[i].Window.DataContext as LiveMonitorViewModel;
                });
                Debug.Assert(lmvm != null);

                double dblItemHeight       = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT;
                double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT;

                Dispatcher.Invoke(() =>
                {
                    SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i];
                    double dblCurrentMonitorFilledHeight           = 0;

                    SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>();

                    IMatchVw matchVw    = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;
                    string currentSport = "";
                    bool isPreLiveOld   = false;

                    while (matchVw != null)
                    {
                        var isPreLive = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet;

                        if (matchVw.SportDescriptor != currentSport)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            currentSport = matchVw.SportDescriptor;
                        }
                        else if (page != i)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            page = i;
                        }
                        else if (isPreLive && !isPreLiveOld)
                        {
                            matchVw.IsHeaderForLiveMonitor = true;
                            isPreLiveOld = isPreLive;
                        }
                        else
                        {
                            if (dblCurrentMonitorFilledHeight + dblItemHeight <= LiveMonitorHeights[i])
                            {
                                matchVw.IsHeaderForLiveMonitor = false;
                            }
                        }

                        currentSport = matchVw.SportDescriptor;
                        page         = i;
                        isPreLiveOld = isPreLive;

                        dblCurrentMonitorFilledHeight += matchVw.IsHeaderForLiveMonitor ? dblHeaderItemHeight : dblItemHeight;

                        if (dblCurrentMonitorFilledHeight > LiveMonitorHeights[i])
                        {
                            page = i;
                            break;
                        }
                        else
                        {
                            lMatchesTemp.Add(matchVw);
                        }

                        iMatchIdx++;
                        matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null;
                    }
                    //Debug.Assert(ChangeTracker.LiveMonitors[i].threadId == socMonitor.threadid);

                    //Debug.Assert(Thread.CurrentThread == socMonitor.threadid);

                    socMonitor.ApplyChanges(lMatchesTemp);
                });
            }
        }