Ejemplo n.º 1
0
        public bool Transfer(IMotionTarget target, object context)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            this.RaiseEvent(new MotionTransferEventArgs(this._info, this._sourceDelta)
            {
                RoutedEvent = TransferingEvent
            });

            if (Math.Sign(this._sourceDelta) == this._info.Direction)
            {
                var    converter   = this._info.Source as INativeMotionConverter;
                double targetDelta = target.Coerce(this._info, context, this._sourceDelta);
                if (!DoubleEx.IsZero(targetDelta))
                {
                    target.Move(this._info, context, targetDelta);
                    this._sourceDelta -= targetDelta;
                    this.RaiseEvent(new MotionTransferEventArgs(this._info, targetDelta)
                    {
                        RoutedEvent = TransferedEvent
                    });
                }
            }

            return(target.CanMove(this._info, context));
        }
Ejemplo n.º 2
0
        public bool Transfer(IMotionTarget target, object context)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            this.RaiseEvent(new NativeMotionTransferEventArgs(this._info, this._nativeSourceDelta)
            {
                RoutedEvent = TransferingEvent
            });

            if (Math.Sign(this._nativeSourceDelta) == this._info.NativeDirection)
            {
                var    converter   = this._info.Source as INativeMotionConverter;
                double sourceDelta = converter.NativeToNormalized(this._nativeSourceDelta);
                double targetDelta = target.Coerce(this._info, context, sourceDelta);
                if (!DoubleEx.IsZero(targetDelta))
                {
                    target.Move(this._info, context, targetDelta);
                    this.EndTransfer(converter.NormalizedToNative(targetDelta), converter.NativeResolutionFrequency);
                }
            }

            return(target.CanMove(this._info, context));
        }
Ejemplo n.º 3
0
        public bool Transfer(IMotionTarget target, object context)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            RaiseEvent(new MotionTransferEventArgs(MotionInfo, Remainder)
            {
                RoutedEvent = TransferingEvent
            });

            if (Math.Sign(Remainder) == MotionInfo.Direction)
            {
                var targetDelta = target.Coerce(MotionInfo, context, Remainder);
                if (!DoubleEx.IsZero(targetDelta))
                {
                    target.Move(MotionInfo, context, targetDelta);
                    Remainder -= targetDelta;
                    RaiseEvent(new MotionTransferEventArgs(MotionInfo, targetDelta)
                    {
                        RoutedEvent = TransferedEvent
                    });
                }
            }
            return(target.CanMove(MotionInfo, context));
        }
Ejemplo n.º 4
0
        public bool Transfer(IMotionTarget target, object context)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            RaiseEvent(new NativeMotionTransferEventArgs(MotionInfo, NativeRemainder)
            {
                RoutedEvent = TransferingEvent
            });

            if (Math.Sign(NativeRemainder) == MotionInfo.NativeDirection)
            {
                var converter   = (INativeMotionConverter)MotionInfo.Source;
                var sourceDelta = converter.NativeToNormalized(NativeRemainder);
                var targetDelta = target.Coerce(MotionInfo, context, sourceDelta);
                if (!DoubleEx.IsZero(targetDelta))
                {
                    target.Move(MotionInfo, context, targetDelta);
                    EndTransfer(converter.NormalizedToNative(targetDelta), converter.NativeResolutionFrequency);
                }
            }
            return(target.CanMove(MotionInfo, context));
        }