private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var draggedItem = (sender as ListBox).SelectedItem as MyObject;

            e.AllowedEffects = DragDropEffects.All;
            var    data = DragDropPayloadManager.GeneratePayload(null);
            string text = typeof(MyObject).ToString();

            if (draggedItem != null)
            {
                text = draggedItem.Name;
            }

            data.SetData("Text", text);
            data.SetData("DraggedData", draggedItem);

            e.DragVisual = new DragVisual()
            {
                Content = text,
            };

            e.DragVisualOffset = e.RelativeStartPoint;
            e.Data             = data;
            shouldCancelDrop   = false;
        }
        private void OnTimelineDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var itemControl = e.OriginalSource as TimelineItemControlBase;

            if (itemControl != null)
            {
                var data     = (TimelineDataItem)itemControl.DataContext;
                var dataItem = (ITimelineItem)data.DataItem;
                var payload  = DragDropPayloadManager.GeneratePayload(null);
                payload.SetData("DraggedItem", dataItem);

                e.AllowedEffects = DragDropEffects.Move;
                e.Data           = payload;

                this.dragVisual.Content = new TimelineItemDragVisualInfo()
                {
                    ItemImageSource = new RadBitmap(itemControl).Bitmap,
                    ItemImageWidth  = itemControl.ActualWidth,
                    ItemImageHeight = itemControl.ActualHeight,
                };
                e.DragVisual = this.dragVisual;

                this.groupControlInfos = GetGroupInfos(timeline);
            }
        }
Example #3
0
        private static void DragStart(UIElement source)
        {
            _isDragging = true;
            FrameworkElement sourceElement = _dragSource.SourceElement;

            sourceElement.PreviewDragEnter += _dragSource.PreviewDragEnterHandler;
            sourceElement.PreviewDragOver  += _dragSource.PreviewDragOverHandler;
            sourceElement.PreviewDragLeave += _dragSource.PreviewDragLeaveHandler;
            DragInitializeEventArgs args = new DragInitializeEventArgs
            {
                DragStartPosition = DragStartPosition
            };

            OnDragInitialize(source, args);
            if (args.Data != null)
            {
                DragDropEffects        effects           = System.Windows.DragDrop.DoDragDrop(source, args.Data, DragDropEffects.All);
                DropCompletedEventArgs dropCompletedArgs = new DropCompletedEventArgs(DragDrop.DropCompletedEvent, effects, args.Data);
                OnDropCompleted(source, dropCompletedArgs);
            }
            sourceElement.PreviewDragEnter -= _dragSource.PreviewDragEnterHandler;
            sourceElement.PreviewDragOver  -= _dragSource.PreviewDragOverHandler;
            sourceElement.PreviewDragLeave -= _dragSource.PreviewDragLeaveHandler;
            FinalizeDrag();
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            this.draggedImage = e.OriginalSource as Image ?? (e.OriginalSource as FrameworkElement).ParentOfType <Image>();

            if (this.draggedImage == null)
            {
                e.Cancel = true;
            }

            this.relativeStartPoint = e.RelativeStartPoint;
        }
Example #5
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            Control source    = sender as Control;
            Panel   context   = DragManager.DragContext;
            Point   dragStart = DragManager.DragStartPosition;

            e.Effects = DragDropEffects.All;
            Point mousePos = e.GetPosition(context);
            Point itemPos  = source.TranslatePoint(new Point(), source);
            Point offset   = new Point(mousePos.X - itemPos.X, mousePos.Y - itemPos.Y);

            e.DragVisualSize   = new Size(source.ActualWidth, source.ActualHeight);
            e.DragVisualOffset = offset;
            e.Data             = DragDataManager.GenerateDataObject(source);
        }
Example #6
0
 private static void OnDragInitialize(UIElement element, DragInitializeEventArgs e)
 {
     _dragSource.DragInitializeHandler?.Invoke(element, e);
 }