Exemplo n.º 1
0
    void UpdateQueue(IAnimatable anim)
    {
        if (anim.WaitForCompletion)
            anim.OnDone -= UpdateQueue;

        if (Queue.Count != 0)
        {
            currentAnim = Queue.Dequeue();

            var name = string.IsNullOrEmpty(currentAnim.Name) ? "Unnamed Anim" : currentAnim.Name;

            Log("Play anim: {0}", name);

            if (currentAnim.WaitForCompletion)
                currentAnim.OnDone += UpdateQueue;

            PlayAnim(currentAnim);

            if (!currentAnim.WaitForCompletion)
                UpdateQueue(currentAnim);
        }
        else
        {
            Log("Finished playing anims!");
            ClearQueue();
        }
    }
Exemplo n.º 2
0
		/**
		 * Add a IAnimatable instance (Armature or custom) to this WorldClock instance.
		 * @param	An IAnimatable instance (Armature, WorldClock or custom)
		 */
		public void Add(IAnimatable animatable)
		{
			if (animatable!=null && _animatableList.IndexOf(animatable) == -1)
			{
				_animatableList.Add(animatable);
			}
		}
Exemplo n.º 3
0
 /// <summary>
 /// Adds an object to the juggler.
 /// </summary>
 public void Add(IAnimatable animatable)
 {
     if (animatable != null && !_objects.Contains(animatable))
     {
         _objects.Add(animatable);
         animatable.RemoveFromJugglerEvent += Remove;
     }
 }
Exemplo n.º 4
0
   /// <summary>
   /// Tests if the supplied node has got one or more of the supplied tags set.
   /// </summary>
   public static Boolean HasTag(IAnimatable node, ColorTag tags)
   {
      if (node == null)
         return false;

      ColorTag nodeTag = ColorTags.GetTag(node);
      return (nodeTag & tags) != 0;
   }
 private void FadeImageInstant(IAnimatable image, TimeSpan beginTime, double toValue)
 {
     DoubleAnimation animation = new DoubleAnimation(toValue, new Duration(new TimeSpan(0)))
     {
         BeginTime = beginTime
     };
     image.BeginAnimation(OpacityProperty, animation);
 }
Exemplo n.º 6
0
   /// <summary>
   /// Returns true if the supplied node has a tag set on it.
   /// </summary>
   public static Boolean HasTag(IAnimatable node)
   {
      if (node == null)
         return false;

      ColorTag tag = ColorTags.GetTag(node);
      return tag != ColorTag.None;
   }
Exemplo n.º 7
0
		/// <summary>
		/// Remove an animation and stop the timer if there are none left.
		/// </summary>
		/// <param name="animatable"></param>
		public void RemoveAnimation(IAnimatable animatable)
		{
			durations.Remove(animatable);
			times.Remove(animatable);
			animatable.EndAnimation();
			if (durations.Count == 0)
				timer.Stop();
		}
Exemplo n.º 8
0
		/**
		 * Remove a IAnimatable instance (Armature or custom) from this WorldClock instance.
		 * @param	An IAnimatable instance (Armature or custom)
		 */
		public void Remove(IAnimatable animatable)
		{
			int index = _animatableList.IndexOf(animatable);
			if (index >= 0)
			{
				_animatableList.RemoveAt(index);
			}
		}
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Internal Constructor
        /// </summary>
        /// <param name="clock"></param>
        /// <param name="property"></param>
        /// <param name="target"></param>
        /// <param name="message"></param>
        /// <param name="innerException"></param>
        internal AnimationException(
            AnimationClock clock, DependencyProperty property, IAnimatable target,
            string message, Exception innerException)
            : base(message, innerException)
        {
            _clock = clock;
            _property = property;
            _targetElement = target;
        }
Exemplo n.º 10
0
        /** Adds an object to the juggler. */
        public void add(IAnimatable obj)
        {
            if (obj != null && mObjects.IndexOf(obj) == -1)
            {
                mObjects.Add(obj);

                var dispatcher = obj as EventDispatcher;
                if (dispatcher != null) dispatcher.addEventListener(starling.events.Event.REMOVE_FROM_JUGGLER, onRemove);
            }
        }
Exemplo n.º 11
0
		public AnimatableKey(IAnimatable animatable, string handle)
		{
			if (animatable == null)
			{
				throw new ArgumentNullException(nameof(animatable));
			}

			if (string.IsNullOrEmpty(handle))
			{
				throw new ArgumentException("Argument is null or empty", nameof(handle));
			}

			Animatable = new WeakReference<IAnimatable>(animatable);
			Handle = handle;
		}
Exemplo n.º 12
0
 /// <include file="../../docs/Microsoft.Maui.Controls/AnimationExtensions.xml" path="//Member[@MemberName='Animate'][1]/Docs" />
 public static void Animate(this IAnimatable self, string name, Action <double> callback, uint rate = 16, uint length = 250, Easing easing = null, Action <double, bool> finished = null,
                            Func <bool> repeat = null)
 {
     self.Animate(name, x => x, callback, rate, length, easing, finished, repeat);
 }
Exemplo n.º 13
0
 public TargetKey(IAnimatable target, DependencyProperty targetProperty)
 {
     this.Target         = target;
     this.TargetProperty = targetProperty;
 }
Exemplo n.º 14
0
 public static void Animate(this IAnimatable self, string name, Action <double> callback, double start, double end, uint rate = 16, uint length = 250, Easing?easing = null,
                            Action <double, bool>?finished = null, Func <bool>?repeat = null)
 {
     self.Animate(name, Interpolate(start, end), callback, rate, length, easing, finished, repeat);
 }
Exemplo n.º 15
0
		public void Commit (IAnimatable owner, string name, uint rate = 16, uint length = 250, 
		                    Easing easing = null, Action<double, bool> finished = null, Func<bool> repeat = null)
		{
			owner.Animate (name, this, rate, length, easing, finished, repeat);
		}
Exemplo n.º 16
0
 public static IAnimation <T> Animate <T>(this IAnimatable <T> parent,
                                          IAnimation <float> controller)
 {
     return(new DrivenAnimation <T>(controller, parent));
 }
 public void Update(IAnimatable item)
 {
     item.Animate();
 }
Exemplo n.º 18
0
 protected UIntPtr Convert(IAnimatable anim)
 {
     return gi.Animatable.GetHandleByAnim(anim);
 }
 public ISvGraphNodeReference SvStdTraverseAnimGraph(IIGraphObjectManager gom, IAnimatable owner, int id, uint flags)
 {
     throw new NotImplementedException();
 }
 public int EnumAnimTree(IAnimEnum animEnum, IAnimatable client, int subNum)
 {
     throw new NotImplementedException();
 }
 public bool AssignController(IAnimatable control, int subAnim)
 {
     throw new NotImplementedException();
 }
 public void EndEditParams(IIObjParam ip, uint flags, IAnimatable next)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
 public void DeregisterNextFrame(IAnimatable a)
 {
     remove.Add(a);
 }
Exemplo n.º 24
0
 /// <include file="../../docs/Microsoft.Maui.Controls/AnimationExtensions.xml" path="//Member[@MemberName='Batch']/Docs" />
 public static IDisposable Batch(this IAnimatable self) => new BatchObject(self);
Exemplo n.º 25
0
 public void Dispose()
 {
     _animatable?.BatchCommit();
     _animatable = null;
 }
 public void BeginEditParams(IIObjParam ip, uint flags, IAnimatable prev)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
        //TODO:
        // Perhaps move this to a new class / node control. It's pretty huge.
        // Use MaxLayers static class to manipulate max objects instead of in code here.

        /// <summary>
        /// Isolate selected TreeNodes in Nested Layer Manager.
        /// Any TreeNode that is not isolated is disabled, and the respective node hidden in Max.
        /// </summary>
        /// <param name="sender">An NLMCheckButton that contains a checked property.</param>
        /// <param name="e">NLM Button Event Args, that contain a pointer to the listview.</param>
        public static void onIsolateSelection(Object sender, ClickEventArgs e)
        {
            // If the sender is not an NLMCheckButton, the request has come from somewhere else (right click or shortcut).
            // For this reason, change the check state of the button UI which will raise this event again.
            if (!(sender is NlmCheckButton))
            {
                e.ListView.ButtonPanelLeft.IsolateSelectedButton.Checked = !e.ListView.ButtonPanelLeft.IsolateSelectedButton.Checked;
                return;
            }

            NlmTreeListView listView = e.ListView;
            NlmCheckButton  button   = sender as NlmCheckButton;

            // Pause UI from refreshing.
            try
            {
                listView.BeginUpdate();

                // Isolate selected if button checked.
                if (button.Checked)
                {
                    // This method has some serious processing going on, so hashsets are used to maximise performance.
                    // Calculate all enabled nodes and disabled nodes.
                    HashSet <BaseTreeNode> enabledNodes  = new HashSet <BaseTreeNode>(listView.NodeControl.Query.SelectionAndAllChildNodes);
                    HashSet <BaseTreeNode> disabledNodes = new HashSet <BaseTreeNode>(listView.NodeControl.Query.AllNodes.Where(x => !enabledNodes.Contains(x)));

                    // Disable disabled nodes.
                    listView.DisableObjects(disabledNodes);

                    // Now we need to work out what maxNodes and layers to temporarily hide.
                    // Firstly, get the highest selected objects.
                    IEnumerable <ObjectTreeNode> selectedNodes = listView.NodeControl.Query.SelectedAncestors
                                                                 .Where(x => (x is ObjectTreeNode)).Cast <ObjectTreeNode>();
                    HashSet <IILayer> onLayers = new HashSet <IILayer>();

                    // If objects are selected, we need to ensure that the layer is not hidden.
                    // If any objects are selected, append the layer to the onLayers hashset.
                    foreach (ObjectTreeNode objectTreeNode in selectedNodes)
                    {
                        IINode maxNode = MaxAnimatable.GetAnimByHandle(objectTreeNode.Handle) as IINode;

                        if (maxNode == null)
                        {
                            continue;
                        }

                        IILayer layer = MaxLayers.GetLayer(maxNode);
                        if (!onLayers.Contains(layer))
                        {
                            onLayers.Add(layer);
                        }
                    }

                    // Ensure that the layer is on so that objects are visible.
                    // The layer is only turned on if an object is selected, and no ancestor is selected.
                    // For any object that is not selected, the object needs to be hidden.
                    foreach (IILayer layer in onLayers)
                    {
                        if (layer.IsHidden)
                        {
#if Max2013 || Max2014
                            layer.IsHidden = false;
#endif
#if Max2015
                            layer.Hide(false, false);
#endif
                        }

                        foreach (IINode maxNode in MaxLayers.GetChildNodes(layer))
                        {
                            UIntPtr maxNodeHandle = MaxAnimatable.GetHandleByAnim(maxNode);
                            if (!selectedNodes.Any(x => (x).Handle == maxNodeHandle) && !maxNode.IsObjectHidden)
                            {
                                listView.DisabledHandles.Add(maxNodeHandle);
                                maxNode.Hide(true);
                            }
                        }
                    }

                    // Loop through all layers that should be turned off.
                    // If the layer should be hidden (because it is not in onLayers or in enabledLayers), hide it.
                    IEnumerable <LayerTreeNode> enabledLayers = enabledNodes.Where(x => (x is LayerTreeNode)).Cast <LayerTreeNode>();
                    IEnumerable <IILayer>       offLayers     = MaxLayers.Layers.Where(x => !onLayers.Contains(x));
                    foreach (IILayer layer in offLayers)
                    {
                        UIntPtr layerHandle = MaxAnimatable.GetHandleByAnim(layer);
                        if (!layer.IsHidden && !enabledLayers.Any(x => (x).Handle == layerHandle))
                        {
#if Max2013 || Max2014
                            layer.IsHidden = true;
#endif
#if Max2015
                            layer.Hide(true, false);
#endif
                            listView.DisabledHandles.Add(layerHandle);
                        }
                    }
                }
                // Remove isolation and restore state if unchecked.
                else
                {
                    // Enable all objects.
                    listView.EnableObjects(listView.DisabledObjects);

                    // Turn on all handles that were turned off.
                    foreach (UIntPtr handle in listView.DisabledHandles)
                    {
                        IAnimatable maxAnim  = MaxAnimatable.GetAnimByHandle(handle);
                        IILayer     maxLayer = maxAnim as IILayer;
                        if (maxLayer != null)
                        {
#if Max2013 || Max2014
                            maxLayer.IsHidden = false;
#endif
#if Max2015
                            maxLayer.Hide(false, false);
#endif
                            continue;
                        }
                        IINode maxNode = maxAnim as IINode;
                        if (maxNode != null)
                        {
                            maxNode.Hide(false);
                            continue;
                        }
                    }

                    // Clear list of handles.
                    listView.DisabledHandles.Clear();
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                listView.EndUpdate();
            }
            MaxUI.RedrawViewportsNow();
        }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransitionBuilder"/> class.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="properties">The properties.</param>
 public TransitionBuilder(IAnimatable target, string[] properties)
 {
     _target     = target;
     _properties = properties;
 }
Exemplo n.º 29
0
 private static void DoubleAnimateProperty(string name, IAnimatable animatable, DependencyProperty property, double end, double timespan)
 {
     double num = (double)((DependencyObject)animatable).GetValue(property);
     if (double.IsNaN(num))
     {
         num = 0.0;
     }
     DoubleAnimation animation = new DoubleAnimation(num, end, new Duration(TimeSpan.FromMilliseconds(timespan)))
     {
         FillBehavior = FillBehavior.HoldEnd,
         DecelerationRatio = 0.2
     };
     animatable.BeginAnimation(property, animation);
     animations[name] = animation;
 }
Exemplo n.º 30
0
 public static bool AnimationIsRunning(this IAnimatable self, string handle)
 {
     handle += self.GetHashCode().ToString();
     return(animations.ContainsKey(handle));
 }
Exemplo n.º 31
0
        public static void AnimateKinetic(this IAnimatable self, string name, Func <double, double, bool> callback, double velocity, double drag, Action finished = null)
        {
            Action animate = () => AnimateKineticInternal(self, name, callback, velocity, drag, finished);

            DoAction(self, animate);
        }
Exemplo n.º 32
0
 public AnimationComponent(S subject, IAnimatable <S> animation) : this(subject)
 {
     BeginAnimation(animation);
 }
Exemplo n.º 33
0
		/// <summary>
		/// Register an animation.
		/// </summary>
		/// <param name="animatable">The animating object.</param>
		/// <param name="duration">The duration of the animation.</param>
		public void RegisterAnimation(IAnimatable animatable, double duration)
		{
			durations[animatable] = duration;
			times[animatable] = 0;
			timer.Start();
		}
Exemplo n.º 34
0
 /// <summary>
 /// Plays all animations in the queue.
 /// </summary>
 void PlayAnim(IAnimatable anim)
 {
     anim.Play();
 }
Exemplo n.º 35
0
		/// <summary>
		/// Handles the timer tick.
		/// </summary>
		void OnTick(object sender, ElapsedEventArgs e)
		{
			IAnimatable[] animatables = new IAnimatable[durations.Count];
			durations.Keys.CopyTo(animatables, 0);
			foreach (IAnimatable animatable in animatables)
			{
				times[animatable] += interval;
				animatable.Animate(times[animatable] / durations[animatable]);
				if (times[animatable] >= durations[animatable])
					RemoveAnimation(animatable);
			}
			scene.RemotePaint();
		}
Exemplo n.º 36
0
   /// <summary>
   /// Gets the tag index for the supplied node.
   /// </summary>
   public static ColorTag GetTag(IAnimatable node)
   {
      Throw.IfNull(node, "node");

      IAnimatable targetNode = node;

      //Try to retrieve layer tag (overrides IINode tag).
      IINode iinode = node as IINode;
      if (iinode != null)
      {
         IILayer layer = iinode.GetReference((int)ReferenceNumbers.NodeLayerRef) as IILayer;
         if (layer != null)
         {
            ColorTag layerTag = ColorTags.GetTag(layer);
            if (layerTag != ColorTag.None)
               return layerTag;
         }
      }

      //Get parent layer tag.
      IILayer iilayer = node as IILayer;
      if (iilayer != null)
      {
         IILayer parent = NestedLayers.GetParent(iilayer);
         if (parent != null)
         {
            ColorTag layerTag = ColorTags.GetTag(parent);
            if (layerTag != ColorTag.None)
               return layerTag;
         }
      }

      //Retrieve the animatable's own tag.
      IAppDataChunk chunk = node.GetAppDataChunk(ColorTags.classID, SClass_ID.Utility, 0);
      if (chunk == null || chunk.Data == null || chunk.Data.Length == 0)
         return ColorTag.None;
      else
         return (ColorTag)chunk.Data[0];
   }
Exemplo n.º 37
0
 /// <include file="../../docs/Microsoft.Maui.Controls/Animation.xml" path="//Member[@MemberName='Commit']/Docs" />
 public void Commit(IAnimatable owner, string name, uint rate = 16, uint length = 250, Easing easing = null, Action <double, bool> finished = null, Func <bool> repeat = null)
 {
     owner.Animate(name, this, rate, length, easing, finished, repeat);
 }
Exemplo n.º 38
0
        public static void DeleteNode(UIntPtr nodeHandle)
        {
            IAnimatable node = MaxAnimatable.GetAnimByHandle(nodeHandle);

            DeleteNode(node as IINode);
        }
Exemplo n.º 39
0
        /// <include file="../../docs/Microsoft.Maui.Controls/AnimationExtensions.xml" path="//Member[@MemberName='AnimationIsRunning']/Docs" />
        public static bool AnimationIsRunning(this IAnimatable self, string handle)
        {
            var key = new AnimatableKey(self, handle);

            return(s_animations.ContainsKey(key));
        }
Exemplo n.º 40
0
		/** 
		 * Returns true if the IAnimatable instance is contained by WorldClock instance.
		 * @param	An IAnimatable instance (Armature or custom)
		 * @return true if the IAnimatable instance is contained by WorldClock instance.
		 */
		public bool Contains(IAnimatable animatable)
		{
			return _animatableList.IndexOf(animatable) >= 0;
		}
Exemplo n.º 41
0
 public BatchObject(IAnimatable animatable)
 {
     _animatable = animatable;
     _animatable?.BatchBegin();
 }
 /// <summary>
 /// Initializes a new Animatable object with the specified owner input parameter.
 /// </summary>
 /// <param name="owner">The IAnimatable object to be animatable.</param>
 public Animatable(IAnimatable owner)
 {
     Owner = owner;
 }
Exemplo n.º 43
0
 public System.Int64 Convert(IAnimatable obj)
 {
     return (System.Int64)gi.Animatable.GetHandleByAnim(obj);
 }
Exemplo n.º 44
0
 static void DoAction(IAnimatable self, Action action)
 {
     action();
 }
Exemplo n.º 45
0
        /** Removes an object from the juggler. */
        public void remove(IAnimatable obj)
        {
            if (obj == null) return;

            var dispatcher = obj as EventDispatcher;
            if (dispatcher != null) dispatcher.removeEventListener(starling.events.Event.REMOVE_FROM_JUGGLER, onRemove);

            var index = mObjects.IndexOf(obj);
            if (index != -1) mObjects[index] = null;
        }
Exemplo n.º 46
0
 protected GenericAnimationBuilder(AnimateThis animator, IAnimatable animatable)
 {
     this.animator   = animator;
     this.animatable = animatable;
 }
Exemplo n.º 47
0
 /** Determines if an object has been added to the juggler. */
 public bool contains(IAnimatable obj)
 {
     return mObjects.IndexOf(obj) != -1;
 }
Exemplo n.º 48
0
 public static UIntPtr GetHandleByAnim(IAnimatable anim)
 {
     return(GlobalInterface.Instance.Animatable.GetHandleByAnim(anim));
 }
Exemplo n.º 49
0
 /// <summary>
 /// アニメーション対象を設定します。
 /// </summary>
 public static void SetTarget(DependencyObject target, IAnimatable value)
 {
     target.SetValue(TargetProperty, value);
 }
Exemplo n.º 50
0
 /// <summary>
 /// Sets the target of an animation.
 /// </summary>
 /// <param name="dependencyObject">The target object for the attached property.</param>
 /// <param name="iAnimatable">The value of the attached property.</param>
 public static void SetTargetObject(DependencyObject dependencyObject, IAnimatable iAnimatable)
 {
     dependencyObject.SetValue(Storyline.TargetObjectProperty, iAnimatable);
 }
Exemplo n.º 51
0
 /// <summary>
 /// Animates the opacity of the specified animatable object.
 /// </summary>
 /// <param name="obj">
 /// The animatable object.
 /// </param>
 /// <param name="targetOpacity">
 /// The target opacity.
 /// </param>
 /// <param name="animationTime">
 /// The animation time.
 /// </param>
 private static void AnimateOpacity(IAnimatable obj, double targetOpacity, double animationTime)
 {
     var a = new DoubleAnimation(targetOpacity, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                 {
                     AccelerationRatio
                         = 0.3,
                     DecelerationRatio
                         = 0.5
                 };
     obj.BeginAnimation(OpacityProperty, a);
 }
Exemplo n.º 52
0
 /// <summary>
 /// Removes an object from the juggler.
 /// </summary>
 public void Remove(IAnimatable animatable)
 {
     _objects.Remove(animatable);
     animatable.RemoveFromJugglerEvent -= Remove;
 }
 private void FadeImage(IAnimatable image, TimeSpan duration, double toValue)
 {
     DoubleAnimation animation = new DoubleAnimation(toValue, duration);
     image.BeginAnimation(OpacityProperty, animation);
 }
Exemplo n.º 54
0
 /// <summary>
 /// Determines if an object has been added to the juggler.
 /// </summary>
 public bool Contains(IAnimatable animatable)
 {
     return _objects.Contains(animatable);
 }
 private void SetZIndex(IAnimatable image, TimeSpan beginTime, int value)
 {
     Int32Animation animation = new Int32Animation(value, new Duration(new TimeSpan(0))) { BeginTime = beginTime };
     image.BeginAnimation(Panel.ZIndexProperty, animation);
 }
Exemplo n.º 56
0
 /// <summary>
 /// Delays the execution of a certain method. Returns a proxy object on which to call the method
 /// instead. Execution will be delayed until 'time' has passed.
 /// </summary>
 public object DelayInvocationOf(IAnimatable animatable, float time)
 {
     //TODO DelayedInvocation delayedInv = DelayedInvocation.InvocationWithTarget(target, time);
     //AddObject(delayedInv);
     //return delayedInv;
     return null;
 }
Exemplo n.º 57
0
 /// <summary>
 /// Plays all animations in the queue.
 /// </summary>
 void PlayAnim(IAnimatable anim)
 {
     anim.Play();
 }
Exemplo n.º 58
0
        public void AdvanceTime(float seconds)
        {
            if (seconds > 0.0)
            {
                seconds *= _speed;

                _elapsedTime += seconds;

                // we need work with a copy, since user-code could modify the collection while enumerating
                IAnimatable[] objectsCopy = new IAnimatable[_objects.Count];
                _objects.CopyTo(objectsCopy);

                foreach (IAnimatable animatable in objectsCopy)
                {
                    animatable.AdvanceTime(seconds);
                }
            }
            else if (seconds < 0.0)
            {
                throw new Exception("time must be positive");
            }
        }
Exemplo n.º 59
0
 public static void MarkAsInstance(this IAnimatable node)
 {
     node.AddAppDataChunk(Loader.Class_ID, SClass_ID.Basenode, 1, new byte[] { 1 });
 }
Exemplo n.º 60
0
 public static IAnimation <T> Drive <T>(this IAnimation <float> controller,
                                        IAnimatable <T> tween)
 {
     return(tween.Animate(controller));
 }