Example #1
1
        private void AntGrid(Grid g)
        {
            g.Width = 5;
            g.Height = 5;
            g.Visibility = Visibility.Visible;

            Storyboard sb = new Storyboard();
            DoubleAnimation da = new DoubleAnimation(5.0, gridmain.ActualWidth - 10, new Duration(TimeSpan.FromSeconds(2)));
            DoubleAnimation da1 = new DoubleAnimation(5.0, gridmain.RowDefinitions[0].ActualHeight - 10, new Duration(TimeSpan.FromSeconds(2)));

            DoubleAnimation da2 = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));

            TransformGroup tg = new TransformGroup();
            RotateTransform rt = new RotateTransform(720);

            tg.Children.Add(rt);
            g.RenderTransform = tg;
            g.RenderTransformOrigin = new Point(0.5, 0.5);
            Storyboard.SetTarget(da2, g);
            Storyboard.SetTargetProperty(da2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));//RotateTransform.AngleProperty
            sb.Children.Add(da2);

            Storyboard.SetTarget(da, g);
            Storyboard.SetTargetProperty(da, new PropertyPath(Grid.WidthProperty));
            sb.Children.Add(da);

            Storyboard.SetTarget(da1, g);
            Storyboard.SetTargetProperty(da1, new PropertyPath(Grid.HeightProperty));
            sb.Children.Add(da1);

            if (!Resources.Contains("ShowAn"))
                Resources.Add("ShowAn", sb);
            sb.AccelerationRatio = 1.0;
            sb.Begin();
        }
Example #2
1
        public Game(UserControl userControl, Canvas drawingCanvas, Canvas debugCanvas, TextBlock txtDebug)
        {
            //Initialize
            IsActive = true;
            IsFixedTimeStep = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16);
            Components = new List<DrawableGameComponent>();
            World = new World(new Vector2(0, 0));
            _gameTime = new GameTime();
            _gameTime.GameStartTime = DateTime.Now;
            _gameTime.FrameStartTime = DateTime.Now;
            _gameTime.ElapsedGameTime = TimeSpan.Zero;
            _gameTime.TotalGameTime = TimeSpan.Zero;

            //Setup Canvas
            DrawingCanvas = drawingCanvas;
            DebugCanvas = debugCanvas;
            TxtDebug = txtDebug;
            UserControl = userControl;

            //Setup GameLoop
            _gameLoop = new Storyboard();
            _gameLoop.Completed += GameLoop;
            _gameLoop.Duration = TargetElapsedTime;
            DrawingCanvas.Resources.Add("gameloop", _gameLoop);
        }
 public Window3()
 {
     InitializeComponent();
        delRun = new DelRun(Run);
        delUpdateUI = new DelUpdateUI(UpdateUI);
        sb = (Storyboard)Resources["myAni"];
 }
        void animating3_Completed(object sender, EventArgs e)
        {
            if(MainWindow.stopGesture)
            {
                myText.Content = "  2";
                var animation2Opacity = new DoubleAnimation();
                animation2Opacity.From = 1.0;
                animation2Opacity.To = 0;
                animation2Opacity.Duration = new Duration(TimeSpan.FromMilliseconds(1000));

                Storyboard.SetTarget(animation2Opacity, myText);
                Storyboard.SetTargetProperty(animation2Opacity, new PropertyPath(UIElement.OpacityProperty));

                Storyboard animating2 = new Storyboard();
                animating2.Children.Add(animation2Opacity);
                animating2.Completed += animating2_Completed;
                animating2.Begin();
            }
            else
            {
                myText.Visibility = Visibility.Collapsed;
                animationStarted = false;
            }

            

        }
        private static void TypewriteTextblock(string textToAnimate, TextBlock txt, TimeSpan timeSpan)
        {
            var story = new Storyboard
            {
                FillBehavior = FillBehavior.HoldEnd
            };

            DiscreteStringKeyFrame discreteStringKeyFrame;
            var stringAnimationUsingKeyFrames = new StringAnimationUsingKeyFrames
            {
                Duration = new Duration(timeSpan)
            };

            var tmp = string.Empty;
            foreach (var c in textToAnimate)
            {
                discreteStringKeyFrame = new DiscreteStringKeyFrame
                {
                    KeyTime = KeyTime.Paced
                };
                tmp += c;
                discreteStringKeyFrame.Value = tmp;
                stringAnimationUsingKeyFrames.KeyFrames.Add(discreteStringKeyFrame);
            }

            Storyboard.SetTargetName(stringAnimationUsingKeyFrames, txt.Name);
            Storyboard.SetTargetProperty(stringAnimationUsingKeyFrames, new PropertyPath(TextBlock.TextProperty));
            story.Children.Add(stringAnimationUsingKeyFrames);
            story.Begin(txt);
        }
 public void Shake()
 {
     if (sb != null && sb.GetCurrentState() == ClockState.Active)
         return;
     sb = (Storyboard)Resources["shaking"];
     sb.Begin();
 }
        /// <summary>
        /// 登录窗体逐渐缩小动画
        /// </summary>
        private void BeginEnterAnimation()
        {
            NameScope.SetNameScope(this, new NameScope());
            ScaleTransform st = this.RenderTransform as ScaleTransform;
            this.RegisterName("scale", st);

            Storyboard sb = new Storyboard();
            sb.Completed += (s, e) =>
            {
                this.Hide();
                new MainWindow().Show();
            };

            DoubleAnimation daX = new DoubleAnimation();
            daX.To = 0;
            daX.Duration = TimeSpan.FromSeconds(0.3);

            DoubleAnimation daY = new DoubleAnimation();
            daY.To = 0;
            daY.Duration = TimeSpan.FromSeconds(0.3);

            Storyboard.SetTargetName(daX, "scale");
            Storyboard.SetTargetProperty(daX, new PropertyPath(ScaleTransform.ScaleXProperty));
            Storyboard.SetTargetName(daY, "scale");
            Storyboard.SetTargetProperty(daY, new PropertyPath(ScaleTransform.ScaleYProperty));

            sb.Children.Add(daX);
            sb.Children.Add(daY);

            sb.Begin(this);

            //ST.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(1))));
            //ST.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(1))));
        }
Example #8
0
        //得到动画画板
        private Storyboard GetStoryboard(double? From1, double To1, double? From2, double To2, double Time1, double Time2)
        {
            Storyboard myStoryboard = new Storyboard();

            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            if (From1 != null)
            {
                myDoubleAnimation.From = From1;
            }
            myDoubleAnimation.To = To1;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(Time1));

            myStoryboard.Children.Add(myDoubleAnimation);
            Storyboard.SetTargetName(myDoubleAnimation, MaskFloor.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.OpacityProperty));

            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            if (From2 != null)
            {
                myDoubleAnimation1.From = From2;
            }
            myDoubleAnimation1.To = To2;
            myDoubleAnimation1.Duration = new Duration(TimeSpan.FromSeconds(Time2));

            myStoryboard.Children.Add(myDoubleAnimation1);
            Storyboard.SetTargetName(myDoubleAnimation1, InfFloor.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(Rectangle.OpacityProperty));

            return myStoryboard;
        }
Example #9
0
 public static void SetScrollEffect(DependencyObject obj, int value)
 {
     var elem = obj as FrameworkElement;
     var transGroup = new TransformGroup();
     transGroup.Children.Add(new ScaleTransform());
     transGroup.Children.Add(new SkewTransform());
     transGroup.Children.Add(new RotateTransform());
     transGroup.Children.Add(new TranslateTransform());
     elem.RenderTransform = transGroup;
     var sb = new Storyboard();
     var da = new DoubleAnimationUsingKeyFrames();
     Storyboard.SetTarget(da, obj);
     Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)", new object[0]));
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 60 });
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 60 });
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 900)), Value = 0, EasingFunction = new CircleEase { EasingMode = EasingMode.EaseOut } });
     sb.Children.Add(da);
     var da2 = new DoubleAnimationUsingKeyFrames();
     Storyboard.SetTarget(da2, obj);
     Storyboard.SetTargetProperty(da2, new PropertyPath(UIElement.OpacityProperty));
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 0 });
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 0 });
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 400)), Value = 1 });
     sb.Children.Add(da2);
     elem.Loaded += (a, b) =>
     {
         sb.Begin();
     };
     obj.SetValue(ScrollEffectProperty, value);
 }
        public LoadingSpin()
        {
            InitializeComponent();
            this.FlashText.Begin();
            this.intervalTimer = new Storyboard()
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(100))
            };
            this.intervalTimer.Completed += new EventHandler(this.OnIntervalTimerCompleted);

            this.animations = new List<Storyboard>()
            {
                CycleAnimation0,
                CycleAnimation1,
                CycleAnimation2,
                CycleAnimation3,
                CycleAnimation4,
                CycleAnimation5,
                CycleAnimation6,
                CycleAnimation7,
                CycleAnimation8,
                CycleAnimation9
            };
            this.Loaded += new RoutedEventHandler(LoadingSpin_Loaded);
        }
Example #11
0
        public ucSchedule()
        {
            try
            {
                InitializeComponent();

                sbFadeIn = (Storyboard)FindResource("sbFadeIn");
                sbFadeOut = (Storyboard)FindResource("sbFadeOut");
                sbFadeOut.Completed += sbFadeOut_Completed;
                sbFadeIn.Completed += sbFadeIn_Completed;

                btnRetry.MouseLeftButtonUp += btnRetry_MouseLeftButtonUp;
                btnRetry.TouchUp += btnRetry_TouchUp;

                btnUseLast.MouseLeftButtonUp += btnUseLast_MouseLeftButtonUp;
                btnUseLast.TouchUp += btnUseLast_TouchUp;

                timerschedule = new DispatcherTimer();
                timerschedule.Interval = TimeSpan.FromSeconds(1);
                timerschedule.Tick += timerschedule_Tick;

                timercountdown = new DispatcherTimer();
                timercountdown.Interval = TimeSpan.FromSeconds(1);
                timercountdown.Tick += timercountdown_Tick;
            }
            catch { }
        }
Example #12
0
        internal void fade(bool fadein)
        {            // Create a storyboard to contain the animations.
            storyboard = new Storyboard();
            TimeSpan duration = new TimeSpan(0, 0, 1);

            // Create a DoubleAnimation to fade the not selected option control
            DoubleAnimation animation = new DoubleAnimation();
            if (fadein)
            {
                animation.From = 0.0;
                animation.To = 1.0;
            }
            else
            {
                animation.From = 1.0;
                animation.To = 0.0;
            }
            animation.Duration = new Duration(duration);
            // Configure the animation to target de property Opacity
            Storyboard.SetTargetName(animation, this.uiImage.Name);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Image.OpacityProperty));
            // Add the animation to the storyboard
            storyboard.Children.Add(animation);

            // Begin the storyboard
            storyboard.Begin(this.uiImage);
        }
        private void PerformAppearanceAnimation()
        {
            double w = System.Windows.Application.Current.Host.Content.ActualWidth;
            double h = System.Windows.Application.Current.Host.Content.ActualHeight;

            CompositeTransform ct = (CompositeTransform)LayoutRoot.RenderTransform;
            ct.TranslateY = h;

            LayoutRoot.Visibility = Visibility.Visible;

            Storyboard animation = new Storyboard();
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.3));

            // Y animation
            DoubleAnimation galleryAnimation = new DoubleAnimation();
            galleryAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
            galleryAnimation.To = 0.0;
            galleryAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(galleryAnimation, LayoutRoot);
            Storyboard.SetTargetProperty(galleryAnimation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)"));
            animation.Children.Add(galleryAnimation);
            animation.Begin();
            animation.Completed += (sender, e) =>
            {
                OnPageAppeared();
            };
        }
Example #14
0
        private void DrawLeftPage()
        {
            //Tworzę obiekt canvas
            Canvas cv = new Canvas();
            cv.Width = 100;
            cv.Height = 100;
            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(255, 0, 255, 255));
            cv.Background = sb;
            Canvas.SetLeft(cv, 150);
            Canvas.SetTop(cv, 100);

            //Projekcja
            PlaneProjection pp = new PlaneProjection();
            pp.LocalOffsetX = -50.0;
            cv.Projection = pp;

            //Dodaję canvas
            plutno.Children.Add(cv);

            //Tworzę animację
            stL = new Storyboard();
            DoubleAnimation db = new DoubleAnimation();
            db.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
            db.From = 0.0;
            db.To = -180.0;

            Storyboard.SetTarget(db, pp);
            Storyboard.SetTargetProperty(db, new PropertyPath(PlaneProjection.RotationYProperty));

            //Dodanie animacji do storyboarda
            stL.Children.Add(db);
        }
Example #15
0
        public LoginView()
        {
            this.InitializeComponent();
            this.confirmSpinnerAnimation = (Storyboard)this.Resources["RotateConfirmSpinner"];

            this.IsVisibleChanged += this.onIsVisibleChanged;
        }
        public Scanner()
        {
            InitializeComponent();

            // Hook up to storyboard(s)
            FrameworkElement templateRoot = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
            if (null != templateRoot)
            {
                foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(templateRoot))
                {
                    if (VisibilityGroupName == group.Name)
                    {
                        foreach (VisualState state in group.States)
                        {
                            if ((ClosedVisibilityStateName == state.Name) && (null != state.Storyboard))
                            {
                                _closedStoryboard = state.Storyboard;
                                _closedStoryboard.Completed += OnClosedStoryboardCompleted;
                            }
                        }
                    }
                }
            }

            // Play the Open state
            VisualStateManager.GoToState(this, OpenVisibilityStateName, true);
        }
        public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue,
            TimeSpan iDuration, CancellationToken iCancellationToken)
        {
            TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
            DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration));
            PropertyPath p = new PropertyPath("(0)", dp);
            Storyboard.SetTargetProperty(anim, p);
            Storyboard sb = new Storyboard();
            sb.Children.Add(anim);
            EventHandler handler = null;
            handler = delegate
            {
                sb.Completed -= handler;
                sb.Remove(@this);
                @this.SetValue(dp, targetvalue);
                tcs.TrySetResult(null);
            };
            sb.Completed += handler;
            sb.Begin(@this, true);

            iCancellationToken.Register(() =>
            {
                double v = (double)@this.GetValue(dp);  
                sb.Stop(); 
                sb.Remove(@this); 
                @this.SetValue(dp, v);
                tcs.TrySetCanceled();
            });

            return tcs.Task;
        }
Example #18
0
 public UpdateCell(TextBlock tb, Storyboard sbUp, Storyboard sbDown, Storyboard sbSame)
 {
     this.tb = tb;
     this.sbUp = sbUp;
     this.sbDown = sbDown;
     this.sbSame = sbSame;
 }
        public static void AnimateScrollIntoViewMainMenu(this ItemsControl itemsControl, object item)
        {
            try
            {
                ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild<ScrollViewer>(itemsControl);

                UIElement container = itemsControl.ItemContainerGenerator.ContainerFromItem(item) as UIElement;
                int index = itemsControl.ItemContainerGenerator.IndexFromContainer(container);
                double toValue = scrollViewer.ExtentWidth * ((double)index / itemsControl.Items.Count);
                Point relativePoint = container.TranslatePoint(new Point(0.0, 0.0), Window.GetWindow(container));

                DoubleAnimation horizontalAnimation = new DoubleAnimation();
                horizontalAnimation.From = scrollViewer.HorizontalOffset;
                horizontalAnimation.To = toValue;
                horizontalAnimation.DecelerationRatio = .2;
                horizontalAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
                Storyboard storyboard = new Storyboard();
                storyboard.Children.Add(horizontalAnimation);
                Storyboard.SetTarget(horizontalAnimation, scrollViewer);
                Storyboard.SetTargetProperty(horizontalAnimation, new PropertyPath(ScrollViewerBehavior.HorizontalOffsetProperty));
                storyboard.Begin();
            }
            catch (Exception)
            {

                
            }
        }
Example #20
0
        public static void Animate(this DependencyObject target, double from, double to, object propertyPath, int duration, int startTime, IEasingFunction easing = null, Action completed = null)
        {
            if (easing == null)
                easing = new SineEase();

            var db = new DoubleAnimation();
            db.To = to;
            db.From = from;
            db.EasingFunction = easing;
            db.Duration = TimeSpan.FromMilliseconds(duration);

            Storyboard.SetTarget(db, target);
            Storyboard.SetTargetProperty(db, new PropertyPath(propertyPath));

            var sb = new Storyboard();
            sb.BeginTime = TimeSpan.FromMilliseconds(startTime);

            if (completed != null)
            {
                sb.Completed += (s, e) => completed();
            }

            sb.Children.Add(db);
            sb.Begin();
        }
        private void PerformCaptureAnimation()
        {
            LoadingView.Text = "Processing ...";
            ShowLoadingView();

            curtain = new Rectangle();
            curtain.Fill = new SolidColorBrush(Colors.White);
            LayoutRoot.Children.Add(curtain);

            Storyboard animation = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
            animation.Duration = duration;

            DoubleAnimation curtainAnimation = new DoubleAnimation();
            animation.Children.Add(curtainAnimation);
            curtainAnimation.Duration = duration;
            curtainAnimation.To = 0;
            curtainAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn };
            Storyboard.SetTarget(curtainAnimation, curtain);
            Storyboard.SetTargetProperty(curtainAnimation, new PropertyPath("Opacity"));

            animation.Completed += (sender, e) => {
                LayoutRoot.Children.Remove(curtain);
            };

            animation.Begin();
        }
Example #22
0
    static Tilt()
    {
      tiltStoryboard = new Storyboard();
      untiltStoryboard = new Storyboard();

      depressAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(depressAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.GlobalOffsetZ)"));
      tiltStoryboard.Children.Add(depressAnimation);

      rotationXAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(rotationXAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationX)"));
      tiltStoryboard.Children.Add(rotationXAnimation);

      rotationYAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(rotationYAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationY)"));
      tiltStoryboard.Children.Add(rotationYAnimation);

      DoubleAnimation animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.GlobalOffsetZ)"));
      untiltStoryboard.Children.Add(animation);

      animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationX)"));
      untiltStoryboard.Children.Add(animation);

      animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationY)"));
      untiltStoryboard.Children.Add(animation);
    }
Example #23
0
		public PressureTank()
		{
			InitializeComponent();

			// Initialize visualization resources
			_pumpingStoryboard = (Storyboard)Resources["RotatePump"];
			_pumpingStoryboard.Begin();

			_pressureLevelStoryboard = (Storyboard)Resources["PressureLevel"];
			_pressureLevelStoryboard.Begin();
			_pressureLevelStoryboard.Pause();

			_timerAlertStoryboard = (Storyboard)Resources["TimerEvent"];
			_sensorAlertStoryboard = (Storyboard)Resources["SensorEvent"];

			// Initialize the simulation environment
			_simulator = new RealTimeSimulator(_model, stepDelay: 1000);
			_simulator.SimulationStateChanged += (o, e) => UpdateSimulationButtonVisibilities();
			_simulator.ModelStateChanged += (o, e) => UpdateModelState();

			// Initialize the visualization state
			UpdateSimulationButtonVisibilities();
			UpdateModelState();

			TimerAlert.Opacity = 0;
			SensorAlert.Opacity = 0;

			ChangeSpeed(8);
		}
Example #24
0
File: Engine.cs Project: JuRogn/OA
        public static Storyboard CreateStoryboard(List<IModel> models, Storyboard sourceStoryboard)
        {
            Storyboard _storyboard;
            if (sourceStoryboard != null)
                _storyboard = sourceStoryboard;
            else
                _storyboard = new Storyboard();

            foreach (var item in models)
            {
                switch (item.ModelType)
                {
                    case IModelType.Double:_storyboard.Children.Add(Components.DoubleComponents.BuildDoubleAnimation(item as DoubleModel));
                        break;
                    case IModelType.DoubleKeyFrames:_storyboard.Children.Add(Components.DoubleComponents.BuildDoubleKeyFramesAnimation(item as DoubleKeyFramesModel));
                        break;
                    case IModelType.Color:_storyboard.Children.Add(Components.ColorComponents.BuildColorAnimation(item as ColorModel));
                        break;
                    case IModelType.ColorKeyFrames:_storyboard.Children.Add(Components.ColorComponents.BuildColorKeyFramesAnimation(item as ColorKeyFramesModel));
                        break;
                    case IModelType.Point:_storyboard.Children.Add(Components.PointComponents.BuildPointAnimation(item as PointModel));
                        break;
                    case IModelType.PointKeyFrames:_storyboard.Children.Add(Components.PointComponents.BuildPointKeyFramesAnimation(item as PointKeyFramesModel));
                        break;
                    case IModelType.ObjectKeyFrames:_storyboard.Children.Add(Components.ObjectComponents.BuildObjectKeyFramesAnimation(item as ObjectKeyFramesModel));
                        break;
                    default:
                        break;
                }
            }
            return _storyboard;
        }
        public PopupMsg(TextBlock msg)
        {
            //Store TextBlock for message display
            this.msg = msg;
            //Register the textblock's name, this is necessary for creating Storyboard using codes instead of XAML
            NameScope.SetNameScope(msg, new NameScope());
            msg.RegisterName("fadetext", msg);

            //Create the fade in & fade out animation
            DoubleAnimationUsingKeyFrames fadeInOutAni = new DoubleAnimationUsingKeyFrames();
            LinearDoubleKeyFrame keyframe = new LinearDoubleKeyFrame();
            keyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2));
            keyframe.Value = 1;
            fadeInOutAni.KeyFrames.Add(keyframe);
            //keyframe = new LinearDoubleKeyFrame();

            fadeInOutAni.Duration = new Duration(TimeSpan.FromSeconds(4));        
            fadeInOutAni.AutoReverse = true;
            fadeInOutAni.AccelerationRatio = .2;
            fadeInOutAni.DecelerationRatio = .7;

            // Configure the animation to target the message's opacity property
            Storyboard.SetTargetName(fadeInOutAni, "fadetext");
            Storyboard.SetTargetProperty(fadeInOutAni, new PropertyPath(TextBlock.OpacityProperty));

            // Add the fade in & fade out animation to the Storyboard
            Storyboard fadeInOutStoryBoard = new Storyboard();
            fadeInOutStoryBoard.Children.Add(fadeInOutAni);

            // Set event trigger, make this animation played on an event we can control
            msg.IsVisibleChanged += delegate(object sender,  System.Windows.DependencyPropertyChangedEventArgs e)
            {
                if (msg.IsVisible) fadeInOutStoryBoard.Begin(msg);
            };
        }
Example #26
0
 /// <summary>
 /// Creates a Storyboard with this Timeline, sets the target and target property
 /// accordingly, and begins the animation.
 /// </summary>
 /// <param name="animation">The Timeline that will be started.</param>
 /// <param name="target">The actual instance of the object to target.</param>
 /// <param name="propertyPath">A dependency property identifier or property path string that describes the
 /// property that will be animated.</param>
 public static void BeginAnimation(this Timeline animation, DependencyObject target, object propertyPath)
 {
     animation.SetTargetAndProperty(target, propertyPath);
     var sb = new Storyboard();
     sb.Children.Add(animation);
     sb.Begin();
 }
Example #27
0
        //========================================================================================
        // Constructors
        //========================================================================================
        /// <summary>
        /// This constructor must be called by implementors or the fading functionality
        /// will not work.
        /// </summary>
        public FadingWindow()
            : base()
        {
            this.Opacity = 0.0;

            // by setting it hidden, this hides the window from the Alt-Tab program switcher
            this.Visibility = Visibility.Hidden;

            DoubleAnimation animation = new DoubleAnimation(
                HiddenOpacity, VisibleOpacity, new Duration(TimeSpan.FromMilliseconds(300)));
            animation.BeginTime = TimeSpan.FromMilliseconds(100);
            animation.AutoReverse = false;

            this.fadeInStoryboard = new Storyboard();
            this.fadeInStoryboard.Children.Add(animation);
            this.fadeInStoryboard.Completed += new EventHandler(ShowCompleted);

            animation = new DoubleAnimation(
                VisibleOpacity, HiddenOpacity, new Duration(TimeSpan.FromMilliseconds(500)));
            animation.BeginTime = TimeSpan.FromMilliseconds(100);
            animation.AutoReverse = false;

            this.fadeOutStoryboard = new Storyboard();
            this.fadeOutStoryboard.Children.Add(animation);
            this.fadeOutStoryboard.Completed += new EventHandler(HideCompleted);

            this.timer = new DispatcherTimer();
            this.timer.Tick += new EventHandler(InitiateFadeOut);
            this.timer.Interval = DefaultFadeOutDelay;
        }
        void InitializeNotificationBar()
        {
            _storyboard = new Storyboard();
            _storyboard.Completed += _storyboard_Completed;

            var animation0 = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.1)));
            Storyboard.SetTarget(animation0, notify_br);
            Storyboard.SetTargetProperty(animation0, new PropertyPath(Border.OpacityProperty));
            _storyboard.Children.Add(animation0);

            var animation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.5)));
            animation.EasingFunction = new CircleEase { EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(animation, notify_br);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(Border.RenderTransform).Y"));
            _storyboard.Children.Add(animation);

            var animation2 = new DoubleAnimation(40, new Duration(TimeSpan.FromSeconds(0.5)));
            animation2.BeginTime = TimeSpan.FromSeconds(3);
            animation2.EasingFunction = new CircleEase { EasingMode = EasingMode.EaseIn };
            Storyboard.SetTarget(animation2, notify_br);
            Storyboard.SetTargetProperty(animation2, new PropertyPath("(Border.RenderTransform).Y"));
            _storyboard.Children.Add(animation2);

            var animation3 = new DoubleAnimation(0, new Duration(TimeSpan.Zero));
            animation3.BeginTime = TimeSpan.FromSeconds(3.5);
            Storyboard.SetTarget(animation3, notify_br);
            Storyboard.SetTargetProperty(animation3, new PropertyPath(Border.OpacityProperty));
            _storyboard.Children.Add(animation3);
        }
		private async void SlideIn() {
			Opacity = 1.0;
			var workingArea = Screen.PrimaryScreen.WorkingArea;
			var aTop = new DoubleAnimation {
				From = workingArea.Bottom + Height,
				To = (workingArea.Bottom - Height) - 5.0,
				Duration = new Duration(TimeSpan.FromSeconds(0.5))
			};
			var aBottom = new DoubleAnimation {
				To = (workingArea.Bottom + Height) + 5.0,
				Duration = new Duration(TimeSpan.FromSeconds(0.5))
			};
			var storyboard = new Storyboard();
			storyboard.Children.Add(aTop);
			Storyboard.SetTarget(aTop, this);
			Storyboard.SetTargetProperty(aTop, new PropertyPath(TopProperty));
			await Extensions.BeginAsync(storyboard);
			await Task.Delay(0xbb8);
			storyboard.Children.Clear();
			storyboard.Children.Add(aBottom);
			Storyboard.SetTarget(aBottom, this);
			Storyboard.SetTargetProperty(aBottom, new PropertyPath(TopProperty));
			await Extensions.BeginAsync(storyboard);
			Close();
		}
Example #30
0
        public void DismissEVHUD()
        {
            if (evHUDView == null)
            {
                return;
            }

            Storyboard storyboard = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
            storyboard.Duration = duration;

            DoubleAnimation panelAnimation = new DoubleAnimation();
            panelAnimation.Duration = duration;
            panelAnimation.To = evHUDView.Width;
            panelAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(panelAnimation, evHUDView);
            Storyboard.SetTargetProperty(panelAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
            storyboard.Children.Add(panelAnimation);

            storyboard.Begin();
            storyboard.Completed += (sender, e) =>
            {
                evHUDView.Visibility = Visibility.Collapsed;

                if (Orientation == PageOrientation.LandscapeLeft || Orientation == PageOrientation.LandscapeRight)
                {
                    ShowLandscapeShutterButton();
                }

            };
        }