internal void HandleDrag(Point newPositionInElementCoordinates)
        {
            double           x         = newPositionInElementCoordinates.X - this.relativePosition.X;
            double           y         = newPositionInElementCoordinates.Y - this.relativePosition.Y;
            GeneralTransform transform = base.AssociatedObject.TransformToVisual(this.RootElement);
            Point            point     = MouseDragElementBehavior.TransformAsVector(transform, x, y);

            this.settingPosition = true;
            this.ApplyTranslation(point.X, point.Y);
            this.UpdatePosition();
            this.settingPosition = false;
        }
 private void ApplyTranslation(double x, double y)
 {
     if (this.ParentElement != null)
     {
         GeneralTransform transform = this.RootElement.TransformToVisual(this.ParentElement);
         Point            point     = MouseDragElementBehavior.TransformAsVector(transform, x, y);
         x = point.X;
         y = point.Y;
         if (this.ConstrainToParentBounds)
         {
             FrameworkElement parentElement    = this.ParentElement;
             Rect             rect             = new Rect(0.0, 0.0, parentElement.ActualWidth, parentElement.ActualHeight);
             GeneralTransform generalTransform = base.AssociatedObject.TransformToVisual(parentElement);
             Rect             rect2            = this.ElementBounds;
             rect2 = generalTransform.TransformBounds(rect2);
             Rect rect3 = rect2;
             rect3.X += x;
             rect3.Y += y;
             if (!MouseDragElementBehavior.RectContainsRect(rect, rect3))
             {
                 if (rect3.X < rect.Left)
                 {
                     double num = rect3.X - rect.Left;
                     x -= num;
                 }
                 else
                 {
                     if (rect3.Right > rect.Right)
                     {
                         double num2 = rect3.Right - rect.Right;
                         x -= num2;
                     }
                 }
                 if (rect3.Y < rect.Top)
                 {
                     double num3 = rect3.Y - rect.Top;
                     y -= num3;
                 }
                 else
                 {
                     if (rect3.Bottom > rect.Bottom)
                     {
                         double num4 = rect3.Bottom - rect.Bottom;
                         y -= num4;
                     }
                 }
             }
         }
         this.ApplyTranslationTransform(x, y);
     }
 }