/// <summary> /// The play method /// </summary> /// <param name="o"> /// The object. /// </param> /// <param name="propertySetter"> /// The property setter expression /// </param> /// <param name="endCallback"> /// The end callback /// </param> /// <typeparam name="T"> /// Any object /// </typeparam> // ReSharper disable once UnusedMember.Global public void Play <T>(T o, Expression <Func <T, object> > propertySetter, SafeInvoker endCallback = null) { if (propertySetter == null) { return; } this.underlyingObject = o; MemberExpression expr; if (propertySetter.Body is MemberExpression) { expr = (MemberExpression)propertySetter.Body; } else { expr = (MemberExpression)((UnaryExpression)propertySetter.Body).Operand; } PropertyInfo prop = (PropertyInfo)expr.Member; this.Play( new SafeInvoker( (float value) => prop.SetValue(this.underlyingObject, Convert.ChangeType(value, prop.PropertyType), null), this.underlyingObject), endCallback); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="frameCallback"> /// The callback to get invoked at each frame /// </param> /// <param name="endCallback"> /// The callback to get invoked at the end of the animation /// </param> public void Play(SafeInvoker <Float3D> frameCallback, SafeInvoker endCallback) { Stop(); FrameCallback = frameCallback; EndCallback = endCallback; IsEnded = false; HorizontalAnimator.Play( new SafeInvoker <float>( value => { XValue = value; InvokeSetter(); }), new SafeInvoker(InvokeFinisher)); VerticalAnimator.Play( new SafeInvoker <float>( value => { YValue = value; InvokeSetter(); }), new SafeInvoker(InvokeFinisher)); DepthAnimator.Play( new SafeInvoker <float>( value => { ZValue = value; InvokeSetter(); }), new SafeInvoker(InvokeFinisher)); }
/// <summary> /// The play method /// </summary> /// <param name="frameCallback"> /// The frame callback. /// </param> /// <param name="endCallback"> /// The end callback. /// </param> public void Play(SafeInvoker frameCallback, SafeInvoker endCallback = null) { this.Stop(); this.frameInvoker = frameCallback; this.endInvoker = endCallback; this.ended = false; this.XAxisAnimator.Play( new SafeInvoker( value => { this.x = value; this.InvokeSetter(); }), new SafeInvoker(this.InvokeFinisher)); this.YAxisAnimator.Play( new SafeInvoker( value => { this.y = value; this.InvokeSetter(); }), new SafeInvoker(this.InvokeFinisher)); this.ZAxisAnimator.Play( new SafeInvoker( value => { this.z = value; this.InvokeSetter(); }), new SafeInvoker(this.InvokeFinisher)); }
/// <summary> /// The play method /// </summary> /// <param name="frameCallback"> /// The frame callback. /// </param> /// <param name="endCallback"> /// The end callback. /// </param> public void Play(SafeInvoker frameCallback, SafeInvoker endCallback = null) { this.Stop(); this.frameInvoker = frameCallback; this.endInvoker = endCallback; this.timer.ResetClock(); this.CurrentStatus = Status.Playing; lock (this.tempPaths) this.tempPaths.AddRange(this.paths); this.timer.Start(); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="frameCallback"> /// The callback to get invoked at each frame /// </param> /// <param name="endCallback"> /// The callback to get invoked at the end of the animation /// </param> public virtual void Play(SafeInvoker <float> frameCallback, SafeInvoker endCallback) { Stop(); FrameCallback = frameCallback; EndCallback = endCallback; _timer.ResetClock(); lock (_tempPaths) { _tempPaths.AddRange(_paths); } _timer.Start(); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="targetObject"> /// The target object to change the property /// </param> /// <param name="propertyName"> /// The name of the property to change /// </param> /// <param name="endCallback"> /// The callback to get invoked at the end of the animation /// </param> public virtual void Play(object targetObject, string propertyName, SafeInvoker endCallback) { TargetObject = targetObject; var prop = TargetObject.GetType() .GetProperty( propertyName, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty); if (prop == null) { return; } Play( new SafeInvoker <float>( value => prop.SetValue(TargetObject, Convert.ChangeType(value, prop.PropertyType), null), TargetObject), endCallback); }
/// <summary> /// The play method /// </summary> /// <param name="o"> /// The object /// </param> /// <param name="propertyName"> /// The property name /// </param> /// <param name="endCallback"> /// The end callback /// </param> /// <typeparam name="T"> /// Any object /// </typeparam> public void Play <T>(T o, string propertyName, SafeInvoker endCallback = null) { this.underlyingObject = o; PropertyInfo prop = this.underlyingObject.GetType() .GetProperty( propertyName, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty); if (prop == null) { return; } this.Play( new SafeInvoker( (float value) => prop.SetValue(this.underlyingObject, Convert.ChangeType(value, prop.PropertyType), null), this.underlyingObject), endCallback); }
/// <summary> /// The play method /// </summary> /// <param name="frameCallback"> /// The frame callback. /// </param> /// <param name="endCallback"> /// The end callback. /// </param> public void Play(SafeInvoker frameCallback, SafeInvoker endCallback = null) { this.Stop(); this.frameInvoker = frameCallback; this.endInvoker = endCallback; this.HorizontalAnimator.Play( new SafeInvoker( value => { this.x = value; this.InvokeSetter(); }), new SafeInvoker(this.InvokeFinisher)); this.VerticalAnimator.Play( new SafeInvoker( value => { this.y = value; this.InvokeSetter(); }), new SafeInvoker(this.InvokeFinisher)); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="frameCallback"> /// The callback to get invoked at each frame /// </param> public void Play(SafeInvoker <Float3D> frameCallback) { Play(frameCallback, (SafeInvoker)null); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="targetObject"> /// The target object to change the property /// </param> /// <param name="property"> /// The property to change /// </param> /// <param name="endCallback"> /// The callback to get invoked at the end of the animation /// </param> public void Play(object targetObject, KnownProperties property, SafeInvoker endCallback) { Play(targetObject, property.ToString(), endCallback); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="targetObject"> /// The target object to change the property /// </param> /// <param name="propertySetter"> /// The expression that represents the property of the target object /// </param> /// <param name="endCallback"> /// The callback to get invoked at the end of the animation /// </param> /// <typeparam name="T"> /// Any object containing a property /// </typeparam> public virtual void Play <T>(T targetObject, Expression <Func <T, object> > propertySetter, SafeInvoker endCallback) { if (propertySetter == null) { return; } TargetObject = targetObject; var property = ((propertySetter.Body as MemberExpression) ?? (((UnaryExpression)propertySetter.Body).Operand as MemberExpression))?.Member as PropertyInfo; if (property == null) { throw new ArgumentException(nameof(propertySetter)); } Play( new SafeInvoker <Float3D>( value => property.SetValue(TargetObject, Convert.ChangeType(value, property.PropertyType), null), TargetObject), endCallback); }
/// <summary> /// Starts the playing of the animation /// </summary> /// <param name="frameCallback"> /// The callback to get invoked at each frame /// </param> public virtual void Play(SafeInvoker <float> frameCallback) { Play(frameCallback, (SafeInvoker <float>)null); }
/// <summary> /// The play method /// </summary> /// <param name="o"> /// The object /// </param> /// <param name="property"> /// The property of object /// </param> /// <param name="endCallback"> /// The end callback /// </param> /// <typeparam name="T"> /// Any object /// </typeparam> public void Play <T>(T o, KnownProperties property, SafeInvoker endCallback = null) { this.Play(o, property.ToString(), endCallback); }