Esempio n. 1
0
        public void AddAnimatedEventToView(int viewTag, string eventName, JObject eventMapping)
        {
            var nodeTag = eventMapping.Value <int>("animatedValueTag");
            var node    = default(AnimatedNode);

            if (!_animatedNodes.TryGetValue(nodeTag, out node))
            {
                throw new InvalidOperationException(
                          Invariant($"Animated node with tag '{nodeTag}' does not exist."));
            }

            var valueNode = node as ValueAnimatedNode;

            if (valueNode == null)
            {
                throw new InvalidOperationException(
                          Invariant($"Animated node connected to event should be of type '{nameof(ValueAnimatedNode)}'."));
            }

            var pathList = eventMapping["nativeEventPath"].ToObject <string[]>();
            var @event   = new EventAnimationDriver(pathList, valueNode);
            var key      = Tuple.Create(viewTag, eventName);

            if (_eventDrivers.ContainsKey(key))
            {
                _eventDrivers[key].Add(@event);
            }
            else
            {
                var drivers = new List <EventAnimationDriver>(1);
                drivers.Add(@event);
                _eventDrivers.Add(key, drivers);
            }
        }