Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UvssSelector"/> class.
        /// </summary>
        /// <param name="parts">A collection containing the selector's parts.</param>
        /// <param name="navexp">The selector's navigation expression, if it has one.</param>
        internal UvssSelector(IEnumerable <UvssSelectorPart> parts, UvssNavigationExpression navexp = null)
        {
            this.parts = parts.ToList();

            if (this.parts.Count == 1)
            {
                var part = this.parts[0];

                this.priority = part.Priority;
                this.text     = part.ToString();
            }
            else
            {
                var builder = SelectorTextBuilder.Value;

                foreach (var part in this.parts)
                {
                    this.priority += part.Priority;

                    if (builder.Length > 0)
                    {
                        builder.Append(' ');
                    }

                    builder.Append(part.ToString());
                }

                this.text      = builder.ToString();
                builder.Length = 0;
            }

            this.navexp = navexp;
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UvssStoryboardAnimation"/> class.
 /// </summary>
 /// <param name="animatedProperty">The name of the animated property.</param>
 /// <param name="navigationExpression">The animated property's navigation expression.</param>
 /// <param name="keyframes">The animation's collection of keyframes.</param>
 internal UvssStoryboardAnimation(String animatedProperty, UvssNavigationExpression navigationExpression, UvssStoryboardKeyframeCollection keyframes)
 {
     this.animatedProperty     = animatedProperty;
     this.navigationExpression = navigationExpression;
     this.keyframes            = keyframes;
 }
        /// <summary>
        /// Creates a new instance of the <see cref="NavigationExpression"/> from the
        /// specified <see cref="UvssNavigationExpression"/> object.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="uvssexp">The UVSS navigation expression from which to create a new structure.</param>
        /// <returns>The <see cref="NavigationExpression"/> that was created.</returns>
        public static NavigationExpression?FromUvssNavigationExpression(UltravioletContext uv, UvssNavigationExpression uvssexp)
        {
            Contract.Require(uv, nameof(uv));

            if (uvssexp == null)
            {
                return(null);
            }

            var upf = uv.GetUI().GetPresentationFoundation();

            var navigationPropertyName  = new DependencyName(uvssexp.NavigationProperty);
            var navigationPropertyIndex = uvssexp.NavigationPropertyIndex;
            var navigationPropertyType  = default(Type);

            if (uvssexp.NavigationPropertyType != null)
            {
                if (!upf.GetKnownType(uvssexp.NavigationPropertyType, false, out navigationPropertyType))
                {
                    throw new UvssException(PresentationStrings.UnrecognizedType.Format(uvssexp.NavigationPropertyType));
                }
            }

            return(new NavigationExpression(navigationPropertyName, navigationPropertyType, navigationPropertyIndex));
        }