Exemplo n.º 1
1
        /// <summary>
        /// Starts the particle running or restarts the particle if it has expired
        /// </summary>
        /// <param name="rerun"></param>
        private void Run(bool rerun)
        {
            // only init the particle if it hasn't been run yet
            if (!rerun)
            {
                NameScope.SetNameScope(this, new NameScope());
                this.Name = String.Format("p{0}", Particle.ParticleNo++);
                this.RegisterName(this.Name, this);
                this.Width = ParticleSystem.random.NextDouble(Owner.MinParticleWidth, Owner.MaxParticleWidth);
                this.Height = ParticleSystem.random.NextDouble(Owner.MinParticleHeight, Owner.MaxParticleHeight);
                this.particleSolidColorBrush = new SolidColorBrush(Colors.White);
                this.RegisterName(String.Format("{0}Brush", this.Name), particleSolidColorBrush);
                this.Background = particleSolidColorBrush;
            }

            // create the storyboard for this particle and hold its end behavior
            mStoryboard = new Storyboard();
            mStoryboard.FillBehavior = FillBehavior.HoldEnd; 

            // create a parallel timeline for the the opacity and background changes.
            ParallelTimeline pt = new ParallelTimeline(TimeSpan.FromSeconds(0));

            // the timeline for the opacity change using the particle Start and End Opacity
            DoubleAnimation daOpacity = new DoubleAnimation(StartOpacity, EndOpacity, 
                                                            new Duration(TimeSpan.FromSeconds(this.LifeSpan)));
            Storyboard.SetTargetName(daOpacity, this.Name);
            Storyboard.SetTargetProperty(daOpacity, new PropertyPath(Particle.OpacityProperty));

            // the timeline for the background color change using a colorkeyframecollection
            ColorAnimationUsingKeyFrames daBackground = new ColorAnimationUsingKeyFrames();
            daBackground.Duration = new Duration(TimeSpan.FromSeconds(this.LifeSpan));
            daBackground.KeyFrames = BackgroundColors;
            Storyboard.SetTargetName(daBackground, String.Format("{0}Brush", this.Name));
            Storyboard.SetTargetProperty(daBackground, new PropertyPath(SolidColorBrush.ColorProperty));
            pt.Children.Add(daOpacity);
            pt.Children.Add(daBackground);
            mStoryboard.Children.Add(pt);

            // the first time this is run begin the storyboard on load.
            if (!rerun)
            {
                this.Loaded += delegate(object sender, RoutedEventArgs args)
                                   {
                                       mStoryboard.Begin(this, true);
                                   };
            }            
                        
            mIsAlive = true;
        }
Exemplo n.º 2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.spContr = ((LEDX.Components.UiController)(target));

            #line 7 "..\..\..\Components\UIController.xaml"
                this.spContr.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.spContr_PreviewMouseDown);

            #line default
            #line hidden

            #line 7 "..\..\..\Components\UIController.xaml"
                this.spContr.Loaded += new System.Windows.RoutedEventHandler(this.spContr_Loaded);

            #line default
            #line hidden

            #line 7 "..\..\..\Components\UIController.xaml"
                this.spContr.IsVisibleChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.SpContr_IsVisibleChanged);

            #line default
            #line hidden
                return;

            case 2:
                this.rView = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 3:
                this.AnimColorBrush = ((System.Windows.Media.SolidColorBrush)(target));
                return;

            case 4:
                this.sBrd = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 5:
                this.clAni = ((System.Windows.Media.Animation.ColorAnimationUsingKeyFrames)(target));
                return;

            case 6:
                this.btAdd = ((System.Windows.Controls.Button)(target));
                return;

            case 7:
                this.tgbSel = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 8:
                this.imUnch = ((System.Windows.Controls.Image)(target));
                return;

            case 9:
                this.imСh = ((System.Windows.Controls.Image)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(ColorAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (_areKeyTimesValid &&
                sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone();
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (ColorKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (ColorKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }
Exemplo n.º 4
0
        public void ColorAnimationKeyFrameRepeatTest()
        {
            ColorAnimationUsingKeyFrames animation;

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = Color.FromUInt32(0) });
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)), Value = Color.FromUInt32(100) });
            animation.Duration = new Duration(TimeSpan.FromSeconds(2));
            animation.RepeatBehavior = RepeatBehavior.Forever;

            TestRootClock rootClock = new TestRootClock();
            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();
            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(Color.FromUInt32(10), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(Color.FromUInt32(90), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(Color.FromUInt32(100), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1.9));
            Assert.AreEqual(Color.FromUInt32(100), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.1));
            Assert.AreEqual(Color.FromUInt32(10), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.9));
            Assert.AreEqual(Color.FromUInt32(90), (Color)animation.GetCurrentValue(0.0, 0.0, clock));
        }
Exemplo n.º 5
0
        public void ColorAnimationKeyFrameTest()
        {
            ColorAnimationUsingKeyFrames animation;

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new DiscreteColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)), Value = Color.FromUInt32(20) });
            animation.KeyFrames.Add(new DiscreteColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)), Value = Color.FromUInt32(40) });
            animation.KeyFrames.Add(new DiscreteColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.8)), Value = Color.FromUInt32(60) });

            ColorAnimationBasicTest(animation, Color.FromUInt32(50), Color.FromUInt32(150), Color.FromUInt32(50), Color.FromUInt32(40), Color.FromUInt32(60));

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new DiscreteColorKeyFrame { KeyTime = KeyTime.FromPercent(0.2), Value = Color.FromUInt32(40) });
            animation.KeyFrames.Add(new DiscreteColorKeyFrame { KeyTime = KeyTime.FromPercent(0.8), Value = Color.FromUInt32(60) });

            ColorAnimationBasicTest(animation, Color.FromUInt32(50), Color.FromUInt32(150), Color.FromUInt32(50), Color.FromUInt32(40), Color.FromUInt32(60));

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)), Value = Color.FromUInt32(40) });
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.8)), Value = Color.FromUInt32(60) });

            ColorAnimationBasicTest(animation, Color.FromUInt32(50), Color.FromUInt32(150), Color.FromUInt32(50), Color.FromUInt32(50), Color.FromUInt32(60));

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromPercent(0.2), Value = Color.FromUInt32(20) });
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromPercent(0.2), Value = Color.FromUInt32(40) });
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromPercent(0.8), Value = Color.FromUInt32(60) });

            ColorAnimationBasicTest(animation, Color.FromUInt32(50), Color.FromUInt32(150), Color.FromUInt32(50), Color.FromUInt32(50), Color.FromUInt32(60));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.CloneCore(System.Windows.Freezable)">Freezable.CloneCore</see>.
        /// </summary>
        protected override void CloneCore(Freezable sourceFreezable)
        {
            ColorAnimationUsingKeyFrames sourceAnimation = (ColorAnimationUsingKeyFrames)sourceFreezable;

            base.CloneCore(sourceFreezable);

            CopyCommon(sourceAnimation, /* isCurrentValueClone = */ false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>.
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            ColorAnimationUsingKeyFrames sourceAnimation = (ColorAnimationUsingKeyFrames)source;

            base.GetCurrentValueAsFrozenCore(source);

            CopyCommon(sourceAnimation, /* isCurrentValueClone = */ true);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 创建Color类型的关键帧动画
 /// </summary>
 /// <param name="Model">动画数据</param>
 /// <returns></returns>
 public static ColorAnimationUsingKeyFrames BuildColorKeyFramesAnimation(ColorKeyFramesModel Model)
 {
     ColorAnimationUsingKeyFrames _colorAnimation = new ColorAnimationUsingKeyFrames();
     _colorAnimation.Duration = (Model.Duration==0? Duration.Automatic:new Duration(TimeSpan.FromSeconds(Model.Duration)));  
     _colorAnimation.AutoReverse = Model.AutoReverse;
     _colorAnimation.BeginTime = TimeSpan.FromSeconds(Model.BeginTime);
     _colorAnimation.FillBehavior = Model.FillBehavior;
     _colorAnimation.RepeatBehavior = Model.RepeatBehavior;
     _colorAnimation.SpeedRatio = Model.SpeedRatio;
     foreach (var item in Model.KeyFrames)
     {
         _colorAnimation.KeyFrames.Add(CreateColorKeyFrmas(item));
     }
     Storyboard.SetTarget(_colorAnimation, Model.Target);
     Storyboard.SetTargetProperty(_colorAnimation, new PropertyPath(Model.PropertyPath));
     return _colorAnimation;
 }
Exemplo n.º 9
0
 protected override void OnRender(DrawingContext drawingContext)
 {
     var brush = new SolidColorBrush(Colors.Black);
     var animation = new ColorAnimationUsingKeyFrames();
     animation.KeyFrames.Add(new LinearColorKeyFrame(Colors.Black, KeyTime.FromPercent(0)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(Colors.LightGray, KeyTime.FromPercent(1)));
     animation.Duration = new Duration(TimeSpan.FromSeconds(1));
     animation.AutoReverse = true;
     animation.RepeatBehavior = RepeatBehavior.Forever;
     brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
     var rect = new Rect(0, 0, ActualWidth, ActualHeight);
     var typeface = new Typeface(new FontFamily("Calibri"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal );
     var text = new FormattedText("Loading...", Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight, typeface,
         15, brush);
     drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(200, 255, 255, 255)), null, rect);
     drawingContext.DrawText(text, new Point((ActualWidth-text.Width)/2.0, (ActualHeight-text.Height)/2.0));
 }
Exemplo n.º 10
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.effLigthing = ((LEDX.Components.Effects.LigthImitationEffect)(target));
                return;

            case 2:
                this.sBrd = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 3:
                this.clAni = ((System.Windows.Media.Animation.ColorAnimationUsingKeyFrames)(target));
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and 
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(ColorAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {    
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (   _areKeyTimesValid 
                && sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone(); 
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (ColorKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (ColorKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }
 private ColorAnimationUsingKeyFrames getColorAnimationFrames(Color firstColor, Color secondColor)
 {
     ColorAnimationUsingKeyFrames animationFrames = new ColorAnimationUsingKeyFrames();
     for (int i = 1; i < 6; i++)
     {
         if (i % 2 == 0)
         {
             DiscreteColorKeyFrame frame=new DiscreteColorKeyFrame();
             frame.KeyTime=new TimeSpan(0,0,0,0,i*250);
             frame.Value=firstColor;
             animationFrames.KeyFrames.Add(frame);
         }
         else
         {
             DiscreteColorKeyFrame frame = new DiscreteColorKeyFrame();
             frame.KeyTime = new TimeSpan(0, 0, 0, 0, i * 250);
             frame.Value = secondColor;
             animationFrames.KeyFrames.Add(frame);
         }
     }
     return animationFrames;
 }
Exemplo n.º 13
0
        private void InitializeTurnOnStoryBoardAnimation()
        {
            ColorAnimationUsingKeyFrames ckf = new ColorAnimationUsingKeyFrames();

            Storyboard.SetTargetProperty(TurnOnAnimation, new PropertyPath("Color"));
            Storyboard.SetTarget(TurnOnAnimation, backgroundBrush);

            LinearColorKeyFrame lck0 = new LinearColorKeyFrame();
            lck0.KeyTime = TimeSpan.FromMilliseconds(300);
            lck0.Value = accentColor;

            ckf.KeyFrames.Add(lck0);
            TurnOnAnimation.Children.Add(ckf);
        }
Exemplo n.º 14
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.spContr = ((LEDX.Components.UiController)(target));
     
     #line 7 "..\..\..\Components\UIController.xaml"
     this.spContr.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.spContr_PreviewMouseDown);
     
     #line default
     #line hidden
     
     #line 7 "..\..\..\Components\UIController.xaml"
     this.spContr.Loaded += new System.Windows.RoutedEventHandler(this.spContr_Loaded);
     
     #line default
     #line hidden
     
     #line 7 "..\..\..\Components\UIController.xaml"
     this.spContr.IsVisibleChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.SpContr_IsVisibleChanged);
     
     #line default
     #line hidden
     return;
     case 2:
     this.rView = ((System.Windows.Shapes.Rectangle)(target));
     return;
     case 3:
     this.AnimColorBrush = ((System.Windows.Media.SolidColorBrush)(target));
     return;
     case 4:
     this.sBrd = ((System.Windows.Media.Animation.Storyboard)(target));
     return;
     case 5:
     this.clAni = ((System.Windows.Media.Animation.ColorAnimationUsingKeyFrames)(target));
     return;
     case 6:
     this.btAdd = ((System.Windows.Controls.Button)(target));
     return;
     case 7:
     this.tgbSel = ((System.Windows.Controls.Primitives.ToggleButton)(target));
     return;
     case 8:
     this.imUnch = ((System.Windows.Controls.Image)(target));
     return;
     case 9:
     this.imСh = ((System.Windows.Controls.Image)(target));
     return;
     }
     this._contentLoaded = true;
 }
Exemplo n.º 15
0
        private void CreatePhaseBackgroundAnimation()
        {
            _phaseBackgroundAnimation = new Storyboard();
            _backgroundBrush = (SolidColorBrush)LayoutRoot.Background;
            ColorAnimationUsingKeyFrames ckf = new ColorAnimationUsingKeyFrames();

            Storyboard.SetTargetProperty(_phaseBackgroundAnimation, new PropertyPath("Color"));
            Storyboard.SetTarget(_phaseBackgroundAnimation, _backgroundBrush);

            LinearColorKeyFrame lck0 = new LinearColorKeyFrame();
            lck0.KeyTime = TimeSpan.FromMilliseconds(500);
            lck0.Value = ColorConverter.Convert(App.GameManager.GameData.GameSettings.BackgroundColor);

            ckf.KeyFrames.Add(lck0);
            _phaseBackgroundAnimation.Children.Add(ckf);
        }
Exemplo n.º 16
0
            public HighlightField()
            {
                color = new SolidColorBrush(Colors.Transparent);

                ColorAnimationUsingKeyFrames animColor = new ColorAnimationUsingKeyFrames();
                animColor.KeyFrames.Add(new LinearColorKeyFrame() { KeyTime = TimeSpan.FromSeconds(0.0), Value = Colors.Yellow });
                animColor.KeyFrames.Add(new LinearColorKeyFrame() { KeyTime = time.TimeSpan, Value = Colors.Transparent });
                animColor.Duration = time;

                story.Children.Add(animColor);
                Storyboard.SetTarget(animColor, this.color);
                Storyboard.SetTargetProperty(animColor, new PropertyPath("(Brush.Color)"));
            }
Exemplo n.º 17
0
 public static ColorAnimationUsingKeyFrames GetCritColorAnimation(Color displayColor)
 {
     var animation = new ColorAnimationUsingKeyFrames();
     animation.KeyFrames.Add(new LinearColorKeyFrame(ColorPalette.WhiteBrightColor, TimerUtility.TicksToTimespan(4)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(displayColor, TimerUtility.TicksToTimespan(8)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(ColorPalette.BlackColor, TimerUtility.TicksToTimespan(12)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(displayColor, TimerUtility.TicksToTimespan(16)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(ColorPalette.WhiteBrightColor, TimerUtility.TicksToTimespan(20)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(displayColor, TimerUtility.TicksToTimespan(24)));
     animation.FillBehavior = FillBehavior.Stop;
     return animation;
 }
Exemplo n.º 18
0
        private void InitializeFlashOnStoryBoardAnimation()
        {
            ColorAnimationUsingKeyFrames ckf = new ColorAnimationUsingKeyFrames();

            Storyboard.SetTargetProperty(FlashOnAnimation, new PropertyPath("Color"));
            Storyboard.SetTarget(FlashOnAnimation, backgroundBrush);

            EasingColorKeyFrame lck0 = new EasingColorKeyFrame();
            lck0.KeyTime = TimeSpan.FromMilliseconds(0);
            lck0.Value = accentColor;

            EasingColorKeyFrame lck1 = new EasingColorKeyFrame();
            lck1.KeyTime = TimeSpan.FromMilliseconds(600);
            lck1.Value = backgroundColor;

            ckf.KeyFrames.Add(lck0);
            ckf.KeyFrames.Add(lck1);
            FlashOnAnimation.Children.Add(ckf);
        }
Exemplo n.º 19
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.effLigthing = ((LEDX.Components.Effects.LigthImitationEffect)(target));
     return;
     case 2:
     this.sBrd = ((System.Windows.Media.Animation.Storyboard)(target));
     return;
     case 3:
     this.clAni = ((System.Windows.Media.Animation.ColorAnimationUsingKeyFrames)(target));
     return;
     }
     this._contentLoaded = true;
 }