Exemplo n.º 1
0
        private void Plot_MouseUp(object sender, OxyMouseEventArgs e)
        {
            if (MouseMoveState == MoveState.CreatingRange)
            {
                // Don't create the range if it does not have a size set
                if (Math.Abs(_activeRange.MinimumX - _activeRange.MaximumX) > 0.0001)
                {
                    // Flip ends around if the user dragged backwards
                    if (_activeRange.MinimumX > _activeRange.MaximumX)
                    {
                        var temp = _activeRange.MaximumX;
                        _activeRange.MaximumX = _activeRange.MinimumX;
                        _activeRange.MinimumX = temp;
                    }

                    // Clamp to 0 if the user dragged behind the start
                    if (_activeRange.MinimumX < 0)
                    {
                        _activeRange.MinimumX = 0;
                    }

                    RangeCreated?.Invoke(_activeRange, _activeRange.MinimumX, _activeRange.MaximumX);
                }
                else
                {
                    SetRanges.Remove(_activeRange);
                    _activeRange.MinimumX = _activeRange.MaximumX = 0;
                    RangeRemoved?.Invoke(_activeRange, _activeRange.MinimumX, _activeRange.MaximumX);
                }
                Model.InvalidatePlot(false);
            }

            MouseMoveState = MoveState.None;
        }
Exemplo n.º 2
0
 private void RemoveRange(RectangleAnnotation range)
 {
     SetRanges.Remove(range);
     RangeRemoved?.Invoke(_activeRange, _activeRange.MinimumX, _activeRange.MaximumX);
     range.MinimumX = 0;
     range.MaximumX = 0;
     Model.InvalidatePlot(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Raises <see cref="CollectionModified" /> and <see cref="RangeRemoved" /> events
 /// </summary>
 /// <param name="e">An <see cref="System.EventArgs" /> that contains the event data</param>
 protected virtual void OnRangeRemoved(EventArgs e)
 {
     if (IgnoreEvents)
     {
         return;
     }
     RangeRemoved?.Invoke(this, e);
     OnCollectionModified(new ListModificationEventArgs(ListModification.RangeRemoved, -1, -1));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Detach data validation rule of all ranges it applies to.
        /// </summary>
        public void ClearRanges()
        {
            var allRanges = _ranges.ToList();

            _ranges.RemoveAll();

            foreach (var range in allRanges)
            {
                RangeRemoved?.Invoke(this, new RangeEventArgs(range));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Remove the specified range from the collection of range this rule applies to.
        /// </summary>
        /// <param name="range">A range to remove.</param>
        public bool RemoveRange(IXLRange range)
        {
            if (range == null)
            {
                return(false);
            }

            var res = _ranges.Remove(range);

            if (res)
            {
                RangeRemoved?.Invoke(this, new RangeEventArgs(range));
            }

            return(res);
        }