Ejemplo n.º 1
0
        /// <summary>
        /// The detach.
        /// </summary>
        /// <param name="dd">
        /// The dd.
        /// </param>
        public static void Detach(ControlAdornerDragDrop dd)
        {
            if (dd == null || dd.adorner == null || dd.adorner.Child == null)
            {
                return;
            }

            dd.adorner.Child.MouseLeftButtonDown -= dd.MouseLeftButtonDown;
            dd.adorner.Child.MouseLeftButtonUp -= dd.MouseLeftButtonUp;
            dd.adorner.Child.MouseMove -= dd.MouseMove;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The attach.
        /// </summary>
        /// <param name="adorner">
        /// The adorner.
        /// </param>
        /// <returns>
        /// The <see cref="ControlAdornerDragDrop"/>.
        /// </returns>
        public static ControlAdornerDragDrop Attach(ControlAdorner adorner)
        {
            if (adorner == null || adorner.Child == null)
            {
                return null;
            }

            var dd = new ControlAdornerDragDrop { adorner = adorner };
            dd.adorner.Child.MouseLeftButtonDown += dd.MouseLeftButtonDown;
            dd.adorner.Child.MouseLeftButtonUp += dd.MouseLeftButtonUp;
            dd.adorner.Child.MouseMove += dd.MouseMove;
            return dd;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     The create adorner.
        /// </summary>
        private void CreateAdorner()
        {
            if (this.adorner != null || (Application.Current.MainWindow == null && this.userDefinedAdorner == null))
            {
                return;
            }

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

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

            this.isPositionCalculated = false;
            var ad = new ControlAdorner(adornedElement) { Child = this, Focusable = false };
            KeyboardNavigation.SetTabNavigation(ad, KeyboardNavigationMode.None);
            layer.Add(ad);
            this.adorner = ad;
            this.adornerLayer = layer;

            if (this.IsPinned && this.adornerDragDrop == null)
            {
                this.adornerDragDrop = ControlAdornerDragDrop.Attach(this.adorner);
            }

            this.RegisterBeingInFront();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     The remove adorner.
        /// </summary>
        private void RemoveAdorner()
        {
            if (this.adorner == null || this.adornerLayer == null)
            {
                return;
            }

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

            this.adornerLayer.Remove(this.adorner);
            this.adorner.Child = null;
            this.adorner = null;
            this.adornerLayer = null;

            this.RegisterBeingMovedOut();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Brings pinned toooltip to front.
        /// </summary>
        public void BringToFront()
        {
            if (this.IsInFront())
            {
                return;
            }

            if (this.IsPinned && this.adorner != null)
            {
                if (this.adornerDragDrop != null)
                {
                    ControlAdornerDragDrop.Detach(this.adornerDragDrop);
                    this.adornerDragDrop = null;
                }

                this.adornerLayer.Remove(this.adorner);

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

                this.adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
                if (this.adornerLayer == null)
                {
                    return;
                }

                this.adornerLayer.Add(this.adorner);

                if (this.IsPinned && this.adornerDragDrop == null)
                {
                    this.adornerDragDrop = ControlAdornerDragDrop.Attach(this.adorner);
                }

                this.RegisterBeingInFront();
            }
        }