public void SearchOdds(SortableObservableCollection <IOddVw> ocOdds, DelegateFilterOdds dfo) { #if DEBUG if (this.BetDomainId == 811116) { } #endif var hsOdds = new HashSet <IOddVw>(); var lOdds = m_objLine.Odds.Clone(); var lOddViews = ocOdds.ToSyncList(); foreach (var oddLn in lOdds) { if (dfo == null || dfo(oddLn)) { hsOdds.Add(oddLn.OddView); if (!lOddViews.Contains(oddLn.OddView)) { lOddViews.Add(oddLn.OddView); } } } for (int i = 0; i < lOddViews.Count;) { IOddVw oddView = lOddViews[i]; if (!hsOdds.Contains(oddView)) { lOddViews.RemoveAt(i); } else { i++; } } if (this.LineObject.IsLiveBet.Value) { lOddViews.Sort(delegate(IOddVw ov1, IOddVw ov2) { return(ov1.LineObject.Sort.Value.CompareTo(ov2.LineObject.Sort.Value)); }); } else if (this.IsOutright) { lOddViews.Sort(delegate(IOddVw ov1, IOddVw ov2) { return(ov1.LineObject.Value.Value.CompareTo(ov2.LineObject.Value.Value)); }); } else { lOddViews.Sort(delegate(IOddVw ov1, IOddVw ov2) { return(ov1.LineObject.Sort.Value.CompareTo(ov2.LineObject.Sort.Value)); }); } ocOdds.ApplyChanges(lOddViews); }
public void SearchMatches(SortableObservableCollection <IMatchVw> ocMatches, string sSearch, string sLanguage, DelegateFilterMatches dfm, Comparison <IMatchVw> comparison) { SyncList <IMatchVw> lMatchesToSync = ocMatches.ToSyncList(); SearchMatches(lMatchesToSync, sSearch, sLanguage, dfm); if (comparison != null) { lMatchesToSync.Sort(comparison); } ocMatches.ApplyChanges(lMatchesToSync); }
public void SearchResults(SortableObservableCollection <MatchResultVw> ocMatchResults, DelegateFilterResults dfr, Comparison <MatchResultVw> comparison) { SyncList <MatchResultVw> lResultsToSync = ocMatchResults.ToSyncList(); SearchResults(lResultsToSync, dfr); if (comparison != null) { lResultsToSync.Sort(comparison); ocMatchResults.ApplyChanges(lResultsToSync); } }
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); }); } }
public void VerifySelectedOdds(SortableObservableCollection <ITipItemVw> socSelectedOdds, SyncHashSet <ITipItemVw> hsOddsToRemove = null) { CheckTime ct = new CheckTime(true, "VerifySelectedOdds(TipCount={0})", socSelectedOdds.Count); ExcpHelper.ThrowIf <ArgumentNullException>(socSelectedOdds == null, "VerifySelectedOdds(NULL) ERROR"); lock (_verifyLocker) { ct.AddEvent("Lock Entered"); if (hsOddsToRemove != null) { hsOddsToRemove.Clear(); } else { hsOddsToRemove = new SyncHashSet <ITipItemVw>(); } SyncList <ITipItemVw> lTipItems = socSelectedOdds.ToSyncList(); foreach (TipItemVw tiv in lTipItems) { // Check if selected odd is not expired if (!CheckOdd(tiv.Odd)) { hsOddsToRemove.Add(tiv); } // Check if selected odd is not yet in current collection (m_lSelectedOdds) else if (!m_lSelectedOdds.Contains(tiv.Odd)) { m_lSelectedOdds.Add(tiv.Odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, true); } } ct.AddEvent("Check Completed"); // Remove from socSelectedOdds and m_lSelectedOdds for (int i = 0; i < lTipItems.Count;) { var tiv = lTipItems[i]; if (hsOddsToRemove.Contains(tiv)) { // This Odd is expired lTipItems.Remove(tiv); socSelectedOdds.Remove(tiv); m_lSelectedOdds.Remove(tiv.Odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, false); } else { i++; } } ct.AddEvent("Remove from List Completed"); // Remove from m_lSelectedOdd those items were not removed in previous cycle for (int i = 0; i < m_lSelectedOdds.Count;) { IOddLn odd = m_lSelectedOdds[i]; TipItemVw tiv = new TipItemVw(odd); if (!lTipItems.Contains(tiv)) { m_lSelectedOdds.Remove(odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, false); } else { i++; } } ct.AddEvent("Remove from List2 Completed"); } ct.Info(m_logger); }