public static Task StartScaleAnimationAsync(this Visual visual, AnimationAxis axis, float?from = null, float to = 0, double duration = 800, int delay = 0, CompositionEasingFunction easing = null, AnimationIterationBehavior iterationBehavior = AnimationIterationBehavior.Count) { CompositionScopedBatch batch; var compositor = visual.Compositor; var taskSource = new TaskCompletionSource <bool>(); void Completed(object o, CompositionBatchCompletedEventArgs e) { batch.Completed -= Completed; taskSource.SetResult(true); } batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); batch.Completed += Completed; visual.StartAnimation($"Scale.{axis}", compositor.CreateScalarKeyFrameAnimation(from, to, duration, delay, easing, iterationBehavior)); batch.End(); return(taskSource.Task); }
public async static Task StartOffsetAnimation(this UIElement element, AnimationAxis axis, float to = 0, double duration = 800, int delay = 0, CompositionEasingFunction easing = null, Action completed = null) { CompositionScopedBatch batch = null; var visual = element.Visual(); var compositor = visual.Compositor; if (completed != null) { batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); batch.Completed += (s, e) => completed(); } if (delay > 0) { await Task.Delay(delay); } visual.StartAnimation($"Offset.{axis.ToString()}", compositor.CreateScalarKeyFrameAnimation(to, duration, easing)); if (batch != null) { batch.End(); } }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { this.ComponentInfoName = "Rhino.xml"; base.LoadContent(); #region Controlador de animación m_BOLTER = (AnimationAxis)this.GetAnimation(_BOLTER); m_BOLTER_BASE = this.GetAnimation(_BOLTER_BASE); m_BOLTER_HATCH = (AnimationAxis)this.GetAnimation(_BOLTER_HATCH); m_DRIVER_HATCH = (AnimationAxis)this.GetAnimation(_DRIVER_HATCH); m_RIGHT_DOOR = (AnimationAxis)this.GetAnimation(_RIGHT_DOOR); m_LEFT_DOOR = (AnimationAxis)this.GetAnimation(_LEFT_DOOR); m_RIGHT_HATCH = (AnimationAxis)this.GetAnimation(_RIGHT_HATCH); m_LEFT_HATCH = (AnimationAxis)this.GetAnimation(_LEFT_HATCH); m_BACK_DOOR = (AnimationAxis)this.GetAnimation(_BACK_DOOR); #endregion #region Controladores de posición m_DRIVER_POSITION = this.GetPlayerPosition(_DRIVER_POSITION); m_GUNNER_POSITION = this.GetPlayerPosition(_GUNNER_POSITION); m_GUNNER_COVERED_POSITION = this.GetPlayerPosition(_GUNNER_COVERED_POSITION); #endregion this.SetPlayerPosition(Player.Bolter); }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { base.LoadContent(); #region Controlador de animación m_HeavyBolter = (AnimationAxis)this.GetAnimation(_HeavyBolter); m_HeavyBolterBase = (AnimationAxis)this.GetAnimation(_HeavyBolterBase); m_LeftLassCannon = (AnimationAxis)this.GetAnimation(_LeftLassCannon); m_LeftLassCannonBase = (AnimationAxis)this.GetAnimation(_LeftLassCannonBase); m_RightLassCannon = (AnimationAxis)this.GetAnimation(_RightLassCannon); m_RightLassCannonBase = (AnimationAxis)this.GetAnimation(_RightLassCannonBase); m_UpperFrontDoor = (AnimationAxis)this.GetAnimation(_UpperFrontDoor); m_LowerFrontDoor = (AnimationAxis)this.GetAnimation(_LowerFrontDoor); m_Driver = (AnimationAxis)this.GetAnimation(_Driver); m_DriverBase = (AnimationAxis)this.GetAnimation(_DriverBase); m_Commander = (AnimationAxis)this.GetAnimation(_Commander); m_CommanderBase = (AnimationAxis)this.GetAnimation(_CommanderBase); #endregion #region Controladores de posición m_DriverPosition = this.GetPlayerControl(_DriverPosition); m_CommanderPosition = this.GetPlayerControl(_CommanderPosition); m_TwinLinkedHeavyBolterGunner = this.GetPlayerControl(_TwinLinkedHeavyBolterGunner); m_LeftLaserCannonGunner = this.GetPlayerControl(_LeftLaserCannonGunner); m_RightLaserCannonGunner = this.GetPlayerControl(_RightLaserCannonGunner); #endregion #region Armamento this.m_TwinLinkedHeavyBolter = this.GetWeapon(_TwinLinkedHeavyBolter); this.m_LeftTwinLinkedLaserCannon = this.GetWeapon(_LeftTwinLinkedLaserCannon); this.m_RightTwinLinkedLaserCannon = this.GetWeapon(_RightTwinLinkedLaserCannon); #endregion #region Emisores this.m_LeftEngine = this.GetParticleEmitter(_LeftEngine); this.m_RightEngine = this.GetParticleEmitter(_RightEngine); this.m_LeftCaterpillar = this.GetParticleEmitter(_LeftCaterpillar); this.m_RightCaterpillar = this.GetParticleEmitter(_RightCaterpillar); #endregion this.SetPlaterControl(this.m_DriverPosition); }
public static void FillAnimation(this ManipulationCompletedRoutedEventArgs e, double fullDimension, Action forward, Action backward, AnimationAxis orientation = AnimationAxis.Y, double ratio = 0.5) { var translation = e.Cumulative.Translation; var distance = orientation == AnimationAxis.X ? translation.X : translation.Y; if (distance >= fullDimension * ratio) { forward(); } else { backward(); } }
public static void StartScaleAnimation(this Visual visual, AnimationAxis axis, float?from = null, float to = 0, double duration = 800, int delay = 0, CompositionEasingFunction easing = null, Action completed = null, AnimationIterationBehavior iterationBehavior = AnimationIterationBehavior.Count) { CompositionScopedBatch batch = null; var compositor = visual.Compositor; if (completed != null) { batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); batch.Completed += (s, e) => completed(); } visual.StartAnimation($"Scale.{axis}", compositor.CreateScalarKeyFrameAnimation(from, to, duration, delay, easing, iterationBehavior)); batch?.End(); }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { base.LoadContent(); #region Controlador de animación m_DRIVER_OUT = (AnimationAxis)this.GetAnimation(_DRIVER_OUT); m_DRIVER_OUT_BASE = (AnimationAxis)this.GetAnimation(_DRIVER_OUT_BASE); m_BOLTER = (AnimationAxis)this.GetAnimation(_BOLTER); m_BOLTER_BASE = this.GetAnimation(_BOLTER_BASE); m_BOLTER_HATCH = (AnimationAxis)this.GetAnimation(_BOLTER_HATCH); m_DRIVER_HATCH = (AnimationAxis)this.GetAnimation(_DRIVER_HATCH); m_RIGHT_DOOR = (AnimationAxis)this.GetAnimation(_RIGHT_DOOR); m_LEFT_DOOR = (AnimationAxis)this.GetAnimation(_LEFT_DOOR); m_RIGHT_HATCH = (AnimationAxis)this.GetAnimation(_RIGHT_HATCH); m_LEFT_HATCH = (AnimationAxis)this.GetAnimation(_LEFT_HATCH); m_BACK_DOOR = (AnimationAxis)this.GetAnimation(_BACK_DOOR); #endregion #region Controladores de posición m_DRIVER_POSITION_IN = this.GetPlayerControl(_DRIVER_POSITION_IN); m_DRIVER_POSITION_OUT = this.GetPlayerControl(_DRIVER_POSITION_OUT); m_GUNNER_POSITION = this.GetPlayerControl(_GUNNER_POSITION); m_GUNNER_COVERED_POSITION = this.GetPlayerControl(_GUNNER_COVERED_POSITION); #endregion #region Armamento this.m_AssaultBolter = this.GetWeapon(_AssaultBolter); #endregion this.SetPlaterControl(this.m_DRIVER_POSITION_OUT); }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { base.LoadContent(); #region Controlador de animación m_BATTLECANNON = (AnimationAxis)this.GetAnimation(_BATTLECANNON); m_BATTLECANNONBASE = (Animation)this.GetAnimation(_BATTLECANNONBASE); m_HULL_CANNON = (AnimationAxis)this.GetAnimation(_HULL_CANNON); m_HULL_CANNON_BASE = (Animation)this.GetAnimation(_HULL_CANNON_BASE); m_LEFT_BOLTER = (AnimationAxis)this.GetAnimation(_LEFT_BOLTER); m_LEFT_BOLTER_BASE = (AnimationAxis)this.GetAnimation(_LEFT_BOLTER_BASE); m_RIGHT_BOLTER = (AnimationAxis)this.GetAnimation(_RIGHT_BOLTER); m_RIGHT_BOLTER_BASE = (AnimationAxis)this.GetAnimation(_RIGHT_BOLTER_BASE); m_TURRET_HACTH = (AnimationAxis)this.GetAnimation(_TURRET_HACTH); m_DRIVER_HACTH = (AnimationAxis)this.GetAnimation(_DRIVER_HACTH); m_LEFT_HACTH = (AnimationAxis)this.GetAnimation(_LEFT_HACTH); m_RIGHT_HACTH = (AnimationAxis)this.GetAnimation(_RIGHT_HACTH); #endregion #region Controladores de posición m_DRIVER = this.GetPlayerControl(_DRIVER); m_BATTLECANNONGUNNER = this.GetPlayerControl(_BATTLECANNONGUNNER); m_LASERCANNONGUNNER = this.GetPlayerControl(_LASERCANNONGUNNER); m_LEFTBOLTERGUNNER = this.GetPlayerControl(_LEFTBOLTERGUNNER); m_RIGHTBOLTERGUNNER = this.GetPlayerControl(_RIGHTBOLTERGUNNER); #endregion #region Armamento this.m_BattleCannon = this.GetWeapon(_BattleCannon); this.m_LaserCannon = this.GetWeapon(_LaserCannon); this.m_LeftHeavyBolter = this.GetWeapon(_LeftHeavyBolter); this.m_RightHeavyBolter = this.GetWeapon(_RightHeavyBolter); #endregion this.SetPlaterControl(this.m_DRIVER); }
public static void StartTranslationAnimation(this UIElement element, AnimationAxis axis, float?from = null, float to = 0, double duration = 800, int delay = 0, CompositionEasingFunction easing = null, Action completed = null, AnimationIterationBehavior iterationBehavior = AnimationIterationBehavior.Count) { CompositionScopedBatch batch = null; ElementCompositionPreview.SetIsTranslationEnabled(element, true); var visual = element.Visual(); var compositor = visual.Compositor; if (completed != null) { batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); batch.Completed += (s, e) => completed(); } visual.StartAnimation($"Translation.{axis}", compositor.CreateScalarKeyFrameAnimation(from, to, duration, delay, easing, iterationBehavior)); batch?.End(); }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { this.ComponentInfoName = "LandSpeeder.xml"; base.LoadContent(); #region Controlador de animación m_FusionCannon = (AnimationAxis)this.GetAnimation("FusionCannon"); m_FusionCannonBase = (AnimationAxis)this.GetAnimation("FusionCannonBase"); #endregion #region Controladores de posición m_Driver = this.GetPlayerPosition("Driver"); m_Gunner = this.GetPlayerPosition("Gunner"); #endregion this.SetPlayerPosition(Player.Gunner); }
/// <summary> /// Inicializa los componentes gráficos /// </summary> protected override void LoadContent() { base.LoadContent(); #region Controlador de animación m_PILOT_HEAD = (AnimationAxis)this.GetAnimation(_PILOT_HEAD); m_PILOT_NECK = (AnimationAxis)this.GetAnimation(_PILOT_NECK); m_FUSION_CANNON = (AnimationAxis)this.GetAnimation(_FUSION_CANNON); m_FUSION_CANNON_BASE = (AnimationAxis)this.GetAnimation(_FUSION_CANNON_BASE); #endregion #region Controladores de posición m_PILOT = this.GetPlayerControl(_PILOT); m_GUNNER = this.GetPlayerControl(_GUNNER); #endregion #region Armamento this.m_FussionCannon = this.GetWeapon(_FussionCannon); #endregion #region Emisores this.m_LeftEngine = this.GetParticleEmitter(_LeftEngine); this.m_RightEngine = this.GetParticleEmitter(_RightEngine); this.m_LeftSmokeEmitter = this.GetParticleEmitter(_LeftSmokeEmitter); this.m_RightSmokeEmitter = this.GetParticleEmitter(_RightSmokeEmitter); #endregion this.SetPlaterControl(this.m_PILOT); }
public int GetIndexOfClosestPlot(double value) { return(AnimationAxis.GetClosestMajorTickIndex(value)); }