/// <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)); } }
public SampleScreen2(ContentManager globalContent, UIScreenService uiScreenService) : base("Content/UI/Screens/SampleScreen2", "SampleScreen2", globalContent) { Contract.Require(uiScreenService, "uiScreenService"); IsOpaque = true; this.font = LocalContent.Load <SpriteFont>("Garamond"); this.blankTexture = GlobalContent.Load <Texture2D>(GlobalTextureID.Blank); this.textRenderer = new TextRenderer(); }
/// <inheritdoc/> protected override UIPanelDefinition LoadPanelDefinition(String asset) { if (String.IsNullOrEmpty(asset)) { return(null); } using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(asset)) { return(LocalContent.LoadFromStream <UIPanelDefinition>(stream, "xml")); } }
public LoadingScreen(ContentManager globalContent, UIScreenService uiScreenService) : base("Content/UI/Screens/LoadingScreen", "LoadingScreen", globalContent) { Contract.Require(uiScreenService, "uiScreenService"); this.uiScreenService = uiScreenService; this.textRenderer = new TextRenderer(); this.blankTexture = GlobalContent.Load <Texture2D>(GlobalTextureID.Blank); this.font = GlobalContent.Load <SpriteFont>(GlobalFontID.SegoeUI); this.spinnerSprite = LocalContent.Load <Sprite>("Spinner"); this.loader = new AsynchronousContentLoader(); this.textRenderer.LayoutEngine.RegisterIcon("spinner", spinnerSprite[0]); UpdateMessage(String.Empty); }
/// <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 UIPanelDefinitionWrapper LoadPanelDefinition(String asset) { if (String.IsNullOrEmpty(asset)) { return(null); } var watch = Ultraviolet.GetUI().WatchingViewFilesForChanges; if (watch) { var definition = LocalContent.LoadWatched <UIPanelDefinition>(asset, () => { if (State == UIPanelState.Open) { var currentViewModel = View?.ViewModel; var currentView = View; if (currentView != null) { currentView.OnClosing(); currentView.OnClosed(); UnloadView(); } FinishLoadingView(); var updatedView = View; if (updatedView != null) { try { if (currentViewModel != null) { updatedView.SetViewModel(currentViewModel); } updatedView.OnOpening(); updatedView.OnOpened(); } catch (Exception e) { UnloadView(); Debug.WriteLine(UltravioletStrings.ExceptionDuringViewReloading); Debug.WriteLine(e); return(false); } } } return(true); }); foreach (var styleSheetAsset in definition.Value.StyleSheetAssets) { LocalContent.AddWatchedDependency(asset, styleSheetAsset); } return(new UIPanelDefinitionWrapper(definition)); } else { var definition = LocalContent.Load <UIPanelDefinition>(asset); return(new UIPanelDefinitionWrapper(definition)); } }
/// <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 UIPanelDefinition LoadPanelDefinition(String asset) { return(String.IsNullOrEmpty(asset) ? null : LocalContent.Load <UIPanelDefinition>(asset)); }