/// <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); }
/// <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(); }
/// <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; } }
/// <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; }
/// <inheritdoc/> protected override void StyleOverride(UvssDocument styleSheet) { UpdatePopupStyle(styleSheet); base.StyleOverride(styleSheet); }
/// <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) { }
/// <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); }
/// <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; } }
/// <inheritdoc/> protected override void StyleCore(UvssDocument styleSheet) { if (clonedElement != null && !clonedElement.IsVisuallyConnectedToViewRoot) { clonedElement.Style(styleSheet); } base.StyleCore(styleSheet); }
/// <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(); }
/// <inheritdoc/> protected override void StyleOverride(UvssDocument styleSheet) { if (componentRoot != null) componentRoot.InvalidateStyle(true); base.StyleOverride(styleSheet); }
/// <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); }