示例#1
0
        /// <summary>
        /// Call Update methods of animations and remove them if needed
        /// </summary>
        public static void Update()
        {
            if (_animationsPending == 0)
            {
                IsAnimating = false;
                return;
            }

            IsAnimating = true;
            List <int> indexesToRemove = new List <int>();

            for (int i = 0; i < Animations.Count; ++i)
            {
                IAnimate a = Animations[i];

                if (!a.IsActive())
                {
                    indexesToRemove.Add(i);
                    continue;
                }

                a.Update();
            }

            for (int i = 0; i < indexesToRemove.Count; ++i)
            {
                Animations.RemoveAt(indexesToRemove[i] - i);
            }

            _animationsPending -= indexesToRemove.Count;
        }
示例#2
0
 void Start()
 {
     con      = GetComponent <INoiseCon>();
     anim_con = (IAnimate)con;
     if (anim_con == null)
     {
         Debug.Log("not animatable");
     }
 }
示例#3
0
        public Animator Play <T>(IAnimate <T> anim)
        {
            if (!(anim is AnimateHandler <T>))
            {
                throw new ArgumentException("Invalid Animation Object");
            }

            AnimateHandler <T> handler = (AnimateHandler <T>)anim;

            mTaskFactory.StartNew(HandleAnimation, handler.AnimationsHeap);
            return(this);
        }
示例#4
0
 public static void ParseAnimatableChildren(UIElement child, ref List <UIElement> AnimatableChildren)
 {
     if (child is IAnimate)
     {
         IAnimate AnimateChild = (IAnimate)child;
         if (AnimateChild.HasPageEntranceAnimation())// dont do the page either
         {
             if (AnimateChild.HasAnimateChildren())
             {
                 List <UIElement> AnimatableGrandChildren = AnimateChild.AnimatableChildren();
                 foreach (UIElement grandChild in AnimatableGrandChildren)
                 {
                     if (null != grandChild)// headers can have null ledes so check pls
                     {
                         ParseAnimatableChildren(grandChild, ref AnimatableChildren);
                     }
                 }
             }
             else
             {
                 AnimatableChildren.Add(child);
             }
         }
     }
     else
     {
         // canvas and other stuff that can contain children
         if (child is Canvas)
         {
             Canvas canvasChild = (Canvas)child;
             foreach (UIElement uiElement in canvasChild.Children)
             {
                 if (uiElement is IAnimate)
                 {
                     ParseAnimatableChildren(uiElement, ref AnimatableChildren);
                 }
             }
         }
         // canvas and other stuff that can contain children
         if (child is Grid)
         {
             Grid gridChild = (Grid)child;
             foreach (UIElement uiElement in gridChild.Children)
             {
                 if (uiElement is IAnimate)
                 {
                     ParseAnimatableChildren(uiElement, ref AnimatableChildren);
                 }
             }
         }
     }
 }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static IAnimate Instance()
 {
     if (_instance == null)
     {
         lock (Lock)
         {
             if (_instance == null)
             {
                 _instance = new Animate();
             }
         }
     }
     return(_instance);
 }
示例#6
0
        public Form1()
        {
            InitializeComponent();
            _graphics = CreateGraphics();

            //_animation = new AnimateAngular();
            //_animation = new AnimateDistance();
            _animation = new AnimateSparkle();

            _timer          = new Timer();
            _timer.Tick    += Timer_Tick;
            _timer.Interval = 10;
            _timer.Start();

            Paint         += Form1_Paint;
            _snowflakeLeds = new SnowflakeLeds();
        }
示例#7
0
        static void Main(string[] args)
        {
            Context.Singleton.RegisterFactory <ConfigManager>();
            Context.Singleton.RegisterFactory <Request>();
            Context.Singleton.RegisterFactory <Animator>();

            Console.WriteLine(Context.Singleton.GetSubsystem <ConfigManager>().Load <DatabaseConfig>("Data/db.conf.json").ToJson());
            Context.Singleton.AddListener("E_TEST", TestEvent).SendEvent("E_TEST");
            Context.Singleton.GetSubsystem <Request>()
            .Get("https://jsonplaceholder.typicode.com/todos/1").Success((url, data) => Console.WriteLine(data));
            IAnimate <Foo> anim = Context.Singleton.GetSubsystem <Animator>().Bind(new Foo());

            anim.Begin().SetDuration(1000).From(x => x.X).To(x => 100).SetEasingType(new SineEasing()).SetOnAnimateListener((source, from, to, alpha) => {
                Console.Write($"{source.X}, ");
            }).End();
            Context.Singleton.GetSubsystem <Animator>().Play(anim);
            Console.ReadKey();
        }
示例#8
0
        // keep incase we dont need to traverse the visual tree recursively (itll output last first so be aware)
        //static private IEnumerable<DependencyObject> FindInputElements(DependencyObject parent)
        //{
        //    if (parent == null)
        //        yield break;

        //    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
        //    {
        //        DependencyObject o = VisualTreeHelper.GetChild(parent, i);

        //        foreach (DependencyObject obj in FindInputElements(o))

        //            yield return (UIElement)obj;

        //    }

        //    yield return parent;
        //}

        public static void PerformPageEntranceAnimation(Page page)
        {
            //traverse the visual tree of a page and perform the fade in and translate in on each frameworkitem
            // general idea from EntranceThemeTransition and rebuilt as a behavior here
            // https://jeremiahmorrill.wordpress.com/2014/04/02/entrancethemetransitionbehavior-behavior-for-wpf/
            List <Storyboard> StoryBoardCollection = new List <Storyboard>();
            List <UIElement>  AnimatableChildren   = new List <UIElement>();
            double            StaggerDelay         = 0.0;
            double            TotalStagger         = (((Windows.UI.Xaml.Controls.Panel)page.Content).Children.Count * 100d) + 500d;
            double            distanceToTranslate;

            // Traverses the first content area on the page in linear order to show everything
            foreach (UIElement child in ((Windows.UI.Xaml.Controls.Panel)page.Content).Children)
            {
                if (null != child && child != page && (child is IAnimate || child is Canvas || child is Grid))// handle special case for canvas// dont do the page either
                {
                    ParseAnimatableChildren(child, ref AnimatableChildren);
                }
            }
            TotalStagger = AnimatableChildren.Count * 100d + 500d;
            foreach (UIElement OrderedChild in AnimatableChildren)
            {
                Storyboard storyboard           = null;
                IAnimate   AnimatedOrderedChild = (IAnimate)OrderedChild;
                distanceToTranslate = 100 * (AnimatedOrderedChild.Direction() != AnimationDirection.Left ? 1 : -1);
                storyboard          = CreateEasingAnimation(OrderedChild, "Opacity", 0.0, 0.0, 1.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d));
                StoryBoardCollection.Add(storyboard);
                if (AnimatedOrderedChild.HasPageEntranceTranslation())
                {
                    storyboard = CreateTranslateAnimation(OrderedChild, "X", distanceToTranslate, distanceToTranslate, 0.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d));
                    StoryBoardCollection.Add(storyboard);
                }

                StaggerDelay += 100;
            }


            foreach (Storyboard SB in StoryBoardCollection)
            {
                SB.Begin();
            }
        }
示例#9
0
 public void UpdateColors(IAnimate animateAngular)
 {
     animateAngular.UpdateColors(_ledCollection);
 }
示例#10
0
 private void Awake()
 {
     _animate = GetComponent <IAnimate>();
 }
示例#11
0
 public void Add(IAnimate animation)
 {
     animations.Add(animation);
     animation.Init();
 }
示例#12
0
 private void Start()
 {
     _animate = GetComponent <IAnimate>();
     _button  = GetComponent <Button>();
     _button.onClick.AddListener(() => { OnClick(); });
 }
示例#13
0
 private void Start()
 {
     _animate = GetComponent <IAnimate>();
 }
    void Awake()
    {
        progressAnimation = animationComponent as IAnimate;

        UnityEngine.Assertions.Assert.IsNotNull(progressAnimation);
    }
示例#15
0
 /// <summary>
 /// Add an animation to the queue
 /// </summary>
 public static void Add(IAnimate animation)
 {
     Animations.Add(animation);
     ++_animationsPending;
 }
示例#16
0
 public static void RegisterAnim3d(IAnimate anim)
 {
     _anim3d = anim;
 }
示例#17
0
 public void Start()
 {
     this._translation = GetComponent <ITranslation>();
     this._rotate      = GetComponent <IRotate>();
     this._animate     = GetComponent <IAnimate>();
 }