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)); }
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)); }
/// <summary> /// Inputs a new step increment. /// </summary> /// <param name="x1">The abscissa where the step function changes</param> /// <param name="dy1">The step increment</param> /// <param name="smin">The minimal slope modulus</param> /// <remarks> /// Updates the slope and the bounding value of the the extrapolated linear function. /// </remarks> public void NewInputDelta(double x1, double dy1, double smin) { if (DoubleEx.IsZero(dy1)) { throw new ArgumentNullException("dy1"); } double sm; if (double.IsNaN(_x)) { sm = smin; _ymax = dy1; } else { var dx1 = x1 - _x; var y1 = CoerceY(_se * dx1); sm = Math.Max(smin, Math.Abs(_ymax / dx1)); _ymax += dy1 - y1; // sub-sampling correction _dyc += y1 - _ys; _ys = 0; //Debug.WriteLine(string.Format("dx={0,7:F2}[ms], dy1={1,7:F2}, y1={2,7:F2}, ymax={3,7:F2}, slope={4,7:F2}", dx1 * 1000, dy1, y1, _ymax, _se)); } _se = sm * Math.Sign(_ymax); _x = x1; }
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)); }
public static double GetScrollableDisplacement(this ScrollViewer self, Orientation orientation, int direction) { if (orientation == Orientation.Vertical) { if (!DoubleEx.IsZero(self.ScrollableHeight)) { if (direction < 0) { return(-self.VerticalOffset); } else { return(self.ExtentHeight - self.ViewportHeight - self.VerticalOffset); } } } else if (!DoubleEx.IsZero(self.ScrollableWidth)) { if (direction < 0) { return(-self.HorizontalOffset); } else { return(self.ExtentWidth - self.ViewportWidth - self.HorizontalOffset); } } return(0); }
public void Move(IMotionInfo info, object context, double delta) { var sinkDelta = NormalizedToSink(delta); if (DoubleEx.IsZero(sinkDelta)) { return; } Client.Move(info, context, sinkDelta); }
public double Coerce(IMotionInfo info, object context, double delta) { var sinkDelta = NormalizedToSink(delta); if (DoubleEx.IsZero(sinkDelta)) { return(0); } var sinkCoerced = Client.Coerce(info, context, CoerceSinkDelta(sinkDelta)); if (DoubleEx.IsZero(sinkCoerced)) { return(0); } return(SinkToNormalized(sinkCoerced)); }
private void OnRendering(object sender, EventArgs e) { var t = TimeBase.Current.Elapsed; double delta = _remainder + _filter.NextOutputDelta(t); if (DoubleEx.GreaterThanOrClose(Math.Abs(delta), Precision)) { _remainder = 0; Next.Move(null, null, delta); } else if (DoubleEx.IsZero(delta)) { CompositionTarget.Rendering -= OnRendering; } else { _remainder += delta; } }
public bool Transfer(INativeMotionTarget target, object context) { if (target == null) { throw new ArgumentNullException("target"); } RaiseEvent(new NativeMotionTransferEventArgs(_info, _nativeSourceDelta) { RoutedEvent = TransferingEvent }); if (Math.Sign(_nativeSourceDelta) == _info.NativeDirection) { var converter = _info.Source as INativeMotionConverter; int nativeTargetDelta = target.Coerce(_info, context, _nativeSourceDelta); if (!DoubleEx.IsZero(nativeTargetDelta)) { target.Move(_info, context, nativeTargetDelta); EndTransfer(nativeTargetDelta, converter.NativeResolutionFrequency); } } return(target.CanMove(_info, context)); }
public bool Transfer(INativeMotionTarget 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 nativeTargetDelta = target.Coerce(MotionInfo, context, NativeRemainder); if (!DoubleEx.IsZero(nativeTargetDelta)) { target.Move(MotionInfo, context, nativeTargetDelta); EndTransfer(nativeTargetDelta, converter.NativeResolutionFrequency); } } return(target.CanMove(MotionInfo, context)); }
public override bool CanMove(IMotionInfo info, object context) { return(!DoubleEx.IsZero(GetScrollableDisplacement(info.Direction))); }
public double X(double y) { return(DoubleEx.IsZero(this.Slope) ? double.NaN : (y - this.YIntercept) / this.Slope); }
public double X(double y) { return DoubleEx.IsZero(Slope) ? double.NaN : (y - YIntercept)/Slope; }
public virtual bool CanMove(IMotionInfo info, object context) { return(!DoubleEx.IsZero(Coerce(info, context, info.Direction))); }