Inheritance: AdornerBase
Ejemplo n.º 1
0
        protected override void OnPreviewMouseMove(MouseEventArgs e)
        {
            base.OnPreviewMouseMove(e);
            if (!EnableSortByDragAndDrop)
            {
                return;
            }
            if (_targetContainer?.DataContext == null)
            {
                return;
            }

            var listBoxItem = _targetContainer as ListBoxItem;

            if (listBoxItem != null && !listBoxItem.IsSelected)
            {
                return;
            }

            // 移動量が十分か検証する
            var currentPosition = PointToScreen(e.GetPosition(_targetContainer));
            var delta           = (_startPosition - currentPosition);

            if (!delta.IsEnoughMoveForDrug())
            {
                return;
            }

            //Debug.WriteLine("DragDropStart");

            _dragAdorner = _dragAdorner ?? (_dragAdorner = DragAdorner.Create(this, _targetContainer, _startPosition));

            _dragAdorner.SetOffset(currentPosition.X, currentPosition.Y);

            DragDrop.DoDragDrop(this, _targetContainer.DataContext, DragDropEffects.Move);

            // 終わったら後始末
            ResetDragAndDropParameter();
        }
Ejemplo n.º 2
0
        private void ResetDragAndDropParameter()
        {
            //Debug.WriteLine("ResetParameter");

            _targetContainer = null;
            _startPosition = new Point();

            _dragAdorner?.Dispose();
            _dragAdorner = null;

            _insertionAdorner?.Dispose();
            _insertionAdorner = null;
        }
Ejemplo n.º 3
0
        protected override void OnPreviewMouseMove(MouseEventArgs e)
        {
            base.OnPreviewMouseMove(e);
            if (!EnableSortByDragAndDrop) return;
            if (_targetContainer?.DataContext == null) return;

            var listBoxItem = _targetContainer as ListBoxItem;
            if (listBoxItem != null && !listBoxItem.IsSelected)
                return;

            // 移動量が十分か検証する
            var currentPosition = PointToScreen(e.GetPosition(_targetContainer));
            var delta = (_startPosition - currentPosition);
            if (!delta.IsEnoughMoveForDrug()) return;

            //Debug.WriteLine("DragDropStart");

            _dragAdorner = _dragAdorner ?? (_dragAdorner = DragAdorner.Create(this, _targetContainer, _startPosition));

            _dragAdorner.SetOffset(currentPosition.X, currentPosition.Y);

            DragDrop.DoDragDrop(this, _targetContainer.DataContext, DragDropEffects.Move);

            // 終わったら後始末
            ResetDragAndDropParameter();
        }