/// <summary> /// Initializes a new instance of the <see cref="PrioritizedTrigger"/> structure. /// </summary> /// <param name="trigger">The trigger being applied.</param> /// <param name="selector">The selector which caused the trigger to be applied.</param> /// <param name="priority">The trigger's priority.</param> /// <param name="index">The index of the trigger's rule set within its style sheet.</param> public PrioritizedTrigger(UvssTrigger trigger, UvssSelector selector, Int32 priority, Int32 index) { this.Trigger = trigger; this.Selector = selector; this.Priority = priority; this.Index = index; }
/// <summary> /// Adds a trigger to the prioritizer. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="selector">The selector which caused this style to be considered.</param> /// <param name="navigationExpression">The navigation expression associated with the style.</param> /// <param name="trigger">The trigger to add to the prioritizer.</param> /// <param name="index">The index of the trigger's rule set within the style sheet.</param> public void Add(UltravioletContext uv, UvssSelector selector, NavigationExpression? navigationExpression, UvssTrigger trigger, Int32 index) { Contract.Require(uv, nameof(uv)); var key = new StyleKey(trigger.CanonicalName, navigationExpression); var priority = CalculatePriorityFromSelector(selector, false); PrioritizedTrigger existing; if (!triggers.TryGetValue(key, out existing)) { triggers[key] = new PrioritizedTrigger(trigger, selector, priority, index); } else { var comparison = selector.ComparePriority(existing.Selector); if (comparison == 0 && index > existing.Index) comparison = 1; if (comparison > 0 && (trigger.IsImportant || !existing.Trigger.IsImportant)) { triggers[key] = new PrioritizedTrigger(trigger, selector, priority, index); } } }
/// <summary> /// Adds a trigger to the prioritizer. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="selector">The selector which caused this style to be considered.</param> /// <param name="navigationExpression">The navigation expression associated with the style.</param> /// <param name="trigger">The trigger to add to the prioritizer.</param> /// <param name="index">The index of the trigger's rule set within the style sheet.</param> public void Add(UltravioletContext uv, UvssSelector selector, NavigationExpression?navigationExpression, UvssTrigger trigger, Int32 index) { Contract.Require(uv, nameof(uv)); var key = new StyleKey(trigger.CanonicalName, navigationExpression); var priority = CalculatePriorityFromSelector(selector, false); PrioritizedTrigger existing; if (!triggers.TryGetValue(key, out existing)) { triggers[key] = new PrioritizedTrigger(trigger, selector, priority, index); } else { var comparison = selector.ComparePriority(existing.Selector); if (comparison == 0 && index > existing.Index) { comparison = 1; } if (comparison > 0 && (trigger.IsImportant || !existing.Trigger.IsImportant)) { triggers[key] = new PrioritizedTrigger(trigger, selector, priority, index); } } }
internal Boolean Remove(UvssTrigger trigger) { return triggers.Remove(trigger); }
internal Boolean Contains(UvssTrigger trigger) { return triggers.Contains(trigger); }
internal void Add(UvssTrigger trigger) { triggers.Add(trigger); }
/// <summary> /// Gets a value indicating whether the collection contains the specified item. /// </summary> /// <param name="trigger">The trigger to evaluate.</param> /// <returns><see langword="true"/> if the collection contains the specified item; otherwise, <see langword="false"/>.</returns> internal Boolean Contains(UvssTrigger trigger) { return(triggers.Contains(trigger)); }
/// <summary> /// Removes an item from the collection. /// </summary> /// <param name="trigger">The trigger to remove from the collection.</param> /// <returns><see langword="true"/> if the item was removed from the collection; otherwise, <see langword="false"/>.</returns> internal Boolean Remove(UvssTrigger trigger) { return(triggers.Remove(trigger)); }
/// <summary> /// Adds an item to the collection. /// </summary> /// <param name="trigger">The trigger to add to the collection.</param> internal void Add(UvssTrigger trigger) { triggers.Add(trigger); }