/// <summary> /// Loads the screen's panel definition from the specified asset. /// </summary> /// <param name="asset">The name of the asset that contains the panel definition.</param> /// <returns>The panel definition that was loaded from the specified asset.</returns> protected virtual WatchedAsset <UIPanelDefinition> LoadPanelDefinition(String asset) { if (String.IsNullOrEmpty(asset)) { return(null); } var display = Window?.Display ?? Ultraviolet.GetPlatform().Displays.PrimaryDisplay; var density = display.DensityBucket; Scale = display.DensityScale; var watch = Ultraviolet.GetUI().WatchingViewFilesForChanges; if (watch) { var definition = new WatchedAsset <UIPanelDefinition>(LocalContent, asset, density, OnValidatingUIPanelDefinition, OnReloadingUIPanelDefinition); return(definition); } else { var definition = LocalContent.Load <UIPanelDefinition>(asset, density); return(new WatchedAsset <UIPanelDefinition>(LocalContent, definition)); } }
/// <summary> /// Gets the version of this document which has been loaded for the specified density bucket. /// </summary> /// <param name="density">The density bucket for which to retrieve a document.</param> /// <returns>The version of this document which has been loaded for the specified density bucket.</returns> public UvssDocument Get(ScreenDensityBucket density) { Contract.EnsureNotDisposed(this, disposed); if (!assetVersions.TryGetValue((Byte)density, out var document)) { var watching = contentManager.Ultraviolet.GetUI().WatchingViewFilesForChanges; if (watching) { document = new WatchedAsset <UvssDocument>(contentManager, assetPath, density, (p, a) => validating?.Invoke(p, a) ?? true, (p, a, v) => validationComplete?.Invoke(p, a, v)); } else { document = new WatchedAsset <UvssDocument>(contentManager, assetPath, density); } assetVersions[(Byte)density] = document; } return(document.ValidatingValue ?? document.Value); }
/// <summary> /// Initializes a new instance of the <see cref="UIPanelDefinitionWrapper"/> class. /// </summary> /// <param name="asset">The <see cref="WatchedAsset{UIPanelDefinitionAsset}"/> which is represented by this wrapper.</param> public UIPanelDefinitionWrapper(WatchedAsset <UIPanelDefinition> asset) { this.asset = asset; this.lastKnownGoodVersion = asset; }