/// <inheritdoc/>
 protected override void StyleCore(UvssDocument styleSheet)
 {
     if (clonedElement != null && !clonedElement.IsVisuallyConnectedToViewRoot)
     {
         clonedElement.Style(styleSheet);
     }
     base.StyleCore(styleSheet);
 }
Beispiel #2
0
        /// <inheritdoc/>
        protected override void StyleOverride(UvssDocument styleSheet)
        {
            if (componentRoot != null)
            {
                componentRoot.InvalidateStyle(true);
            }

            base.StyleOverride(styleSheet);
        }
        /// <summary>
        /// Attempts to set the global style sheet used by all Presentation Foundation views. If any exceptions are thrown
        /// during this process, the previous style sheet will be automatically restored.
        /// </summary>
        /// <param name="styleSheet">The global style sheet to set.</param>
        /// <returns><see langword="true"/> if the style sheet was set successfully; otherwise, <see langword="false"/>.</returns>
        public Boolean TrySetGlobalStyleSheet(UvssDocument styleSheet)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            var previous = globalStyleSheet;

            try
            {
                SetGlobalStyleSheetInternal(styleSheet);
            }
            catch
            {
                SetGlobalStyleSheetInternal(previous);
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Loads files necessary for the Presentation Foundation.
        /// </summary>
        private void LoadPresentation()
        {
            var upf = Ultraviolet.GetUI().GetPresentationFoundation();

            upf.RegisterKnownTypes(GetType().Assembly);

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

                CompileBindingExpressions();
                upf.LoadCompiledExpressions();

                Diagnostics.DrawDiagnosticsVisuals = true;
            }
        }
Beispiel #5
0
        /// <inheritdoc/>
        protected internal sealed override void ApplyStyles(UvssDocument document)
        {
            var rule = document.RuleSets.Where(x => x.IsViewResourceRule()).LastOrDefault();

            if (rule != null)
            {
                foreach (var style in rule.Rules)
                {
                    var dp = DependencyProperty.FindByStylingName(style.Name, GetType());
                    if (dp != null)
                    {
                        var selector = rule.Selectors[0];
                        var navexp   = NavigationExpression.FromUvssNavigationExpression(
                            view.Ultraviolet, selector.NavigationExpression);
                        base.ApplyStyle(style, selector, navexp, dp);
                    }
                }
            }
            base.ApplyStyles(document);
        }
 /// <summary>
 /// Applies the styles from the specified style sheet to this object.
 /// </summary>
 /// <param name="document">The style sheet to apply to this object.</param>
 protected internal virtual void ApplyStyles(UvssDocument document)
 {
 }
        /// <summary>
        /// Sets the global style sheet used by all Presentation Foundation views.
        /// </summary>
        /// <param name="styleSheet">The global style sheet to set.</param>
        public void SetGlobalStyleSheet(UvssDocument styleSheet)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            SetGlobalStyleSheetInternal(styleSheet);
        }