/// <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; }
/// <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); }
/// <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(); }
/// <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(); }