Exemple #1
0
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            LockApplicationHost host = LockApplicationHost.GetForCurrentView();
            Frame rootFrame          = new Frame();

            Window.Current.Content = rootFrame;
            rootFrame.Navigate(typeof(MainPage), args.Arguments);
            Window.Current.Activate();
        }
Exemple #2
0
        public void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            Frame frame = ConstructUI();

            App.Current.CallSystem.CallManager.ActiveCallChanged += CallManager_ActiveCallChanged;
            MainWindow = Window.Current;

            switch (args.Kind)
            {
            case ActivationKind.Launch:
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            ShowCallUIWindow();
                        }
                        frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                App.Current.OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
Exemple #3
0
        public SlownessPatternPage()
        {
            this.InitializeComponent();
            ((UWPDebugging.App)App.Current).StartAnimator += OnStartAnimatorMessage;
            Logging.SingleInstance.LogMessage("SlownessPatternPage Created");

            LockApplicationHost lockHost = LockApplicationHost.GetForCurrentView();

            if (lockHost != null)
            {
                lockHost.Unlocking += LockHost_Unlocking;
                Logging.SingleInstance.LogMessage("SlownessPatternPage setup unlocking event handler");
            }
        }
Exemple #4
0
        private async void Button_Click_3(object sender, RoutedEventArgs e)
        {
            LockApplicationHost host = LockApplicationHost.GetForCurrentView();

            if (host != null)
            {
                host.RequestUnlock();
                Logging.SingleInstance.LogMessage("Lockhost RequestUnlock");
            }
            else
            {
                await ApplicationView.GetForCurrentView().TryConsolidateAsync();

                Logging.SingleInstance.LogMessage("TryConsolidateAsync");
            }
        }
Exemple #5
0
        public static WindowDisplayMode GetForCurrentView()
        {
            ApplicationView applicationView = ApplicationView.GetForCurrentView();

            switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily)
            {
            case "Windows.Desktop":
            {
                if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.ViewManagement.ApplicationViewMode", "CompactOverlay") && applicationView.ViewMode == ApplicationViewMode.CompactOverlay)
                {
                    return(WindowDisplayMode.CompactOverlay);
                }
                if (LockApplicationHost.GetForCurrentView() != null)
                {
                    // When an application is in kiosk mode, ApplicationView.ISFullScreenMode will return false
                    // even if the application is in fact displayed full screen. We need to check manually if an application is
                    // in kiosk mode and force the result to FullScreen.
                    return(WindowDisplayMode.FullScreen);
                }
                if (IsMixedReality())
                {
                    return(WindowDisplayMode.Windowed);
                }
                else
                {
                    if (applicationView.IsFullScreenMode)
                    {
                        return(WindowDisplayMode.FullScreen);
                    }
                    else
                    {
                        switch (UIViewSettings.GetForCurrentView().UserInteractionMode)
                        {
                        case UserInteractionMode.Mouse:
#pragma warning disable CS0618 // Type or member is obsolete
                            return(applicationView.IsFullScreen ? WindowDisplayMode.Maximized : WindowDisplayMode.Windowed);

#pragma warning restore CS0618 // Type or member is obsolete
                        case UserInteractionMode.Touch:
                        {
                            if (applicationView.AdjacentToLeftDisplayEdge)
                            {
                                if (applicationView.AdjacentToRightDisplayEdge)
                                {
                                    return(WindowDisplayMode.FullScreenTabletMode);
                                }
                                else
                                {
                                    return(WindowDisplayMode.SnappedLeft);
                                }
                            }
                            else
                            {
                                return(WindowDisplayMode.SnappedRight);
                            }
                        }

                        default:
                            return(WindowDisplayMode.Unknown);
                        }
                    }
                }
            }

            case "Windows.Mobile":
            {
                if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse)
                {
                    // Continuum
                    return(applicationView.IsFullScreenMode ? WindowDisplayMode.Maximized : WindowDisplayMode.Windowed);
                }
                else
                {
                    return(WindowDisplayMode.FullScreen);
                }
            }

            case "Windows.Holographic":
            {
                return(WindowDisplayMode.Windowed);
            }

            case "Windows.Xbox":
            case "Windows.IoT":
            {
                return(WindowDisplayMode.FullScreen);
            }

            case "Windows.Team":
            {
                if (applicationView.AdjacentToLeftDisplayEdge)
                {
                    if (applicationView.AdjacentToRightDisplayEdge)
                    {
                        return(WindowDisplayMode.FullScreenTabletMode);
                    }
                    else
                    {
                        return(WindowDisplayMode.SnappedLeft);
                    }
                }
                else
                {
                    return(WindowDisplayMode.SnappedRight);
                }
            }

            default:
                return(WindowDisplayMode.Unknown);
            }
        }
Exemple #6
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            IsForeground = true;
            Frame frame = ConstructUI();

            Dispatcher = Window.Current.Dispatcher;
            if (!PermissionSystem.IsAllPermissionsObtained && !await ObtainingAccess)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    ObtainingAccess = PermissionSystem.RequestAllPermissions();
                });

                await ObtainingAccess;
            }
            if (Initializating == null)
            {
                Initializating = InitializateSystems();
            }
            await Initializating;

            UISystem.Initializate(Dispatcher);
            NotificationSystem.RemoveCallToastNotifications();
            switch (args.Kind)
            {
            case ActivationKind.Launch:
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            CompactOverlayId = await CallUIPage.ShowInCallUI();
                        }
                        frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
Exemple #7
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            Frame frame;

            try
            {
                await Initialisation;
            }
            catch
            {
                await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
                {
                    await AccessSetup();
                    InitializateSystems();
                });
            }
            switch (args.Kind)
            {
            case ActivationKind.Launch:
                frame = ConstructUI();
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            frame.Navigate(typeof(InCallUI));
                        }
                        else
                        {
                            frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                        }
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame = ConstructUI();
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                frame = ConstructUI();
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                frame = ConstructUI();
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
Exemple #8
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            // CoreApplication.EnablePrelaunch was introduced in Windows 10 version 1607
            bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch");


            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                // On Windows 10 version 1607 or later, this code signals that this app wants to participate in prelaunch
                if (canEnablePrelaunch)
                {
                    TryEnablePrelaunch();
                }

                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    LockApplicationHost host = LockApplicationHost.GetForCurrentView();
                    if (host == null)
                    {
                        // if call to LockApplicationHost is null, this app is running under lock
                        // render MainPage normally
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }
                    else
                    {
                        // If LockApplicationHost was successfully obtained
                        // this app is running as a lock screen app, or above lock screen app
                        // render a different page for assigned access use
                        // to avoid showing regular main page to keep secure information safe
                        rootFrame.Navigate(typeof(SlownessPatternPage), e.Arguments);
                    }
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();

                Logging.SingleInstance.LogMessage("Launch");
            }
            else
            {
                Logging.SingleInstance.LogMessage("PreLaunch");
            }
            ExtendAcrylicIntoTitleBar();
        }