コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrioritizedStyle"/> structure.
 /// </summary>
 /// <param name="style">The style being applied.</param>
 /// <param name="selector">The selector which caused the style to be applied.</param>
 /// <param name="priority">The style's priority.</param>
 /// <param name="index">The index of the style's rule set within its style sheet.</param>
 public PrioritizedStyle(UvssRule style, UvssSelector selector, Int32 priority, Int32 index)
 {
     this.Style    = style;
     this.Selector = selector;
     this.Priority = priority;
     this.Index    = index;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrioritizedStyle"/> structure.
 /// </summary>
 /// <param name="style">The style being applied.</param>
 /// <param name="selector">The selector which caused the style to be applied.</param>
 /// <param name="priority">The style's priority.</param>
 /// <param name="index">The index of the style's rule set within its style sheet.</param>
 public PrioritizedStyle(UvssRule style, UvssSelector selector, Int32 priority, Int32 index)
 {
     this.Style = style;
     this.Selector = selector;
     this.Priority = priority;
     this.Index = index;
 }
コード例 #3
0
        /// <summary>
        /// Adds a styling rule 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="rule">The styling rule to add to the prioritizer.</param>
        /// <param name="index">The index of the rule's rule set within the style sheet.</param>
        public void Add(UltravioletContext uv, UvssSelector selector, NavigationExpression? navigationExpression, UvssRule rule, Int32 index)
        {
            Contract.Require(uv, nameof(uv));

            var key = new StyleKey(rule.CanonicalName, navigationExpression);
            var priority = CalculatePriorityFromSelector(selector, rule.IsImportant);

            PrioritizedStyle existing;
            if (!rules.TryGetValue(key, out existing))
            {
                rules[key] = new PrioritizedStyle(rule, selector, priority, index);
            }
            else
            {
                var comparison = selector.ComparePriority(existing.Selector);
                if (comparison == 0 && index > existing.Index)
                    comparison = 1;

                if (comparison > 0 && (rule.IsImportant || !existing.Style.IsImportant))
                {
                    rules[key] = new PrioritizedStyle(rule, selector, priority, index);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds a styling rule 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="rule">The styling rule to add to the prioritizer.</param>
        /// <param name="index">The index of the rule's rule set within the style sheet.</param>
        public void Add(UltravioletContext uv, UvssSelector selector, NavigationExpression?navigationExpression, UvssRule rule, Int32 index)
        {
            Contract.Require(uv, nameof(uv));

            var key      = new StyleKey(rule.CanonicalName, navigationExpression);
            var priority = CalculatePriorityFromSelector(selector, rule.IsImportant);

            PrioritizedStyle existing;

            if (!rules.TryGetValue(key, out existing))
            {
                rules[key] = new PrioritizedStyle(rule, selector, priority, index);
            }
            else
            {
                var comparison = selector.ComparePriority(existing.Selector);
                if (comparison == 0 && index > existing.Index)
                {
                    comparison = 1;
                }

                if (comparison > 0 && (rule.IsImportant || !existing.Style.IsImportant))
                {
                    rules[key] = new PrioritizedStyle(rule, selector, priority, index);
                }
            }
        }
コード例 #5
0
        /// <inheritdoc/>
        internal override void ApplyStyledVisualStateTransition(UvssRule style)
        {
            Contract.Require(style, nameof(style));

            if (View != null && View.StyleSheet != null)
            {
                var value = (style.CachedResolvedValue != null && style.CachedResolvedValue is String) ?
                    (String)style.CachedResolvedValue : style.Value.Trim();

                style.CachedResolvedValue = value;

                var storyboard = View.StyleSheet.GetStoryboardInstance(value);
                if (storyboard != null)
                {
                    var group = default(String);
                    var from = default(String);
                    var to = default(String);

                    switch (style.Arguments.Count)
                    {
                        case 2:
                            group = style.Arguments[0];
                            from = null;
                            to = style.Arguments[1];
                            break;

                        case 3:
                            group = style.Arguments[0];
                            from = style.Arguments[1];
                            to = style.Arguments[2];
                            break;

                        default:
                            throw new NotSupportedException();
                    }

                    VisualStateGroups.SetVisualStateTransition(group, from, to, storyboard);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Applies the specified style to the dependency property.
        /// </summary>
        /// <param name="dobj">The dependency object on which to set the style.</param>
        /// <param name="style">The style to set on this dependency property.</param>
        /// <param name="provider">An object that supplies culture-specific formatting information.</param>
        internal void ApplyStyle(DependencyObject dobj, UvssRule style, IFormatProvider provider)
        {
            if (styleSetter == null)
                throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(Name));

            styleSetter(dobj, style, provider);
        }
コード例 #7
0
        /// <summary>
        /// Applies the specified style to the dependency property.
        /// </summary>
        /// <param name="dobj">The dependency object on which to set the style.</param>
        /// <param name="style">The style to set on this dependency property.</param>
        internal void ApplyStyle(DependencyObject dobj, UvssRule style)
        {
            if (styleSetter == null)
                throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(Name));

            styleSetter(dobj, style, CultureInfo.InvariantCulture);
        }