예제 #1
0
        private static void AnimateToPosition(DependencyObject d, Rect desiredPosition)
        {
            Rect position = ArrangePanel.GetPosition(d);

            if (double.IsNaN(position.X))
            {
                ArrangePanel.SetPosition(d, desiredPosition);
            }
            else
            {
                Vector vector  = desiredPosition.TopLeft - position.TopLeft;
                double length1 = vector.Length;
                vector = desiredPosition.BottomRight - position.BottomRight;
                double        length2        = vector.Length;
                TimeSpan      timeSpan       = TimeSpan.FromMilliseconds(Math.Max(length1, length2) * 1.0);
                RectAnimation rectAnimation1 = new RectAnimation(position, desiredPosition, new Duration(timeSpan));
                rectAnimation1.DecelerationRatio = 1.0;
                RectAnimation rectAnimation2 = rectAnimation1;
                if (!(d is UIElement uiElement))
                {
                    return;
                }
                uiElement.BeginAnimation(ArrangePanel.PositionProperty, (AnimationTimeline)rectAnimation2);
            }
        }
예제 #2
0
        private void DoReordering(MouseEventArgs e)
        {
            e.Handled = true;
            Point position = e.GetPosition((IInputElement)this);

            ArrangePanel.SetOrder((DependencyObject)this._draggingObject, this._strategy.GetIndex(position));
            ArrangePanel.SetPosition((DependencyObject)this._draggingObject, new Rect(position + this._delta, ArrangePanel.GetPosition((DependencyObject)this._draggingObject).Size));
        }
예제 #3
0
        private void StartReordering(MouseEventArgs e)
        {
            if (e == null || !(e.OriginalSource is UIElement originalSource))
            {
                return;
            }
            this._startPosition  = e.GetPosition((IInputElement)this);
            this._draggingObject = this.GetMyChildOfUiElement(originalSource);
            this._draggingObject.SetValue(Panel.ZIndexProperty, (object)100);
            Rect position = ArrangePanel.GetPosition((DependencyObject)this._draggingObject);

            this._delta = position.TopLeft - this._startPosition;
            this._draggingObject.BeginAnimation(ArrangePanel.PositionProperty, (AnimationTimeline)null);
            ArrangePanel.SetPosition((DependencyObject)this._draggingObject, position);
        }