/// <summary>
			/// Suspend the document and resumes it periodically, for a time span of 1 second.
			/// Sometimes, depending on the probabilityToResumeTemporarily, the document is resumed temporarily.
			/// </summary>
			public void Worker()
			{
				var start = DateTime.UtcNow;
				do
				{
					System.Threading.Thread.Sleep(1);

					if (null == _suspendToken)
					{
						_suspendToken = _doc.SuspendGetToken();
					}
					else
					{
						var rnd = _rnd.NextDouble();

						if (rnd < _probabilityToResumeTemporarily)
						{
							_suspendToken.ResumeCompleteTemporarily();
						}
						else
						{
							_suspendToken.Dispose();
							_suspendToken = null;
						}
					}
				} while ((DateTime.UtcNow - start).TotalSeconds < 1);

				if (null != _suspendToken)
				{
					_suspendToken.Dispose();
					_suspendToken = null;
				}
			}
示例#2
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>
            /// Suspend the document and resumes it periodically, for a time span of 1 second.
            /// Sometimes, depending on the probabilityToResumeTemporarily, the document is resumed temporarily.
            /// </summary>
            public void Worker()
            {
                var start = DateTime.UtcNow;

                do
                {
                    System.Threading.Thread.Sleep(1);

                    if (null == _suspendToken)
                    {
                        _suspendToken = _doc.SuspendGetToken();
                    }
                    else
                    {
                        var rnd = _rnd.NextDouble();

                        if (rnd < _probabilityToResumeTemporarily)
                        {
                            _suspendToken.ResumeCompleteTemporarily();
                        }
                        else
                        {
                            _suspendToken.Dispose();
                            _suspendToken = null;
                        }
                    }
                } while ((DateTime.UtcNow - start).TotalSeconds < 1);

                if (null != _suspendToken)
                {
                    _suspendToken.Dispose();
                    _suspendToken = null;
                }
            }
 /// <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.
 /// All event data accumulated during the suspended state are discarded, and thus no change event is triggered even if the instance has changed during the suspended state.
 /// </summary>
 /// <param name="suspendToken">The suspend token.</param>
 public void ResumeSilently(ref ISuspendToken suspendToken)
 {
     if (null != suspendToken)
     {
         suspendToken.ResumeSilently();
         suspendToken = null;
     }
 }
示例#6
0
		/// <summary>
		/// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
		/// if the suppress level falls to zero.
		/// </summary>
		/// <param name="token"></param>
		/// <returns>The event count accumulated during the suspend phase.</returns>
		public int Resume(ref ISuspendToken token)
		{
			int result = 0;
			if (token != null)
			{
				token.Dispose(); // the OnResume function is called from the SuppressToken
				token = null;
			}
			return result;
		}
示例#7
0
        /// <summary>
        /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
        /// if the suppress level falls to zero.
        /// </summary>
        /// <param name="token"></param>
        /// <returns>The event count accumulated during the suspend phase.</returns>
        public int Resume(ref ISuspendToken token)
        {
            int result = 0;

            if (token != null)
            {
                token.Dispose(); // the OnResume function is called from the SuppressToken
                token = null;
            }
            return(result);
        }
示例#8
0
            public override void MoveGrip(PointD2D newPosition)
            {
                newPosition = _parent.Transformation.InverseTransformPoint(newPosition);
                var obj = (ClosedCardinalSpline)GraphObject;

                newPosition = obj._transformation.InverseTransformPoint(newPosition);

                if (null == _suspendToken)
                {
                    _suspendToken = obj.SuspendGetToken();
                }
                obj.SetPoint(_pointNumber, newPosition - _offset);
            }
示例#9
0
		/// <summary>
		/// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
		/// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true.
		/// </summary>
		/// <param name="token"></param>
		/// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param>
		/// <returns>The event count accumulated during the suspend phase.</returns>
		public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent)
		{
			int result = 0;
			if (token != null)
			{
				if (firingOfResumeEvent == EventFiring.Suppressed)
				{
					token.ResumeSilently();
				}

				token.Dispose(); // the OnResume function is called from the SuppressToken
				token = null;
			}
			return result;
		}
示例#10
0
        /// <summary>
        /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
        /// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param>
        /// <returns>The event count accumulated during the suspend phase.</returns>
        public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent)
        {
            int result = 0;

            if (token != null)
            {
                if (firingOfResumeEvent == EventFiring.Suppressed)
                {
                    token.ResumeSilently();
                }

                token.Dispose(); // the OnResume function is called from the SuppressToken
                token = null;
            }
            return(result);
        }
示例#11
0
            public override bool Deactivate()
            {
                var obj = (ClosedCardinalSpline)GraphObject;

                using (var token = obj.SuspendGetToken())
                {
                    int      otherPointIndex    = _pointNumber == 0 ? 1 : 0;
                    PointD2D oldOtherPointCoord = obj._transformation.TransformPoint(obj._curvePoints[otherPointIndex] + _offset); // transformiere in ParentCoordinaten

                    // Calculate the new Size
                    obj.CalculateAndSetBounds();
                    obj.UpdateTransformationMatrix();
                    PointD2D newOtherPointCoord = obj._transformation.TransformPoint(obj._curvePoints[otherPointIndex] + obj.Location.AbsoluteVectorPivotToLeftUpper);
                    obj.ShiftPosition(oldOtherPointCoord - newOtherPointCoord);
                }

                _suspendToken?.Dispose();
                _suspendToken = null;

                return(false);
            }