Ejemplo n.º 1
0
        /// <summary>
        /// Converts the composite document to a <see cref="UvssDocument"/> instance.
        /// </summary>
        /// <returns></returns>
        public UvssDocument ToUvssDocument()
        {
            var document = new UvssDocument(Ultraviolet);

            foreach (var child in children)
            {
                if (child is UvssDocument)
                {
                    document.Append((UvssDocument)child);
                }
                else
                {
                    var watched = (WatchedAsset <UvssDocument>)child;
                    document.Append(watched);
                }
            }
            return(document);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Appends another styling document to the end of this document.
        /// </summary>
        /// <param name="document">The document to append to the end of this document.</param>
        public void Append(UvssDocument document)
        {
            Contract.Require(document, nameof(document));

            Ultraviolet.ValidateResource(document);

            this.ruleSets.AddRange(document.RuleSets);
            this.storyboardDefinitions.AddRange(document.StoryboardDefinitions);

            foreach (var storyboardDefinition in document.storyboardDefinitions)
            {
                this.storyboardDefinitionsByName[storyboardDefinition.Name] = storyboardDefinition;
            }

            foreach (var storyboardInstance in document.storyboardInstancesByName)
            {
                this.storyboardInstancesByName[storyboardInstance.Key] = storyboardInstance.Value;
            }

            CategorizeRuleSets();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads files necessary for the Presentation Foundation.
        /// </summary>
        protected void LoadPresentation()
        {
            var upf = Ultraviolet.GetUI().GetPresentationFoundation();
            upf.RegisterKnownTypes(GetType().Assembly);

            if (!ShouldRunInServiceMode())
            {
                var globalStyleSheet = new UvssDocument();
                globalStyleSheet.Append(content.Load<UvssDocument>("UI/DefaultUIStyles"));
                globalStyleSheet.Append(content.Load<UvssDocument>("UI/GameStyles"));
                upf.SetGlobalStyleSheet(globalStyleSheet);

                CompileBindingExpressions();
                upf.LoadCompiledExpressions();

                Diagnostics.DrawDiagnosticsVisuals = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the style sheet which is applied to the popup content.
        /// </summary>
        /// <param name="styleSheet">The style sheet to apply to the popup content.</param>
        private void UpdatePopupStyle(UvssDocument styleSheet)
        {
            if (!IsOpen || styleSheet == null)
            {
                stylesNeedUpdate = true;
                return;
            }

            root.InvalidateStyle(true);
            root.Style(MostRecentStyleSheet);

            stylesNeedUpdate = false;
        }
Ejemplo n.º 5
0
        /// <inheritdoc/>
        protected override void StyleOverride(UvssDocument styleSheet)
        {
            UpdatePopupStyle(styleSheet);

            base.StyleOverride(styleSheet);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// When overridden in a derived class, applies the specified style sheet
        /// to this element and to any child elements.
        /// </summary>
        /// <param name="styleSheet">The style sheet to apply to this element and its children.</param>
        protected virtual void StyleOverride(UvssDocument styleSheet)
        {

        }
Ejemplo n.º 7
0
        /// <inheritdoc/>
        protected sealed override void StyleCore(UvssDocument styleSheet)
        {
            base.StyleCore(styleSheet);

            VisualStateGroups.ReapplyStates();

            StyleOverride(styleSheet);
        }
 /// <inheritdoc/>
 protected internal sealed override void ApplyStyles(UvssDocument document)
 {
     var rule = document.Rules.Where(x => x.IsViewResourceRule()).LastOrDefault();
     if (rule != null)
     {
         foreach (var style in rule.Styles)
         {
             var dp = DependencyProperty.FindByStylingName(style.Name, GetType());
             if (dp != null)
             {
                 var navexp = NavigationExpression.FromUvssNavigationExpression(view.Ultraviolet, rule.NavigationExpression);
                 base.ApplyStyle(style, rule.Selectors[0], navexp, dp);
             }
         }
     }
     base.ApplyStyles(document);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Appends another styling document to the end of this document.
        /// </summary>
        /// <param name="document">The document to append to the end of this document.</param>
        public void Append(UvssDocument document)
        {
            Contract.Require(document, "document");

            this.rules.AddRange(document.Rules);
            this.storyboards.AddRange(document.Storyboards);

            foreach (var storyboard in document.Storyboards)
            {
                this.storyboardsByName[storyboard.Name] = storyboard;
            }
        }
Ejemplo n.º 10
0
 /// <inheritdoc/>
 protected override void StyleCore(UvssDocument styleSheet)
 {
     if (clonedElement != null && !clonedElement.IsVisuallyConnectedToViewRoot)
     {
         clonedElement.Style(styleSheet);
     }
     base.StyleCore(styleSheet);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Appends another styling document to the end of this document.
        /// </summary>
        /// <param name="document">The document to append to the end of this document.</param>
        public void Append(UvssDocument document)
        {
            Contract.Require(document, nameof(document));

            Ultraviolet.ValidateResource(document);

            this.ruleSets.AddRange(document.RuleSets);
            this.storyboardDefinitions.AddRange(document.StoryboardDefinitions);

            foreach (var storyboardDefinition in document.storyboardDefinitions)
                this.storyboardDefinitionsByName[storyboardDefinition.Name] = storyboardDefinition;

            foreach (var storyboardInstance in document.storyboardInstancesByName)
                this.storyboardInstancesByName[storyboardInstance.Key] = storyboardInstance.Value;

            CategorizeRuleSets();
        }
Ejemplo n.º 12
0
        /// <inheritdoc/>
        protected override void StyleOverride(UvssDocument styleSheet)
        {
            if (componentRoot != null)
                componentRoot.InvalidateStyle(true);

            base.StyleOverride(styleSheet);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates the style sheet which is applied to the popup content.
        /// </summary>
        /// <param name="styleSheet">The style sheet to apply to the popup content.</param>
        private void UpdatePopupStyle(UvssDocument styleSheet)
        {
            if (!IsOpen || styleSheet == null)
                return;

            root.InvalidateStyle(true);
            root.Style(MostRecentStyleSheet);
        }