Exemple #1
0
        public void CalculateCachedData()
        {
            if (IsDisposeInProgress)
            {
                return;
            }

            // we can calulate the bounds only if they are set before
            if (null == _xBoundaries && null == _yBoundaries && null == _zBoundaries)
            {
                return;
            }

            ISuspendToken suspendTokenX = null;
            ISuspendToken suspendTokenY = null;
            ISuspendToken suspendTokenZ = null;

            suspendTokenX = _xBoundaries?.SuspendGetToken();
            suspendTokenY = _yBoundaries?.SuspendGetToken();
            suspendTokenZ = _zBoundaries?.SuspendGetToken();

            try
            {
                _xBoundaries?.Reset();
                _yBoundaries?.Reset();
                _zBoundaries?.Reset();

                _pointCount = GetMaximumRowIndexFromDataColumns();

                IReadableColumn xColumn = XColumn;
                IReadableColumn yColumn = YColumn;
                IReadableColumn zColumn = ZColumn;

                foreach (var segment in _dataRowSelection.GetSelectedRowIndexSegmentsFromTo(0, _pointCount, _dataTable?.Document?.DataColumns, _pointCount))
                {
                    for (int rowIdx = segment.start; rowIdx < segment.endExclusive; ++rowIdx)
                    {
                        if (!xColumn.IsElementEmpty(rowIdx) && !yColumn.IsElementEmpty(rowIdx) && !zColumn.IsElementEmpty(rowIdx))
                        {
                            _xBoundaries?.Add(xColumn, rowIdx);
                            _yBoundaries?.Add(yColumn, rowIdx);
                            _zBoundaries?.Add(zColumn, rowIdx);
                        }
                    }
                }

                // now the cached data are valid
                _isCachedDataValidX = null != _xBoundaries;
                _isCachedDataValidY = null != _yBoundaries;
                _isCachedDataValidZ = null != _zBoundaries;

                // now when the cached data are valid, we can reenable the events
            }
            finally
            {
                suspendTokenX?.Resume();
                suspendTokenY?.Resume();
                suspendTokenZ?.Resume();
            }
        }
 /// <summary>
 /// Resumes changed events, either with taking the accumulated event data into account (see <see cref="Resume(ref ISuspendToken)"/>) or discarding the accumulated event data (see <see cref="ResumeSilently"/>,
 /// depending on the provided argument <paramref name="eventFiring"/>.
 /// </summary>
 /// <param name="suspendToken">The suspend token.</param>
 /// <param name="eventFiring">This argument determines if the events are resumed taking the event data into account, or the resume is silent, i.e. accumulated event data are discarded.</param>
 public void Resume(ref ISuspendToken suspendToken, EventFiring eventFiring)
 {
     if (null != suspendToken)
     {
         suspendToken.Resume(eventFiring);
         suspendToken = null;
     }
 }
 /// <summary>
 /// Resumes changed events by calling <see cref="ISuspendToken.Resume()"/> for the provided suspend token, and setting the reference to the suspend token to null.
 /// If Event data were accumulated during the suspended state, a changed event is triggered for each event data.
 /// </summary>
 /// <param name="suspendToken">The suspend token.</param>
 public void Resume(ref ISuspendToken suspendToken)
 {
     if (null != suspendToken)
     {
         suspendToken.Resume();
         suspendToken = null;
     }
 }