Example #1
0
        /// <summary>
        /// Shows adorners over the selected element
        /// </summary>
        private void activateAdorners(object sender, MouseEventArgs e)
        {
            if (_isDragging)
            {
                return;
            }

            clearAdorners();

            var border = sender as Border;

            if (border == null)
            {
                return;
            }

            var adornerLayers = AdornerLayer.GetAdornerLayer(border);
            var adorner       = new SimpleAdorner(border);

            adorner.dragStarted    += onDragStarted;
            adorner.centerDragging += onCenterAdornerDragging;
            adorner.edgeDragging   += onEdgeAdornerDragging;
            adorner.dragCompleted  += onDragCompleted;

            adornerLayers?.Add(adorner);
        }
Example #2
0
        /// <summary>
        /// Initiates a drag and drop session.
        /// </summary>
        private void DragStarted()
        {
            _isDragging = true;

            _dragAdornment = new SimpleAdorner(_dragElement);
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(_dragElement);

            layer.Add(_dragAdornment);
        }
Example #3
0
        /// <summary>
        /// Initiates a drag and drop session.
        /// </summary>
        private void DragStarted()
        {
            _isDragging = true;

            _dragAdornment = new SimpleAdorner(_dragElement);
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(_dragElement);
            layer.Add(_dragAdornment);
        }
Example #4
0
        /// <summary>
        /// Completes a drag and drop either cancelling it or committing it.
        /// </summary>
        private void DragFinished(bool cancelled, Point? dropPoint)
        {
            Mouse.Capture(null);
            if (_isDragging) {
                AdornerLayer.GetAdornerLayer(_dragAdornment.AdornedElement).Remove(_dragAdornment);

                if (cancelled == false) {
                    if (_dropAction != null) {
                        _dropAction(dropPoint.Value);
                        _dropAction = null;
                    }
                    //Canvas.SetTop(_dragElement, _dragTop + _overlayElement.TopOffset);
                    //Canvas.SetLeft(_dragElement, _dragLeft + _overlayElement.LeftOffset);
                    // commit result
                }
                _dragAdornment = null;

            }
            _isDragging = false;
            _isMouseDown = false;
        }