コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the DragOperation class.
        /// </summary>
        /// <param name="dragSource">The source of the drag operation.</param>
        /// <param name="data">The data associated with the drag operation.
        /// </param>
        /// <param name="allowedEffects">The allowed effects of the drag
        /// operation.
        /// </param>
        /// <param name="initialKeyState">The initial state of the keys relevant
        /// to drag operations.</param>
        public DragOperation(DependencyObject dragSource, object data, SW.DragDropEffects allowedEffects, SW.DragDropKeyStates initialKeyState)
        {
            SW.IDataObject dataObject = data as SW.IDataObject;
            if (dataObject == null)
            {
                dataObject = new DataObject(data);
            }

            _allowedEffects = allowedEffects;
            KeyStates       = initialKeyState;

            _dragSource = dragSource;
            SW.DragEventArgs dragStartEventArgs =
                new SW.DragEventArgs()
            {
                OriginalSource = dragSource,
                AllowedEffects = allowedEffects,
                Effects        = allowedEffects,
                Data           = dataObject
            };

            _lastDragEventArgs = dragStartEventArgs;
            dragStartEventArgs.AllowedEffects = allowedEffects;
            dragStartEventArgs.Data           = dataObject;

            this._dragStartEventArgs = dragStartEventArgs;

            IObservable <Event <SW.QueryContinueDragEventArgs> > sourceQueryContinue =
                from dragStartedEvent in _dragStarting
                from queryContinueDragEvent in _dragSourceQueryContinueDrag.Until(_dragCompleted)
                where queryContinueDragEvent.EventArgs.Handled
                select queryContinueDragEvent;

            sourceQueryContinue
            .Where(queryContinueDragEvent => queryContinueDragEvent.EventArgs.Action == SW.DragAction.Drop)
            .Subscribe(queryContinueDragEvent => OnTargetDrop());

            sourceQueryContinue
            .Where(queryContinueDragEvent => queryContinueDragEvent.EventArgs.Action == SW.DragAction.Cancel)
            .Subscribe(queryContinueDragEvent => OnCancel());

            _dragCompleted.Subscribe(_ => IsDragging = false);
        }
コード例 #2
0
 /// <summary>
 /// Retrieves the data based using the first acceptable format.
 /// </summary>
 /// <param name="that">The data object.</param>
 /// <returns>The data retrieved from the data object.</returns>
 public static object GetData(this SW.IDataObject that)
 {
     return(that.GetData(that.GetFormats()[0]));
 }