Пример #1
0
        internal void UpdateSource(IDragEventSource src)
        {
            if (src.Id != SourceId)
            {
                throw new InvalidOperationException("Cannot change the source id of pending drag operation");
            }

            _source = src;
            (Position, Modifiers) = src.GetState();
        }
Пример #2
0
        internal DataPackageOperation Dropped(IDragEventSource src)
        {
            // For safety, we don't validate the FrameId for the finalizing actions, we rely only on the _state
            if (_state >= State.Completing)
            {
                return(_acceptedOperation);
            }

            Update(src);
            Enqueue(RaiseDrop);

            return(_acceptedOperation);
        }
Пример #3
0
        private void Update(IDragEventSource src)
        {
            // As ugly as it is, it's the behavior of UWP, the CoreDragInfo is a mutable object!
            Info.UpdateSource(src);

            // Updates the view location to follow the pointer
            // Note: This must be set AFTER the Info has been updated
            _view.SetLocation(Info.Position);

            // As we have multiple sources for the pointer events (capture of the dragged element and DragRoot),
            // we make sure to not process the same event twice.
            _lastFrameId = src.FrameId;
        }
Пример #4
0
        internal CoreDragInfo(
            IDragEventSource source,
            DataPackageView data,
            DataPackageOperation allowedOperations,
            object?dragUI = null)
        {
            _source = source;
            (Position, Modifiers) = source.GetState();

            Data = data;
            AllowedOperations = allowedOperations;
            DragUI            = dragUI;
        }
Пример #5
0
        internal DataPackageOperation Moved(IDragEventSource src)
        {
            if (_state >= State.Completing || src.FrameId <= _lastFrameId)
            {
                return(_acceptedOperation);
            }

            var wasOverWindow = _isOverWindow;

            _isOverWindow = Window.Current.Bounds.Contains(src.GetPosition(null));

            Update(src);             // It's required to do that as soon as possible in order to update the view's location

            if (wasOverWindow && !_isOverWindow)
            {
                Enqueue(RaiseRecoverableLeave);
            }
            else
            {
                Enqueue(RaiseEnterOrOver, isIgnorable: _state == State.Over);                 // This is ignorable only if we already over
            }

            return(_acceptedOperation);
        }
Пример #6
0
 private DragOperation?FindOperation(IDragEventSource src)
 => _dragOperations.FirstOrDefault(drag => drag.Info.SourceId == src.Id);
Пример #7
0
 public DataPackageOperation ProcessAborted(IDragEventSource src)
 => FindOperation(src)?.Aborted(src) ?? DataPackageOperation.None;