Ejemplo n.º 1
0
 /// <summary>
 /// PreviewMouseLeftButtonUp イベントハンドラ
 /// </summary>
 /// <param name="sender">イベント発行元</param>
 /// <param name="e">イベント引数</param>
 static void element_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (_adorner != null)
     {
         _adorner.AdornedElement.ReleaseMouseCapture();
         _adorner.Detach();
         _adorner = null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// PreviewMouseLeftButtonDown イベントハンドラ
        /// </summary>
        /// <param name="sender">イベント発行元</param>
        /// <param name="e">イベント引数</param>
        static void element_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var originalElement = e.OriginalSource as FrameworkElement;
            var parent          = originalElement != null?FindAncestor <Panel>(originalElement) : null;

            var adornedElement = sender as FrameworkElement;

            if ((parent == null) || (adornedElement == null))
            {
                return;
            }

            var pt     = e.GetPosition(adornedElement);
            var offset = new Point(-pt.X, -pt.Y);

            _adorner = new GhostAdorner(parent, adornedElement, pt, offset);

            adornedElement.CaptureMouse();
        }