private void AnimationVisualElement(TranslateTransform3D translate, bool forward, double targetX, double targetY, double targetZ) { Duration duration = new Duration(TimeSpan.FromSeconds(.4)); //对TranslateTransform3D的X偏移量应用动画 DoubleAnimation animationX = new DoubleAnimation(); animationX.To = targetX; animationX.Duration = duration; animationX.AccelerationRatio = forward ? 0 : 1; animationX.DecelerationRatio = forward ? 1 : 0; translate.BeginAnimation(TranslateTransform3D.OffsetXProperty, animationX); //对TranslateTransform3D的Y偏移量应用动画 DoubleAnimation animationY = new DoubleAnimation(); animationX.To = targetY; animationX.AccelerationRatio = forward ? 0.7 : 0.3; animationX.DecelerationRatio = forward ? 0.3 : 0.7; animationX.Duration = duration; translate.BeginAnimation(TranslateTransform3D.OffsetYProperty, animationX); //对TranslateTransform3D的Z偏移量应用动画 DoubleAnimation animationZ = new DoubleAnimation(); animationZ.To = targetZ; animationZ.AccelerationRatio = forward ? 0.3 : 0.7; animationZ.DecelerationRatio = forward ? 0.7 : 0.3; animationZ.Duration = duration; translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, animationZ); }
void translateModel(Vector3D srcvec, Vector3D objvec, Vector3D oldvec) { DoubleAnimation dx, dy, dz; TranslateTransform3D translate = null; foreach (Transform3D one in (zmodel.Transform as Transform3DGroup).Children) { if (one is TranslateTransform3D) { translate = one as TranslateTransform3D; break; } } if (translate == null) return; if (objvec.X != oldvec.X) { dx = new DoubleAnimation(srcvec.X, objvec.X, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetXProperty, dx); } translate.OffsetX = objvec.X; if (objvec.Y != oldvec.Y) //备忘:遗留问题,此暂并未使用到Y方向的分裂,无需对齐 { dy = new DoubleAnimation(srcvec.Y, objvec.Y, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetYProperty, dy); translate.OffsetY = objvec.Y; } if (objvec.Z != oldvec.Z) { dz = new DoubleAnimation(srcvec.Z, objvec.Z, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, dz); } translate.OffsetZ = objvec.Z; }
private void StateKeyGet() { double speedratio = parent.sld_EC_Speed.Value; c_step = 0; parent.lbl_EC_Text.Content = String.Format(Properties.Resources.Key_XOR_, c_round, parent.cipher.States[c_round, 0], parent.cipher.States[c_round, 1]); parent.lbl_EC_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[0]); Point3D pos = GetRoundKeyPosition(c_round); Point3D des = new Point3D(-6, 0, 0); TranslateTransform3D tt = new TranslateTransform3D(); DoubleAnimation dx = new DoubleAnimation(pos.X, des.X, TimeSpan.FromSeconds(2)) { SpeedRatio = speedratio }; DoubleAnimation dy = new DoubleAnimation(pos.Y, des.Y, TimeSpan.FromSeconds(2)) { SpeedRatio = speedratio }; DoubleAnimation dz = new DoubleAnimation(pos.Z, des.Z, TimeSpan.FromSeconds(2)) { SpeedRatio = speedratio }; mdl3D_roundkey[c_round].Transform = tt; Color_RoundKeyCube(c_round, 0); Color_State(c_round, 0, 0); tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dx); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, dy); tt.BeginAnimation(TranslateTransform3D.OffsetZProperty, dz); countdown(2, MethodBase.GetCurrentMethod().Name, speedratio); }
/// <summary> /// 移动 /// </summary> internal void Move(int currentIndex) { _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty, AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed)); _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed)); _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed)); }
public void Animate(int index) { var rotateAnimation = new DoubleAnimation(RotationAngle(index), AnimationDuration); var xAnimation = new DoubleAnimation(TranslationX(index), AnimationDuration); var zAnimation = new DoubleAnimation(TranslationZ(index), AnimationDuration); rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, rotateAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, xAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetZProperty, zAnimation); }
public void Animate(int index) { TimeSpan duration = TimeSpan.FromMilliseconds(500); var rotateAnimation = new DoubleAnimation(RotationAngle(index), duration); var xAnimation = new DoubleAnimation(TranslationX(index), duration); var zAnimation = new DoubleAnimation(TranslationZ(index), duration); rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, rotateAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, xAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetZProperty, zAnimation); }
public Transform3DCollection OutDownFrontRight(Point3D SourcePosition, Point3D TargetPosition, double Wait, double Duration) { Transform3DCollection tc = new Transform3DCollection(); DoubleAnimation xa = new DoubleAnimation(SourcePosition.X, TargetPosition.X, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(0) }; DoubleAnimation ya = new DoubleAnimation(SourcePosition.Y, TargetPosition.Y, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(Duration / 2) }; DoubleAnimation za = new DoubleAnimation(SourcePosition.Z, TargetPosition.Z, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(Duration / 2) }; TranslateTransform3D xt = new TranslateTransform3D(); xt.BeginAnimation(TranslateTransform3D.OffsetXProperty, xa); TranslateTransform3D yt = new TranslateTransform3D(); yt.BeginAnimation(TranslateTransform3D.OffsetYProperty, ya); TranslateTransform3D zt = new TranslateTransform3D(); zt.BeginAnimation(TranslateTransform3D.OffsetZProperty, za); tc.Add(xt); tc.Add(yt); tc.Add(zt); return(tc); }
private void MoveIt(ModelVisual3D mv3dgl, double to) { TranslateTransform3D t = mv3dgl.Transform as TranslateTransform3D; DoubleAnimation da = new DoubleAnimation(to, new Duration(TimeSpan.FromMilliseconds(100))); da.DecelerationRatio = 1; t.BeginAnimation(TranslateTransform3D.OffsetZProperty, da); }
public void Animate(int index, bool animate) { if (animate || rotation.HasAnimatedProperties) { var rotateAnimation = new DoubleAnimation(RotationAngle(index), AnimationDuration); var xAnimation = new DoubleAnimation(TranslationX(index), AnimationDuration); var zAnimation = new DoubleAnimation(TranslationZ(index), AnimationDuration); rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, rotateAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, xAnimation); translation.BeginAnimation(TranslateTransform3D.OffsetZProperty, zAnimation); } else { rotation.Angle = RotationAngle(index); translation.OffsetX = TranslationX(index); translation.OffsetZ = TranslationZ(index); } }
/// <summary> /// 移动 /// </summary> internal void Move(int currentIndex, bool animated) { if (animated || _rotation3D.HasAnimatedProperties) { _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty, AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed)); _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed)); _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed)); } else { _rotation3D.Angle = GetAngleByPos(currentIndex); _transform3D.OffsetX = GetXByPos(currentIndex); _transform3D.OffsetZ = GetZByPos(currentIndex); } }
private void BtnSeparate_Click(object sender, RoutedEventArgs e) { List <ContainerUIElement3D> uiElement3DList = Helpers.Visual3Ds.Visual3DHelper.GetAllElement3DInViewPoirt3D <ContainerUIElement3D>(viewport3D); foreach (ContainerUIElement3D uiElement3D in uiElement3DList) { var visual = uiElement3D.Children[0] as Viewport2DVisual3D; var geometry = visual.Geometry as MeshGeometry3D; Point3D point = geometry.Positions[0]; double x = point.X - _center.X; double y = point.Y - _center.Y; double a = Math.Sqrt(2000 * 2000 / (x * x + y * y)); Transform3DGroup transform3DGroup = uiElement3D.Transform as Transform3DGroup; TranslateTransform3D translateTransform3D = transform3DGroup.Children[0] as TranslateTransform3D; DoubleAnimation doubleAnimationTranslateTransform = new DoubleAnimation(); doubleAnimationTranslateTransform.BeginTime = new TimeSpan(0, 0, 0); doubleAnimationTranslateTransform.Duration = TimeSpan.FromMilliseconds(3000); doubleAnimationTranslateTransform.From = translateTransform3D.OffsetX; doubleAnimationTranslateTransform.To = x * a; doubleAnimationTranslateTransform.Completed += (s, args) => uiElement3D.Visibility = Visibility.Collapsed; doubleAnimationTranslateTransform.EasingFunction = new BackEase() { Amplitude = 0.3, EasingMode = EasingMode.EaseIn, }; DoubleAnimation doubleAnimationTranslateTransformY = new DoubleAnimation(); doubleAnimationTranslateTransformY.BeginTime = new TimeSpan(0, 0, 0); doubleAnimationTranslateTransformY.Duration = TimeSpan.FromMilliseconds(3000); doubleAnimationTranslateTransformY.From = translateTransform3D.OffsetX; doubleAnimationTranslateTransformY.To = y * a; doubleAnimationTranslateTransformY.EasingFunction = new BackEase() { Amplitude = 0.3, EasingMode = EasingMode.EaseIn, }; translateTransform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, doubleAnimationTranslateTransform); translateTransform3D.BeginAnimation(TranslateTransform3D.OffsetYProperty, doubleAnimationTranslateTransformY); } }
private void OnStop(object param) { animation.RepeatBehavior = new RepeatBehavior(0.1); translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, animation); #region rotation //animation.RepeatBehavior = new RepeatBehavior(0.1); //rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, animation); #endregion }
public override void Perform() { TranslateTransform3D TranslateTransform3D = GetTranslateTransform3DFromViewport3D(Viewport3D); switch (PropertyToAnimate) { case Properties.OffsetXProperty: TranslateTransform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, DoubleAnimation, HandoffBehavior); break; case Properties.OffsetYProperty: TranslateTransform3D.BeginAnimation(TranslateTransform3D.OffsetYProperty, DoubleAnimation, HandoffBehavior); break; case Properties.OffsetZProperty: TranslateTransform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, DoubleAnimation, HandoffBehavior); break; } }
public void Animate(double aRotationAngle, double aTranslationX, double aTranslationY, double aTranslationZ, TimeSpan aAnimationDuration) { var rotateAnimation = new DoubleAnimation(aRotationAngle, aAnimationDuration); var xAnimation = new DoubleAnimation(aTranslationX, aAnimationDuration); var yAnimation = new DoubleAnimation(aTranslationY, aAnimationDuration); var zAnimation = new DoubleAnimation(aTranslationZ, aAnimationDuration); if (_Rotation != null) { _Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, rotateAnimation); } if (_Translation != null) { _Translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, xAnimation); _Translation.BeginAnimation(TranslateTransform3D.OffsetYProperty, yAnimation); _Translation.BeginAnimation(TranslateTransform3D.OffsetZProperty, zAnimation); } }
private void StateSboxIntegrate() { double speedratio = parent.sld_EC_Speed.Value; int p, x; TranslateTransform3D tt = new TranslateTransform3D(); p = c_group * 4; for (int i = 3; i >= 0; i--) { p = c_group * 4 + i; x = (int)(parent.cipher.States[c_round, 2] >> p) & 1; gma3D_state[p].Material = material[x, 1]; gma3D_state[p].Transform = tt; c_sel[i] = p; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 2, To = Math.PI * 3 / 2, Scale = 4, Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; if (c_group == 15) { DoubleAnimation da = new DoubleAnimation(opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = speedratio }; brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, da); DoubleAnimation db = new DoubleAnimation(opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = speedratio }; brush[0, 0].BeginAnimation(Brush.OpacityProperty, db); brush[1, 0].BeginAnimation(Brush.OpacityProperty, db); } else { DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(1), SpeedRatio = speedratio }; da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(.8))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_low, KeyTime.FromPercent(1))); brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, da); } tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1.5, MethodBase.GetCurrentMethod().Name, speedratio); }
private void Do3DAnimation(GradientBall ball, Point3D nextPosition) { Action animation = () => { var speed = new Duration(new TimeSpan(0, 0, 3)); Point3D currentPosition = ball.Offset; var animationX = new DoubleAnimation(currentPosition.X, nextPosition.X, speed); var animationY = new DoubleAnimation(currentPosition.Y, nextPosition.Y, speed); var animationZ = new DoubleAnimation(currentPosition.Z, nextPosition.Z, speed); var tt3D = new TranslateTransform3D(currentPosition.X, currentPosition.Y, currentPosition.Z); ball.Transform = tt3D; tt3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, animationX); tt3D.BeginAnimation(TranslateTransform3D.OffsetYProperty, animationY); tt3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, animationZ); }; ball.Dispatcher.BeginInvoke(DispatcherPriority.Send, animation); }
public void AnimateCaptureMove() { TranslateTransform3D translate = new TranslateTransform3D(); translate.OffsetX = 0; translate.OffsetY = 0; translate.OffsetZ = 20; this.Transformations.Children.Add(translate); DoubleAnimation animZ = new DoubleAnimation(0, translate.OffsetZ, new Duration(TimeSpan.FromSeconds(1))); translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, animZ); }
private void KeyShift() { c_step = 0; parent.lbl_KS_Text.Content = String.Format(Properties.Resources.rotate_key_register_61, parent.cipher.KeyRegs[c_round, 1, 0], parent.cipher.KeyRegs[c_round, 0, 0], parent.cipher.KeyRegs[c_round, 1, 1], parent.cipher.KeyRegs[c_round, 0, 1]); parent.lbl_KS_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[c_step]); double a, b, r = 6, h = -1.5; RoundCosDoubleAnimation rax = null; RoundSinDoubleAnimation ray = null, raz = null; TranslateTransform3D tt; for (int i = 0; i < 80; i++) { a = (2 * Math.PI * (i / 80.0)); b = (2 * Math.PI * ((i - 19) % 80) / 80.0); if (a > b) { b += 2 * Math.PI; } rax = new RoundCosDoubleAnimation() { From = a, To = b, Scale = r, Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; raz = new RoundSinDoubleAnimation() { From = a, To = b, Scale = r, Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; ray = new RoundSinDoubleAnimation() { From = a, To = b, Scale = h, Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; tt = new TranslateTransform3D(); gma3D_keyreg[i].Transform = tt; tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, rax); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, ray); tt.BeginAnimation(TranslateTransform3D.OffsetZProperty, raz); } countdown(4, MethodBase.GetCurrentMethod().Name); }
public static void AnimatePosition(ModelVisual3D model, Vector3D oldPosition, Vector3D newPosition) { TranslateTransform3D transform = new TranslateTransform3D(oldPosition); if (newPosition.X != oldPosition.X) { DoubleAnimation animationX = new DoubleAnimation(oldPosition.X, newPosition.X, AnimationDuration) { AccelerationRatio = AnimationAccelerationRatio, DecelerationRatio = AnimationDecelerationRatio, FillBehavior = FillBehavior.HoldEnd }; transform.BeginAnimation(TranslateTransform3D.OffsetXProperty, animationX); } if (newPosition.Y != oldPosition.Y) { DoubleAnimation animationY = new DoubleAnimation(oldPosition.Y, newPosition.Y, AnimationDuration) { AccelerationRatio = AnimationAccelerationRatio, DecelerationRatio = AnimationDecelerationRatio, FillBehavior = FillBehavior.HoldEnd }; transform.BeginAnimation(TranslateTransform3D.OffsetYProperty, animationY); } if (newPosition.Z != oldPosition.Z) { DoubleAnimation animationZ = new DoubleAnimation(oldPosition.Z, newPosition.Z, AnimationDuration) { AccelerationRatio = AnimationAccelerationRatio, DecelerationRatio = AnimationDecelerationRatio, FillBehavior = FillBehavior.HoldEnd }; transform.BeginAnimation(TranslateTransform3D.OffsetZProperty, animationZ); } AddTransformationAnimation(model, transform); }
void RoundKeyMove(int r) { //this.txtBoxStep.Text = ""; Point3D pos = GetRoundKeyPosition(r); TranslateTransform3D tt = new TranslateTransform3D(); DoubleAnimation dx = new DoubleAnimation(0, pos.X, TimeSpan.FromSeconds(2)) { SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation dy = new DoubleAnimation(0, pos.Y, TimeSpan.FromSeconds(2)) { SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation dz = new DoubleAnimation(0, pos.Z, TimeSpan.FromSeconds(2)) { SpeedRatio = parent.sld_KS_Speed.Value }; mdl3D_roundkey[r].Transform = tt; tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dx); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, dy); tt.BeginAnimation(TranslateTransform3D.OffsetZProperty, dz); }
private void BtnCombine_Click(object sender, RoutedEventArgs e) { List <ContainerUIElement3D> uiElement3DList = Helpers.Visual3Ds.Visual3DHelper.GetAllElement3DInViewPoirt3D <ContainerUIElement3D>(viewport3D); foreach (UIElement3D uiElment3D in uiElement3DList) { uiElment3D.Visibility = Visibility.Visible; Transform3DGroup transform3DGroup = uiElment3D.Transform as Transform3DGroup; TranslateTransform3D translateTransform3D = transform3DGroup.Children[0] as TranslateTransform3D; DoubleAnimation doubleAnimationTranslateTransform = new DoubleAnimation(); doubleAnimationTranslateTransform.BeginTime = new TimeSpan(0, 0, 0); doubleAnimationTranslateTransform.Duration = TimeSpan.FromMilliseconds(500); doubleAnimationTranslateTransform.From = translateTransform3D.OffsetX; doubleAnimationTranslateTransform.To = 0; doubleAnimationTranslateTransform.EasingFunction = new BackEase() { Amplitude = 0.3, EasingMode = EasingMode.EaseOut, }; DoubleAnimation doubleAnimationTranslateTransformY = new DoubleAnimation(); doubleAnimationTranslateTransformY.BeginTime = new TimeSpan(0, 0, 0); doubleAnimationTranslateTransformY.Duration = TimeSpan.FromMilliseconds(500); doubleAnimationTranslateTransformY.From = translateTransform3D.OffsetY; doubleAnimationTranslateTransformY.To = 0; doubleAnimationTranslateTransformY.EasingFunction = new BackEase() { Amplitude = 0.3, EasingMode = EasingMode.EaseOut, }; translateTransform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, doubleAnimationTranslateTransform); translateTransform3D.BeginAnimation(TranslateTransform3D.OffsetYProperty, doubleAnimationTranslateTransformY); } }
void translateLabel(Vector3D srcvec, Vector3D objvec, Vector3D oldvec) { DoubleAnimation dx, dy, dz; TranslateTransform3D translate = (zlabel.Transform as Transform3DGroup).Children[1] as TranslateTransform3D; if (objvec.X != oldvec.X) { dx = new DoubleAnimation(srcvec.X, objvec.X, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetXProperty, dx); } translate.OffsetX = objvec.X; if (objvec.Y != oldvec.Y) { dy = new DoubleAnimation(srcvec.Y + 1, objvec.Y + zmodel.Bounds.SizeY * 1.01 + 1, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetYProperty, dy); } translate.OffsetY = objvec.Y + zmodel.Bounds.SizeY * 1.01 + 1; if (objvec.Z != oldvec.Z) { dz = new DoubleAnimation(srcvec.Z, objvec.Z, duration, FillBehavior.Stop); translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, dz); } translate.OffsetZ = objvec.Z; }
public void Spin() { Front.InvalidateVisual(); Back.InvalidateVisual(); var rotationAnimation = new DoubleAnimation(FrontVisible ? 0 : 180, new Duration(TimeSpan.FromSeconds(SpinTime))); _rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, rotationAnimation); var translationAnimation = new DoubleAnimationUsingKeyFrames(); translationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(-0.5, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(SpinTime / 2.0)), new SineEase())); translationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(SpinTime)), new SineEase { EasingMode = EasingMode.EaseIn })); _translation.BeginAnimation(TranslateTransform3D.OffsetZProperty, translationAnimation); }
private void CreateSpinAnimation(SpinInstruction instruction, int tabToIndex, double fromAngle, double toAngle) { RotateTransform3D flipTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0)); DoubleAnimation flipAnimation = new DoubleAnimation(0, 360, new Duration(new TimeSpan(0, 0, 0, 0, animationDuration))); RotateTransform3D spinTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0)); DoubleAnimation spinAnimation = new DoubleAnimation(fromAngle, toAngle, new Duration(new TimeSpan(0, 0, 0, 0, animationDuration))); spinAnimation.Completed += (sender, e) => { instructions.Dequeue(); currentIndex = instruction.To; currentTabIndex = tabToIndex; isAnimating = false; Animate(); }; spinTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, spinAnimation); if (EnableFlip) { flipTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, flipAnimation); } Transform3DGroup carouselTransform = new Transform3DGroup(); carouselTransform.Children.Add(spinTransform); if (EnableFlip) { carouselTransform.Children.Add(flipTransform); } CarouselContainer.Transform = carouselTransform; double currentDistance = CalculateCameraDistance(instruction.From, currentTabIndex); double nextDistance = CalculateCameraDistance(instruction.To, tabToIndex); System.Diagnostics.Debug.WriteLine(nextDistance); DoubleAnimation cameraAnimation = new DoubleAnimation(currentDistance, nextDistance, new Duration(new TimeSpan(0, 0, 0, 0, animationDuration))); Transform3D cameraTransform = new TranslateTransform3D(0, 0, currentDistance); MainCamera.Transform = cameraTransform; cameraTransform.BeginAnimation(TranslateTransform3D.OffsetZProperty, cameraAnimation); }
//鼠标点击显示信息 private void pcbComponent_MouseDown(object sender, MouseButtonEventArgs e) { if (e.RightButton == MouseButtonState.Released && e.LeftButton == MouseButtonState.Pressed) { Point location = e.GetPosition(myViewport); ModelBase model = sender as ModelBase; TranslateTransform3D translateTrans = new TranslateTransform3D(0, 0, 0); (model.Transform as Transform3DGroup).Children.Add(translateTrans); DoubleAnimation animation = new DoubleAnimation(); animation.To = 5; animation.DecelerationRatio = 1; animation.Duration = TimeSpan.FromSeconds(1); animation.AutoReverse = true; translateTrans.BeginAnimation(TranslateTransform3D.OffsetYProperty, animation); } }
//鼠标点击显示信息 private void back_MouseDown(object sender, MouseButtonEventArgs e) { if (e.RightButton == MouseButtonState.Released && e.LeftButton == MouseButtonState.Pressed) { ModelBase model = sender as ModelBase; TranslateTransform3D translateTrans = new TranslateTransform3D(0, 0, 0); Transform3DGroup transGroup = new Transform3DGroup(); transGroup.Children.Add(model.Transform); transGroup.Children.Add(translateTrans); model.Transform = transGroup; DoubleAnimation animation = new DoubleAnimation(); animation.To = -300; animation.DecelerationRatio = 1; animation.Duration = TimeSpan.FromSeconds(1); animation.AutoReverse = true; translateTrans.BeginAnimation(TranslateTransform3D.OffsetZProperty, animation); } }
private void KeySboxExtract() { int x, r; TranslateTransform3D tt = new TranslateTransform3D(); r = (int)(parent.cipher.KeyRegs[c_round, 1, 1] >> 60) & 0x0f; for (int i = 0; i < 8; i++) { if (i < 4) { x = (r >> (3 - i)) & 1; } else { x = (parent.cipher.Sbox4[r] >> (7 - i)) & 1; } gma3D_sbox[r, i].Material = material[x, 3]; } for (int i = 76; i < 80; i++) { x = (r >> (i - 76)) & 1; gma3D_keyreg[i].Material = material[x, 3]; gma3D_keyreg[i].Transform = tt; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(1), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation da = new DoubleAnimation(opacity_default, opacity_high, TimeSpan.FromSeconds(1)) { SpeedRatio = parent.sld_KS_Speed.Value }; brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, da); tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1, MethodBase.GetCurrentMethod().Name); }
public async void pickSingleImage(UInt16 Z) { UInt16[] band = { Z, Z, Z }; if ((Ctrl_ImageView)((MultiFuncWindow)App.global_Windows[0]).UserControls[0] != null) { ((Ctrl_ImageView)((MultiFuncWindow)App.global_Windows[0]).UserControls[0]).RefreshPseudoColor(0, ImageInfo.strFilesPath, 4, band, ColorRenderMode.Grayscale); } if (Z < 1 || Z > 160) { return; } //Bitmap bmp = await DataProc.GetBmp(ImageInfo.strFilesPath, Z - 1, ColorRenderMode.Grayscale); Bitmap bmp = await BmpOper.MakePseudoColor(ImageInfo.strFilesPath, band, 4, ImageInfo.imgWidth); if (bmp == null) { return; } bmp.RotateFlip(RotateFlipType.Rotate180FlipNone); bmp.RotateFlip(RotateFlipType.Rotate180FlipY); BitmapImage bmpSource = new BitmapImage(); if (!File.Exists($"bmpFiles\\{Z}.bmp")) { bmp.Save($"bmpFiles\\{Z}.bmp"); } bmpSource = new BitmapImage(new Uri($"{Environment.CurrentDirectory}\\bmpFiles\\{Z}.bmp")); gm3d_Active.Material = new DiffuseMaterial(new System.Windows.Media.ImageBrush(bmpSource)); DoubleAnimation day = new DoubleAnimation { From = 0, To = imheight / 10 / (imheight / 600), Duration = new Duration(TimeSpan.FromSeconds(1)) }; //TranslateTransform3D transtrans3d = new TranslateTransform3D(0, 0, scene.touchPoint.Z); TranslateTransform3D transtrans3d = new TranslateTransform3D(0, 0, ((Z - 80) * 0.4)); gm3d_Active.Transform = transtrans3d; transtrans3d.BeginAnimation(TranslateTransform3D.OffsetYProperty, day); curBand.Content = Z.ToString(); }
private void KeyCounterAdd() { c_step = 2; parent.lbl_KS_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[c_step]); int a, b, r, x; a = (int)(parent.cipher.KeyRegs[c_round, 1, 3] & 0xf) << 1; b = (int)(parent.cipher.KeyRegs[c_round, 0, 3] >> 15) & 1; r = a ^ b; parent.lbl_KS_Text.Content = String.Format(Properties.Resources.xor_round_counter, Int2BinaryString(a, 5), Int2BinaryString(b, 5), Int2BinaryString(r, 5)); TranslateTransform3D tt = new TranslateTransform3D(); for (int i = 0; i < 5; i++) { x = (r >> i) & 1; gma3D_roundcountertemp[i].Material = gma3D_keyreg[i + 15].Material; gma3D_roundcountertemp[i].Transform = tt; gma3D_keyreg[i + 15].Material = material[x, 3]; } CosDoubleAnimation day = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(2), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0))); da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0.5))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_default, KeyTime.FromPercent(1))); DoubleAnimationUsingKeyFrames db = da.Clone(); brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, db); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, day); countdown(4, MethodBase.GetCurrentMethod().Name); }
private void KeySboxIntegrate() { TranslateTransform3D tt = new TranslateTransform3D(); for (int i = 76; i < 80; i++) { gma3D_keyreg[i].Transform = tt; } CosDoubleAnimation dax = new CosDoubleAnimation() { From = Math.PI * 2, To = Math.PI * 3 / 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(1), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimation da = new DoubleAnimation(opacity_high, opacity_default, TimeSpan.FromSeconds(1)) { SpeedRatio = parent.sld_KS_Speed.Value }; brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, da); tt.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax); countdown(1, MethodBase.GetCurrentMethod().Name); }