Ejemplo n.º 1
0
 public static void AddRange(this TimelineCollection timelineCollection, IEnumerable <Timeline> timelines)
 {
     foreach (var timeline in timelines)
     {
         timelineCollection.Add(timeline);
     }
 }
Ejemplo n.º 2
0
        protected void GenerateStoryboardTree()
        {
            var rootStoryboard = GenerateStoryboardTreeImpl();

            Children = new TimelineCollection {
                rootStoryboard
            };
        }
Ejemplo n.º 3
0
        public void SetSpeed(TimeSpan time)
        {
            StopAnimation();

            TimelineCollection collection = a.Storyboard.Children;//берём колекцию колекций кадров

            //устанавливаем значения
            (collection[0] as DoubleAnimationUsingKeyFrames).KeyFrames[1].KeyTime = (collection[1] as DoubleAnimationUsingKeyFrames).KeyFrames[1].KeyTime = (collection[2] as DoubleAnimationUsingKeyFrames).KeyFrames[1].KeyTime = (collection[3] as DoubleAnimationUsingKeyFrames).KeyFrames[1].KeyTime = new TimeSpan(0, 0, 0, 0, (int)Math.Round(time.TotalMilliseconds / 2));
            (collection[0] as DoubleAnimationUsingKeyFrames).KeyFrames[2].KeyTime = (collection[2] as DoubleAnimationUsingKeyFrames).KeyFrames[2].KeyTime = time;
            SpeedAnimation = time;
        }
Ejemplo n.º 4
0
        void UpdateScoreAnimation(string targetName)
        {
            // Score Half
            Storyboard.SetTargetName((DependencyObject)_scoreHalfAnimation.Children[0], targetName);

            // Score End
            TimelineCollection timelines = _scoreEndAnimation.Children;

            Storyboard.SetTargetName((DependencyObject)timelines[0], targetName);
            Storyboard.SetTargetName((DependencyObject)timelines[1], targetName);
            Storyboard.SetTargetName((DependencyObject)timelines[2], targetName);
        }
Ejemplo n.º 5
0
        private void ChangeAnimationValue()
        {
            TimelineCollection collection = a.Storyboard.Children;//берём колекцию колекций кадров

            //устанавливаем значения
            (collection[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0].Value = (collection[1] as DoubleAnimationUsingKeyFrames).KeyFrames[0].Value = (collection[0] as DoubleAnimationUsingKeyFrames).KeyFrames[1].Value = X1;
            (collection[2] as DoubleAnimationUsingKeyFrames).KeyFrames[0].Value = (collection[3] as DoubleAnimationUsingKeyFrames).KeyFrames[0].Value = (collection[2] as DoubleAnimationUsingKeyFrames).KeyFrames[1].Value = Y1;

            (collection[0] as DoubleAnimationUsingKeyFrames).KeyFrames[2].Value = X2;
            (collection[1] as DoubleAnimationUsingKeyFrames).KeyFrames[1].Value = X2;
            (collection[2] as DoubleAnimationUsingKeyFrames).KeyFrames[2].Value = Y2;
            (collection[3] as DoubleAnimationUsingKeyFrames).KeyFrames[1].Value = Y2;
        }
Ejemplo n.º 6
0
        public void spin(int degrees)
        {
            DoubleAnimation d = new DoubleAnimation();

            d.From           = 0;
            d.To             = 120;
            d.Duration       = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            d.RepeatBehavior = new RepeatBehavior(1);

            TimelineCollection v = Storyboard1.Children;

            foreach (var vv in v)
            {
                DoubleAnimationUsingKeyFrames dauks = (DoubleAnimationUsingKeyFrames)vv;
                var v3 = dauks.KeyFrames[1].Value = degrees;
            }

            Storyboard1.Begin();
        }
Ejemplo n.º 7
0
        void WinGame(string winPlay)
        {
            for (int row = 0; row < 3; ++row)
            {
                for (int col = 0; col < 3; ++col)
                {
                    _board[row, col].Button.IsEnabled = false;
                }
            }

            _statusMessage = string.Format("Player {0} Wins", _player == Player.First ? 1 : 2);

            TimelineCollection timelines = _winAnimation.Children;

            Storyboard.SetTargetName((DependencyObject)timelines[0], winPlay);
            Storyboard.SetTargetName((DependencyObject)timelines[1], winPlay);
            Storyboard.SetTargetName((DependencyObject)timelines[2], winPlay);

            _progressFadeAnimation.Begin(this);
            _winAnimation.Begin(this);
            _statusHalfAnimation.Begin(this);
        }
Ejemplo n.º 8
0
 public Animation()
 {
     Children = new TimelineCollection();
 }
Ejemplo n.º 9
0
        public ProgressAdorner(UIElement adornedElement) : base(adornedElement)
        {
            VisualChildren = new VisualCollection(this);

            RowDefinitionCollection rows = Grid.RowDefinitions;

            rows.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            rows.Add(new RowDefinition()
            {
                Height = new GridLength(50, GridUnitType.Pixel)
            });
            rows.Add(new RowDefinition()
            {
                Height = new GridLength(25, GridUnitType.Pixel)
            });
            rows.Add(new RowDefinition()
            {
                Height = new GridLength(25, GridUnitType.Pixel)
            });
            rows.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });

            Ellipse Ellipse = new Ellipse()
            {
                Name = "Icon",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Height = 50,
                Width  = 50,
                Stroke = Brushes.Black,
                Fill   = Brushes.RoyalBlue
            };

            Grid.SetRow(Ellipse, 1);

            TriggerCollection Triggers        = Ellipse.Triggers;
            EventTrigger      Event           = new EventTrigger(Ellipse.LoadedEvent);
            BeginStoryboard   BeginStoryboard = new BeginStoryboard();

            Event.Actions.Add(BeginStoryboard);
            Triggers.Add(Event);

            Storyboard Storyboard = new Storyboard();

            BeginStoryboard.Storyboard = Storyboard;
            DoubleAnimation Animation1 = new DoubleAnimation()
            {
                From           = 20.0,
                To             = 50.0,
                Duration       = new Duration(new TimeSpan(TimeSpan.TicksPerSecond)),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };
            DoubleAnimation Animation2 = new DoubleAnimation()
            {
                From           = 20.0,
                To             = 50.0,
                Duration       = new Duration(new TimeSpan(TimeSpan.TicksPerSecond)),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            Storyboard.SetTarget(Animation1, Ellipse);
            Storyboard.SetTarget(Animation2, Ellipse);
            Storyboard.SetTargetProperty(Animation1, new PropertyPath(Ellipse.HeightProperty));
            Storyboard.SetTargetProperty(Animation2, new PropertyPath(Ellipse.WidthProperty));
            TimelineCollection storyboard = Storyboard.Children;

            storyboard.Add(Animation1);
            storyboard.Add(Animation2);

            ProgressBar ProgressBar = new ProgressBar()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Height = 20,
                Width  = 200
            };

            Grid.SetRow(ProgressBar, 2);

            Button Button = new Button()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Width    = 100,
                Height   = 25,
                FontSize = 12,
                Content  = "Cancel"
            };

            Button.Click += new RoutedEventHandler(CancelTask);
            Binding Binding = new Binding("CancelButtonEnabled");

            Binding.Source = this;
            Button.SetBinding(Button.IsEnabledProperty, Binding);

            Loaded += new RoutedEventHandler((sender, e) =>
            {
                Timer ButtonTimer     = new Timer(3000);
                ButtonTimer.Elapsed  += new ElapsedEventHandler((sender2, e2) => { CancelButtonEnabled = true; });
                ButtonTimer.AutoReset = false;
                ButtonTimer.Start();
            });
            Grid.SetRow(Button, 3);

            UIElementCollection GridUIElements = Grid.Children;

            GridUIElements.Add(Ellipse);
            GridUIElements.Add(ProgressBar);
            GridUIElements.Add(Button);
            Brush Brush = Brushes.LightGray.Clone();

            Brush.Opacity   = 0.5;
            Grid.Background = Brush;

            VisualChildren.Add(Grid);
        }