/// <summary>
        /// Initializes a test application which displays the specified Presentation Foundation view.
        /// </summary>
        protected IUltravioletTestApplication GivenAPresentationFoundationTestFor <T>(Func <ContentManager, T> ctor) where T : UIScreen
        {
            var globalStyleSheet = default(GlobalStyleSheet);
            var screen           = default(UIScreen);

            return(GivenAnUltravioletApplication()
                   .WithPresentationFoundationConfigured()
                   .WithInitialization(uv =>
            {
                var upf = uv.GetUI().GetPresentationFoundation();
                upf.CompileExpressions(Path.Combine("Resources", "Content"), CompileExpressionsFlags.GenerateInMemory | CompileExpressionsFlags.WorkInTemporaryDirectory);
                upf.LoadCompiledExpressions();
            })
                   .WithContent(content =>
            {
                content.Ultraviolet.GetContent().Manifests.Load(Path.Combine("Resources", "Content", "Manifests", "Global.manifest"));

                globalStyleSheet = GlobalStyleSheet.Create();
                globalStyleSheet.Append(content, "UI/DefaultUIStyles");

                content.Ultraviolet.GetUI().GetPresentationFoundation().SetGlobalStyleSheet(globalStyleSheet);

                screen = ctor(content);
                content.Ultraviolet.GetUI().GetScreens().Open(screen);
            })
                   .WithDispose(() =>
            {
                screen?.Dispose();
                globalStyleSheet?.Dispose();
            }));
        }
Пример #2
0
        private void LoadPresentation()
        {
            var upf = Ultraviolet.GetUI().GetPresentationFoundation();

            var globalStylesheet = GlobalStyleSheet.Create();

            globalStylesheet.Append(content, "UI/DefaultUIStyles");
            upf.SetGlobalStyleSheet(globalStylesheet);

            upf.CompileExpressionsIfSupported("Content");
            upf.LoadCompiledExpressions();
        }
Пример #3
0
        private void LoadPresentation()
        {
            var upf = Ultraviolet.GetUI().GetPresentationFoundation();

            upf.RegisterKnownTypes(GetType().Assembly);

            if (!ShouldRunInServiceMode())
            {
                globalStyleSheet = GlobalStyleSheet.Create();
                globalStyleSheet.Append(content, "UI/DefaultUIStyles");
                upf.SetGlobalStyleSheet(globalStyleSheet);

                CompileBindingExpressions();
                upf.LoadCompiledExpressions();
            }
        }
        /// <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(GlobalStyleSheet styleSheet)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            var previous = globalStyleSheet;

            try
            {
                SetGlobalStyleSheetInternal(styleSheet);
            }
            catch
            {
                SetGlobalStyleSheetInternal(previous);
                return(false);
            }
            return(true);
        }
        /// <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(GlobalStyleSheet styleSheet)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            SetGlobalStyleSheetInternal(styleSheet);
        }