Exemplo n.º 1
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.º 2
0
        public static ControlAdornerDragDrop Attach(ControlAdorner adorner, UIElement element)
        {
            if (adorner?.Child is null)
            {
                return(null);
            }

            var dd = new ControlAdornerDragDrop
            {
                _adorner = adorner,
                _element = element
            };

            dd._adorner.Child.MouseLeftButtonDown += dd.MouseLeftButtonDown;
            dd._adorner.Child.MouseLeftButtonUp   += dd.MouseLeftButtonUp;
            dd._adorner.Child.MouseMove           += dd.MouseMove;

            // Important: the initial check should position it correctly,
            // see https://github.com/WildGums/Orc.Controls/issues/40

            var frameworkElement = (FrameworkElement)element;

            //Debug.WriteLine($"Adorner child: X = '{childPosition.X}', Y = '{childPosition.Y}'");
            //Debug.WriteLine($"Adorned element: Width = '{adornedElement.ActualWidth}', Height = '{adornedElement.ActualHeight}'");
            //Debug.WriteLine($"Initial X = '{initialX}', Y = '{initialY}'");

            dd.UpdatePosition(frameworkElement, new Point(0, 0), true);

            return(dd);
        }
Exemplo n.º 3
0
        private void CreateAdorner()
        {
            if (_adorner != null || (Application.Current.MainWindow is null && _userDefinedAdorner is null))
            {
                return;
            }

            var adornedElement = GetAdornerElement();

            if (adornedElement is null)
            {
                return;
            }

            var layer = AdornerLayer.GetAdornerLayer(adornedElement);

            if (layer is null)
            {
                return;
            }

            _isPositionCalculated = false;

            var ad = new ControlAdorner(adornedElement)
            {
                Child     = this,
                Focusable = false
            };

            KeyboardNavigation.SetTabNavigation(ad, KeyboardNavigationMode.None);
            layer.Add(ad);

            BringFluentRibbonBackstageToFront(layer, adornedElement);

            _adorner      = ad;
            _adornerLayer = layer;

            if (IsPinned && _adornerDragDrop is null)
            {
                _adornerDragDrop = ControlAdornerDragDrop.Attach(_adorner, _dragGrip);
            }

            RegisterBeingInFront();
        }
Exemplo n.º 4
0
        public static ControlAdornerDragDrop Attach(ControlAdorner adorner, UIElement element)
        {
            if (adorner == null || adorner.Child == null)
            {
                return null;
            }

            var dd = new ControlAdornerDragDrop
            {
                _adorner = adorner,
                _element = element
            };

            dd._adorner.Child.MouseLeftButtonDown += dd.MouseLeftButtonDown;
            dd._adorner.Child.MouseLeftButtonUp += dd.MouseLeftButtonUp;
            dd._adorner.Child.MouseMove += dd.MouseMove;

            return dd;
        }
        public static ControlAdornerDragDrop Attach(ControlAdorner adorner, UIElement element)
        {
            if (adorner == null || adorner.Child == null)
            {
                return(null);
            }

            var dd = new ControlAdornerDragDrop
            {
                _adorner = adorner,
                _element = element
            };

            dd._adorner.Child.MouseLeftButtonDown += dd.MouseLeftButtonDown;
            dd._adorner.Child.MouseLeftButtonUp   += dd.MouseLeftButtonUp;
            dd._adorner.Child.MouseMove           += dd.MouseMove;

            return(dd);
        }
Exemplo n.º 6
0
        private void RemoveAdorner()
        {
            if (_adorner == null || _adornerLayer == null)
            {
                return;
            }

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

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

            RegisterBeingMovedOut();
        }
Exemplo n.º 7
0
        private void CreateAdorner()
        {
            if (_adorner != null || (Application.Current.MainWindow == null && _userDefinedAdorner == null))
            {
                return;
            }

            var adornedElement = GetAdornerElement();
            if (adornedElement == null)
            {
                return;
            }

            var layer = AdornerLayer.GetAdornerLayer(adornedElement);
            if (layer == null)
            {
                return;
            }

            _isPositionCalculated = false;
            var ad = new ControlAdorner(adornedElement) { Child = this, Focusable = false };
            KeyboardNavigation.SetTabNavigation(ad, KeyboardNavigationMode.None);
            layer.Add(ad);
            _adorner = ad;
            _adornerLayer = layer;

            if (IsPinned && _adornerDragDrop == null)
            {
                _adornerDragDrop = ControlAdornerDragDrop.Attach(_adorner, _dragGrip);
            }

            RegisterBeingInFront();
        }