Beispiel #1
0
        /// <summary>
        /// For performance reasons, we don't call EhSelfChanged during the suspended state. Instead, when we resume here, we compare the saved state of this instance with the current state of the instance
        /// and and set our accumulated data accordingly.
        /// </summary>
        protected override void OnResume()
        {
            BoundariesChangedData data = 0;

            // if anything changed in the meantime, fire the event
            if (_savedNumberOfItems != _numberOfItems)
            {
                data |= BoundariesChangedData.NumberOfItemsChanged;
            }

            if (_cachedMinValue != _minValue)
            {
                data |= BoundariesChangedData.LowerBoundChanged;
            }

            if (_cachedMaxValue != _maxValue)
            {
                data |= BoundariesChangedData.UpperBoundChanged;
            }

            if (0 != data)
            {
                if (null == _accumulatedEventData)
                {
                    _accumulatedEventData = new BoundariesChangedEventArgs(data);
                }
                else
                {
                    _accumulatedEventData.Add(new BoundariesChangedEventArgs(data));
                }
            }

            base.OnResume();
        }
Beispiel #2
0
        /// <summary>
        /// merged boundaries of another object into this object
        /// </summary>
        /// <param name="b">another physical boundary object of the same type as this</param>
        public virtual void Add(NumericalBoundaries b)
        {
            if (GetType() == b.GetType())
            {
                if (b._numberOfItems > 0)
                {
                    BoundariesChangedData data = BoundariesChangedData.NumberOfItemsChanged;

                    _numberOfItems += b._numberOfItems;
                    if (b._minValue < _minValue)
                    {
                        _minValue = b._minValue;
                        data     |= BoundariesChangedData.LowerBoundChanged;
                    }
                    if (b._maxValue > _maxValue)
                    {
                        _maxValue = b._maxValue;
                        data     |= BoundariesChangedData.UpperBoundChanged;
                    }

                    if (!IsSuspended) // performance tweak, see overrides OnSuspended and OnResume for details (if suspended, we have saved the state of the instance for comparison when we resume).
                    {
                        EhSelfChanged(new BoundariesChangedEventArgs(data));
                    }
                }
            }
            else
            {
                throw new ArgumentException("Argument has not the same type as this, argument type: " + b.GetType().ToString() + ", this type: " + GetType().ToString());
            }
        }
Beispiel #3
0
        public override void Add(Main.SelfAccumulateableEventArgs e)
        {
            var other = e as BoundariesChangedEventArgs;

            if (other == null)
            {
                throw new ArgumentException(string.Format("Argument e should be of type {0}, but is: {1}", typeof(BoundariesChangedEventArgs), e.GetType()));
            }

            _data |= other._data;
        }
Beispiel #4
0
 public BoundariesChangedEventArgs(bool bLowerBound, bool bUpperBound)
 {
     if (bLowerBound)
     {
         _data |= BoundariesChangedData.LowerBoundChanged;
     }
     if (bUpperBound)
     {
         _data |= BoundariesChangedData.UpperBoundChanged;
     }
 }
Beispiel #5
0
        /// <summary>
        /// For performance reasons, we don't call EhSelfChanged during the suspended state. Instead, when we resume here, we compare the saved state of this instance with the current state of the instance
        /// and and set our accumulated data accordingly.
        /// </summary>
        protected override void OnResume()
        {
            BoundariesChangedData data = 0;

            // if anything changed in the meantime, fire the event
            if (!EnumerableExtensions.AreStructurallyEqual(_savedItems, _itemList))
            {
                data |= BoundariesChangedData.ComplexChange;
            }

            if (0 != data)
            {
                _accumulatedEventData = new BoundariesChangedEventArgs(data);
            }

            _savedItems = null;
            base.OnResume();
        }
Beispiel #6
0
        public bool Add(double d)
        {
            if (IsSuspended) // when suspended: performance tweak, see overrides OnSuspended and OnResume for details (if suspended, we have saved the state of the instance for comparison when we resume).
            {
                if (d != 0 && !double.IsNaN(d))
                {
                    d = 1 / d;
                    if (d < _minValue)
                    {
                        _minValue = d;
                    }
                    if (d > _maxValue)
                    {
                        _maxValue = d;
                    }
                    _numberOfItems++;
                    return(true);
                }
            }
            else // not suspended: normal behaviour with change notification
            {
                if (d != 0 && !double.IsNaN(d))
                {
                    d = 1 / d;
                    BoundariesChangedData data = BoundariesChangedData.NumberOfItemsChanged;
                    if (d < _minValue)
                    {
                        _minValue = d; data |= BoundariesChangedData.LowerBoundChanged;
                    }
                    if (d > _maxValue)
                    {
                        _maxValue = d; data |= BoundariesChangedData.UpperBoundChanged;
                    }
                    _numberOfItems++;

                    EhSelfChanged(new BoundariesChangedEventArgs(data));

                    return(true);
                }
            }

            return(false);
        }
Beispiel #7
0
 public void Add(BoundariesChangedData other)
 {
     _data |= other;
 }
Beispiel #8
0
 public void Add(BoundariesChangedEventArgs other)
 {
     _data |= other._data;
 }
Beispiel #9
0
 public void SetVBoundaryChangedFlag()
 {
     _data |= BoundariesChangedData.VBoundariesChanged;
 }
Beispiel #10
0
 public BoundariesChangedEventArgs(BoundariesChangedData data)
 {
     _data = data;
 }