예제 #1
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 reloadGlobalStyleSheet = new WatchedAssetReloadingHandler(() =>
                                                                              Ultraviolet.GetUI().GetPresentationFoundation().TrySetGlobalStyleSheet(globalStyleSheet.ToUvssDocument()));

                globalStyleSheet = new CompositeUvssDocument(Ultraviolet, reloadGlobalStyleSheet);
                globalStyleSheet.Append(content, "UI/DefaultUIStyles");
                globalStyleSheet.Append(content, "UI/GameStyles");
                reloadGlobalStyleSheet();

                CompileBindingExpressions();
                upf.LoadCompiledExpressions();
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WatchedAsset{TContent}"/> structure.
        /// </summary>
        /// <param name="owner">The <see cref="ContentManager"/> that owns the watched asset.</param>
        /// <param name="assetPath">The asset path that represents the asset.</param>
        /// <param name="assetFilePath">The resolved file path to the file that represents the asset.</param>
        /// <param name="watcher">The <see cref="FileSystemWatcher"/> which is responsible for watching the asset.</param>
        /// <param name="onReloading">The action to perform when the asset is changed.</param>
        public WatchedAsset(ContentManager owner, String assetPath, String assetFilePath, FileSystemWatcher watcher, WatchedAssetReloadingHandler onReloading)
        {
            this.Owner         = owner;
            this.AssetPath     = assetPath;
            this.AssetFilePath = Path.GetFullPath(assetFilePath);
            this.OnReloading   = onReloading;

            this.watcher          = watcher;
            this.watcher.Changed += Watcher_Changed;
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompositeUvssDocument"/> class.
 /// </summary>
 /// <param name="uv">The ultraviolet context.</param>
 /// <param name="onReloading">The method to invoke when one of the composite document's child documents is reloaded.</param>
 public CompositeUvssDocument(UltravioletContext uv, WatchedAssetReloadingHandler onReloading = null)
     : base(uv)
 {
     this.onReloading = onReloading;
 }