Beispiel #1
0
        /// <summary>
        /// Moves the Target.
        /// </summary>
        /// <remarks>
        /// This method checks the constraints (MinLeft, MaxLeft, etc) before moving the Target,
        /// and raises related events if it is required.
        /// </remarks>
        /// <param name="deltaX">The X distance to move.</param>
        /// <param name="deltaY">The Y distance to move.</param>
        /// <returns>True if the Target is actually moved.</returns>
        public bool Move(double deltaX, double deltaY)
        {
            if (Target == null)
                return false;

            if (Target.IsLoaded == false)
                return false;

            var delta = new Vector(deltaX, deltaY);

            // Adjusts the delta not to exceed the defined min-max positions.
            AdjustDeltaForMinMaxPositions(ref delta);

            // Raises the Moving event.
            if (!RaiseMovingEvent(this, Target, ref delta))
                return false;

            // Moves the target element.
            bool isMoved = FrameworkElementHelper.Move(Target, delta);

            // Raises the Moved event.
            RaiseMovedEvent(this, Target, delta);

            return isMoved;
        }
Beispiel #2
0
        /// <summary>
        /// Adjusts not to exceed the defined min-max positions.
        /// </summary>
        private void AdjustForMinMaxPositions()
        {
            if (Target == null)
                return;

            if (Target.IsLoaded == false)
                return;

            // Gets the delta that is not exceed the defined min-max positions.
            Vector delta = new Vector();
            AdjustDeltaForMinMaxPositions(ref delta);

            // Applies the delta.
            FrameworkElementHelper.Move(Target, delta);
        }