Exemplo n.º 1
0
        public static void Detach(ResizingAdorner adorner)
        {
            Argument.IsNotNull(() => adorner);

            var adornerLayer = AdornerLayer.GetAdornerLayer(adorner.AdornedElement);

            if (adornerLayer == null)
            {
                return;
            }

            adornerLayer.Remove(adorner);

            adorner._visualChildren.Clear();

            if (adorner.AdornedElement is FrameworkElement fxElement)
            {
                fxElement.Loaded -= adorner.OnAdornedElementLoaded;
            }

            adorner._left.DragDelta        -= adorner.HandleLeft;
            adorner._topLeft.DragDelta     -= adorner.HandleTopLeft;
            adorner._top.DragDelta         -= adorner.HandleTop;
            adorner._topRight.DragDelta    -= adorner.HandleTopRight;
            adorner._right.DragDelta       -= adorner.HandleRight;
            adorner._bottomRight.DragDelta -= adorner.HandleBottomRight;
            adorner._bottom.DragDelta      -= adorner.HandleBottom;
            adorner._bottomLeft.DragDelta  -= adorner.HandleBottomLeft;
        }
Exemplo n.º 2
0
        private void RemoveAdorner()
        {
            if (_adorner is null || _adornerLayer is null)
            {
                return;
            }

            if (_adornerDragDrop != null)
            {
                ControlAdornerDragDrop.Detach(_adornerDragDrop);
                _adornerDragDrop = null;
            }

            if (_adornerResizing != null)
            {
                ResizingAdorner.Detach(_adornerResizing);
                _adornerResizing = null;
            }

            _adornerLayer.Remove(_adorner);
            _adorner.Child = null;
            _adorner       = null;
            _adornerLayer  = null;

            RegisterBeingMovedOut();
        }
Exemplo n.º 3
0
        public static ResizingAdorner Attach(FrameworkElement element)
        {
            Argument.IsNotNull(() => element);

            var adorner = new ResizingAdorner(element);

            if (adorner.AdornedElement is FrameworkElement fxElement)
            {
                fxElement.Loaded += adorner.OnAdornedElementLoaded;
            }

            adorner._left.DragDelta        += adorner.HandleLeft;
            adorner._topLeft.DragDelta     += adorner.HandleTopLeft;
            adorner._top.DragDelta         += adorner.HandleTop;
            adorner._topRight.DragDelta    += adorner.HandleTopRight;
            adorner._right.DragDelta       += adorner.HandleRight;
            adorner._bottomRight.DragDelta += adorner.HandleBottomRight;
            adorner._bottom.DragDelta      += adorner.HandleBottom;
            adorner._bottomLeft.DragDelta  += adorner.HandleBottomLeft;

            var adornerLayer = AdornerLayer.GetAdornerLayer(element);

            adornerLayer.Add(adorner);

            adorner.UpdateState();

            return(adorner);
        }
Exemplo n.º 4
0
 private void UpdateResizingAdorner()
 {
     if (IsOpen && (ResizeMode == ResizeMode.CanResize || ResizeMode == ResizeMode.CanResizeWithGrip))
     {
         if (_adornerResizing == null && _adorner != null)
         {
             _adornerResizing = ResizingAdorner.Attach(this);
         }
     }
     else
     {
         if (_adornerResizing != null)
         {
             ResizingAdorner.Detach(_adornerResizing);
             _adornerResizing = null;
         }
     }
 }