コード例 #1
0
ファイル: BootStrapper.cs プロジェクト: wildjan/T10_Samples
        /// <summary>
        /// InitializeFrameAsync creates a default Frame preceeded by the optional
        /// splash screen, then OnInitialzieAsync, then the new frame (if necessary).
        /// This is private because there's no reason for the developer to call this.
        /// </summary>
        private async Task InitializeFrameAsync(IActivatedEventArgs e)
        {
            DebugWrite($"{nameof(IActivatedEventArgs)}:{e.Kind}");

            // first show the splash
            FrameworkElement splash = null;

            if (SplashFactory != null && e.PreviousExecutionState != ApplicationExecutionState.Suspended)
            {
                Window.Current.Content = splash = SplashFactory(e.SplashScreen);
                Window.Current.Activate();
            }

            // allow the user to do things, even when restoring
            _HasOnInitializeAsync = true;
            await OnInitializeAsync(e);

            // this "unused" bit is very important because of a quirk in ResourceThemes
            try
            {
                if (Application.Current.Resources.ContainsKey("ExtendedSplashBackground"))
                {
                    var unused = Application.Current.Resources["ExtendedSplashBackground"];
                }
            }
            catch { /* this is okay */ }

            // this wonky style of loop is important due to a platform bug
            int count = Application.Current.Resources.Count;

            foreach (var resource in Application.Current.Resources)
            {
                var k = resource.Key;
                if (k == typeof(Controls.CustomTitleBar))
                {
                    var s = resource.Value as Style;
                    var t = new Controls.CustomTitleBar();
                    t.Style = s;
                }
                count--;
                if (count == 0)
                {
                    break;
                }
            }

            // create the default frame only if there's nothing already there
            // if it is not null, by the way, then the developer injected something & they win
            if (Window.Current.Content == null || Window.Current.Content == splash)
            {
                // build the default frame
                var frame = CreateRootFrame(e);
                var modal = new Controls.ModalDialog
                {
                    DisableBackButtonWhenModal = true,
                    Content = (NavigationServiceFactory(BackButton.Attach, ExistingContent.Include, frame)).FrameFacade.Frame
                };
                Window.Current.Content = modal;
            }
        }
コード例 #2
0
        /// <summary>
        /// InitializeFrameAsync creates a default Frame preceeded by the optional
        /// splash screen, then OnInitialzieAsync, then the new frame (if necessary).
        /// This is private because there's no reason for the developer to call this.
        /// </summary>
        private async Task InitializeFrameAsync(IActivatedEventArgs e)
        {
            DebugWrite($"IActivatedEventArgs.Kind:{e.Kind}");

            // first show the splash
            FrameworkElement splash = null;

            if (SplashFactory != null && e.PreviousExecutionState != ApplicationExecutionState.Suspended)
            {
                Window.Current.Content = splash = SplashFactory(e.SplashScreen);
                Window.Current.Activate();
            }

            // allow the user to do things, even when restoring
            await OnInitializeAsync(e);

            // this "unused" bit is very important because of a quirk in ResourceThemes
            try { var unused = Application.Current.Resources["ExtendedSplashBackground"]; }
            catch { /* this is okay */ }

            // setup custom titlebar
            foreach (var resource in Application.Current.Resources
                     .Where(x => x.Key.Equals(typeof(Controls.CustomTitleBar))))
            {
                var control = new Controls.CustomTitleBar();
                control.Style = resource.Value as Style;
            }

            // create the default frame only if there's nothing already there
            // if it is not null, by the way, then the developer injected something & they win
            if (Window.Current.Content == null || Window.Current.Content == splash)
            {
                // build the default frame
                var frame = CreateRootFrame(e);
                var modal = new Controls.ModalDialog
                {
                    Content = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include, frame).Frame
                };
                Window.Current.Content = modal;
            }
        }