Esempio n. 1
0
        List <AnimationTo> GetBlink(Rect bound, AOrientation orientation, double duration, int blinkTimes = 0)
        {
            List <AnimationTo> result = new List <AnimationTo>();
            int times = blinkTimes;

            if (times == 0)
            {
                this.rand.Next(1, defaultRepeatTimes);
            }

            double xChange = orientation == AOrientation.Horizontal ? 0.1 : 1;
            double yChange = orientation == AOrientation.Vertical ? 0.1 : 1;

            for (int i = 0; i < times; i++)
            {
                Point       ori    = new Point(1, 1);
                Point       pChane = new Point(xChange, yChange);
                int         offset = rand.Next(10, 30);
                AnimationTo at1    = new AnimationTo(duration, pChane);
                AnimationTo at2    = new AnimationTo(duration, ori);
                AnimationTo at3    = new AnimationTo(offset * duration, ori);
                result.Add(at1);
                result.Add(at2);
                result.Add(at3);
            }

            return(result);
        }
Esempio n. 2
0
        private void CreateBlinkAnimation(StrokeCollection strokes, AOrientation oritation)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(1, 1);

            AnimationLibrary.Current.GetBlinkAnimationSync(bound, oritation, 2, 0.2, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Scale, center, from, to, true);
                obj.Begin();
            });
        }
Esempio n. 3
0
        private void CreateShakeAnimation(StrokeCollection strokes, AOrientation oritation)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(bound.Left + bound.Width / 2, bound.Top + bound.Height / 2);

            AnimationLibrary.Current.GetShakeAnimationSync(bound, oritation, 5, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Translate, center, from, to, true);
                obj.Begin();
            });
        }
Esempio n. 4
0
        List <AnimationTo> GetShock(Rect bound, AOrientation orientation, int ShockTimes = 0)
        {
            List <AnimationTo> result = new List <AnimationTo>();
            Point from  = this.GetCenter(bound);
            int   times = ShockTimes;

            if (times == 0)
            {
                this.rand.Next(1, 10);
            }


            double change = 0;

            if (orientation == AOrientation.Horizontal)
            {
                change = (this.rand.NextDouble() + 0.2) * bound.Width;
            }
            else
            {
                change = (this.rand.NextDouble() + 0.2) * bound.Height;
            }

            double backChange = 0 - change;


            for (int i = 0; i < times; i++)
            {
                double ratio = change * (times - i) / times;
                Point  pChane;
                Point  pBack;
                if (orientation == AOrientation.Horizontal)
                {
                    pChane = new Point(from.X + ratio, from.Y);
                    pBack  = new Point(from.X - ratio, from.Y);
                }
                else
                {
                    pChane = new Point(from.X, from.Y + ratio);
                    pBack  = new Point(from.X, from.Y - ratio);
                }

                AnimationTo at1 = new AnimationTo(0.5, pChane);
                AnimationTo at2 = new AnimationTo(0.5, from);
                AnimationTo at3 = new AnimationTo(0.5, pBack);
                AnimationTo at4 = new AnimationTo(0.5, from);
                result.Add(at1);
                result.Add(at2);
                result.Add(at3);
                result.Add(at4);
            }

            return(result);
        }
Esempio n. 5
0
        void GetShakeAnimationBackground(object obj)
        {
            AnimationThread    paramater   = (AnimationThread)obj;
            Rect               bound       = (Rect)(paramater.Paramaters[0]);
            int                shakeTimes  = (int)(paramater.Paramaters[1]);
            AOrientation       orientation = (AOrientation)(paramater.Paramaters[2]);
            List <AnimationTo> jumps       = this.GetShake(bound, orientation, shakeTimes);

            Application.Current.Dispatcher.BeginInvoke((Action)(() =>
            {
                paramater.CompletedEvent(jumps);
            }));
        }
Esempio n. 6
0
        public void GetShakeAnimationSync(Rect bound, AOrientation orientation, int shakeTimes, Action <List <AnimationTo> > completedEvent)
        {
            AnimationThread obj = new AnimationThread();

            obj.Paramaters.Add(bound);
            obj.Paramaters.Add(shakeTimes);
            obj.Paramaters.Add(orientation);
            obj.CompletedEvent = completedEvent;

            Thread thread = new Thread(new ParameterizedThreadStart(this.GetShakeAnimationBackground));

            thread.IsBackground = true;
            thread.Name         = "ShakeAnimation";
            thread.Start(obj);
        }