Ejemplo n.º 1
0
        /// <summary>
        /// When adding IntentNodes, check the existing nodes for IntentNodes that are consecutive... if they are consecutive, and the colors match, combine the Intents
        /// </summary>
        /// <param name="intentNodes"></param>
        public void AddRangeCombiner(IEnumerable <IIntentNode> intentNodes)
        {
            //AddRange(intentNodes);
            //return;
            // TODO: it looks like these only support LightingIntents. It should either be made generic, or the class made specific.
            foreach (var node in intentNodes)
            {
                var newIntent = node.Intent as LightingIntent;

                if (newIntent != null)
                {
                    var oldIntentNode = this.FirstOrDefault(nn => nn.EndTime.Equals(node.StartTime));
                    if (oldIntentNode != null)
                    {
                        var oldIntent = oldIntentNode.Intent as LightingIntent;
                        if (oldIntent != null && oldIntent.EndValue.FullColor.ToArgb() == newIntent.StartValue.FullColor.ToArgb() && CreateNewIntent(oldIntent, newIntent))
                        {
                            //Create a new IntentNode to replace the old one with the new values.
                            var lIntent = new LightingIntent(oldIntent.StartValue, newIntent.EndValue, oldIntent.TimeSpan.Add(newIntent.TimeSpan));

                            lIntent.GenericID = ((LightingIntent)oldIntentNode.Intent).GenericID;

                            var intentNode = new IntentNode(lIntent, oldIntentNode.StartTime);

                            this.Remove(oldIntentNode);
                            Add(intentNode);
                            continue;
                        }
                    }
                }

                Add(node);
            }
        }
Ejemplo n.º 2
0
        public static TimeSpan TranslateIntentRelativeTime(TimeSpan intent1RelativeTime, IntentNode intent1,
                                                           IntentNode intent2)
        {
            TimeSpan effectRelativeTime      = GetEffectRelativeTime(intent1RelativeTime, intent1);
            TimeSpan otherIntentRelativeTime = GetIntentRelativeTime(effectRelativeTime, intent2);

            return(otherIntentRelativeTime);
        }