public async Task Run(AppointmentsProviderReplaceAppointmentActivatedEventArgs args, Frame frame)
 {
     var payload = new ReplaceAppointmentPayload(args.ReplaceAppointmentOperation);
     int currentApplicationViewId = ApplicationView.GetApplicationViewIdForWindow(CoreApplication.GetCurrentView().CoreWindow);
     var viewConfig = new MultiViewConfiguration <ReplaceAppointmentPayload>(View, (p) => true);
     await viewConfig.Show(payload, currentApplicationViewId, frame);
 }
예제 #2
0
        /// <summary>
        /// This will initially create the UI.
        /// Note that some of the the UI does not exist at first and is created dynamically.
        /// </summary>
        public async void CreateUI()
        {
            // Create a new new core application view.
            // this will be the external windows to host the media player.
            CoreApplicationView newView = CoreApplication.CreateNewView();

            // This will hold the ID of the new view.
            int newViewId = 0;

            // Remember the dispatcher for the new view so it can later be addressed as the
            // view runs in its own thread.
            // This is stored globally in the event handler.
            this.globalEventHandlerInstance.playerDispatcher = newView.Dispatcher;

            // Run the new view in a new thread based on the new dispatcher.
            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // Create a new content frame and load the fullscreen viewer into it.
                Frame frame = new Frame();
                frame.Navigate(typeof(FullScreenViewer), null);
                Window.Current.Content = frame;

                // The window needs to be active in order to show it later.
                Window.Current.Activate();

                // Get the IDs for the view and window.
                newViewId       = ApplicationView.GetForCurrentView().Id;
                var newWindowId = ApplicationView.GetApplicationViewIdForWindow(newView.CoreWindow);
            });

            // Activate and show the new window.
            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

            sequencerControls.SetStatusMessage("Player window created, ready.");
        }
예제 #3
0
        async void OnLaunch(object sender, RoutedEventArgs e)
        {
            CoreApplicationView newCoreView = CoreApplication.CreateNewView();

            //HolographicSpace.CreateForCoreWindow(newCoreView.CoreWindow);



            ApplicationView newAppView = null;
            int             mainViewId = ApplicationView.GetApplicationViewIdForWindow(
                CoreApplication.MainView.CoreWindow);

            await newCoreView.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                () =>
            {
                newAppView             = ApplicationView.GetForCurrentView();
                Window.Current.Content = new BlankPage1();
                Window.Current.Activate();
            });

            await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                newAppView.Id,
                ViewSizePreference.UseHalf,
                mainViewId,
                ViewSizePreference.UseHalf);
        }
예제 #4
0
        async void ShowCampaignWindow_Click(object sender, RoutedEventArgs e)
        {
            //BootGMBinderSite();

            CoreApplicationView newCoreView = CoreApplication.CreateNewView();

            ApplicationView newAppView = null;
            int             mainViewId = ApplicationView.GetApplicationViewIdForWindow(
                CoreApplication.MainView.CoreWindow);

            await newCoreView.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                () =>
            {
                newAppView             = ApplicationView.GetForCurrentView();
                Window.Current.Content = new CampaignMainPage();
                Window.Current.Activate();
            });

            await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                newAppView.Id,
                ViewSizePreference.UseHalf,
                mainViewId,
                ViewSizePreference.UseHalf);
        }
예제 #5
0
        public static async Task <PlayerWindowManager> CreatePlayerWindowManager(CoreApplicationView playerView)
        {
            INavigationService ns = null;
            int id = 0;
            await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame              = new Frame();
                var frameFacade        = new FrameFacadeAdapter(frame);
                Window.Current.Content = frame;

                var sessionStateService = new SessionStateService();
                ns = new FrameNavigationService(frameFacade
                                                , (pageToken) =>
                {
                    if (pageToken == nameof(Views.VideoPlayerControl))
                    {
                        return(typeof(Views.VideoPlayerControl));
                    }
                    else
                    {
                        return(typeof(Page));
                    }
                }, sessionStateService);
                id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow);
            });

            return(new PlayerWindowManager(playerView, id, ns));
        }
예제 #6
0
        /// <summary>
        /// Tries to retrieve existing instance of <see cref="ViewLifetimeControl"/> for current <see cref="CoreWindow"/>
        /// </summary>
        /// <returns>Instance of <see cref="ViewLifetimeControl"/> that is associated with current window or <value>null</value> if no calls to <see cref="GetForCurrentView"/> were made
        /// before.</returns>
        public static IViewLifetimeControl TryGetForCurrentView()
        {
            IViewLifetimeControl res;

            WindowControlsMap.TryGetValue(ApplicationView.GetApplicationViewIdForWindow(Window.Current.CoreWindow), out res);
            return(res);
        }
 private async void OpenMainWindow()
 {
     await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
     {
         await ApplicationViewSwitcher.TryShowAsStandaloneAsync(ApplicationView.GetApplicationViewIdForWindow(CoreApplication.MainView.CoreWindow));
     });
 }
예제 #8
0
        protected override void OnWindowCreated(WindowCreatedEventArgs args)
        {
            base.OnWindowCreated(args);
            var window = args.Window;

            WindowDictionary.TryAdd(ApplicationView.GetApplicationViewIdForWindow(window.CoreWindow), window);
        }
예제 #9
0
        async private void OnCreateTerminal(object sender, RoutedEventArgs e)
        {
            CoreApplicationView newCoreView = CoreApplication.CreateNewView();

            ApplicationView newAppView = null;
            int             mainViewId = ApplicationView.GetApplicationViewIdForWindow(
                CoreApplication.MainView.CoreWindow);

            await newCoreView.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                () =>
            {
                newAppView             = ApplicationView.GetForCurrentView();
                Window.Current.Content = new Frame();
                (Window.Current.Content as Frame).Navigate(typeof(Terminal));
                Window.Current.Activate();
            });

            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
            //ApplicationView.PreferredLaunchViewSize = new Size(280, 72);
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                newAppView.Id,
                ViewSizePreference.UseHalf,
                mainViewId,
                ViewSizePreference.UseHalf);
        }
        private async Task CreateSecondaryView()
        {
            var secondaryView = CoreApplication.CreateNewView();

            var result = await secondaryView.DispatcherQueue.EnqueueAsync(async() =>
            {
                secondaryView.TitleBar.ExtendViewIntoTitleBar = true;

                var content = new SecondaryWindowCoreLayout();

                var ns = content.CreateNavigationService();
                await ns.NavigateAsync(nameof(BlankPage));

                Window.Current.Content = content;

                var id = ApplicationView.GetApplicationViewIdForWindow(secondaryView.CoreWindow);

                var view = ApplicationView.GetForCurrentView();

                view.TitleBar.ButtonBackgroundColor         = Windows.UI.Colors.Transparent;
                view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent;

                await Task.Delay(250);

                Window.Current.Activate();

                await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.UseHalf, MainViewId, ViewSizePreference.UseHalf);

                // ウィンドウサイズの保存と復元
                if (DeviceTypeHelper.IsDesktop)
                {
                    var localObjectStorageHelper = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                    if (localObjectStorageHelper.KeyExists(secondary_view_size))
                    {
                        view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size));
                    }

                    view.VisibleBoundsChanged += View_VisibleBoundsChanged;
                }

                PlaylistPlayer = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <HohoemaPlaylistPlayer>();

                view.Consolidated += SecondaryAppView_Consolidated;

                _PlayerPageNavgationTransitionInfo = new DrillInNavigationTransitionInfo();
                _BlankPageNavgationTransitionInfo  = new SuppressNavigationTransitionInfo();

                return(id, view, ns);
            });

            SecondaryAppView     = result.view;
            SecondaryCoreAppView = secondaryView;
            SecondaryViewPlayerNavigationService = result.ns;

            _scheduler.Schedule(() =>
            {
                var primaryView           = ApplicationView.GetForCurrentView();
                primaryView.Consolidated += MainView_Consolidated;
            });
        }
예제 #11
0
 public async Task Run(AppointmentsProviderShowAppointmentDetailsActivatedEventArgs args, Frame frame)
 {
     var payload = new ShowAppointmentDetailsPayload(args.RoamingId, args.LocalId, args.InstanceStartDate);
     int currentApplicationViewId = ApplicationView.GetApplicationViewIdForWindow(CoreApplication.GetCurrentView().CoreWindow);
     var viewConfig = new MultiViewConfiguration <ShowAppointmentDetailsPayload>(View, (p) => true);
     await viewConfig.Show(payload, currentApplicationViewId, frame);
 }
 private ViewLifetimeControl(CoreWindow newWindow)
 {
     Dispatcher = newWindow.Dispatcher;
     _window    = newWindow;
     Id         = ApplicationView.GetApplicationViewIdForWindow(_window);
     RegisterForEvents();
 }
예제 #13
0
        public override Task OnNavigatedTo(NavigationEventArgs args)
        {
            var _mainViewId = ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread());

            App.MainViewId = _mainViewId;

            return(null);
        }
예제 #14
0
        /// <summary>
        /// Retrieves existing or creates new instance of <see cref="ViewLifetimeControl"/> for current <see cref="CoreWindow"/>
        /// </summary>
        /// <returns>Instance of <see cref="ViewLifetimeControl"/> that is associated with current window</returns>
        public static IViewLifetimeControl GetForCurrentView()
        {
            var wnd = Window.Current.CoreWindow;

            /*BUG: use this strange way to get Id as for ShareTarget hosted window on desktop version ApplicationView.GetForCurrentView() throws "Catastrofic failure" COMException.
             * Link to question on msdn: https://social.msdn.microsoft.com/Forums/security/en-US/efa50111-043a-4007-8af8-2b53f72ba207/uwp-c-xaml-comexception-catastrofic-failure-due-to-applicationviewgetforcurrentview-in?forum=wpdevelop  */
            return(WindowControlsMap.GetOrAdd(ApplicationView.GetApplicationViewIdForWindow(wnd), id => new ViewLifetimeControl(wnd)));
        }
예제 #15
0
 private WindowFrameService(Frame frame, WeakReference parent)
 {
     m_currentWindow  = CoreWindow.GetForCurrentThread();
     m_coreDispatcher = m_currentWindow.Dispatcher;
     m_frame          = frame;
     m_parent         = parent;
     m_viewId         = ApplicationView.GetApplicationViewIdForWindow(m_currentWindow);
 }
예제 #16
0
 protected override void Execute(object parameter)
 {
     _scheduler.Schedule(async() =>
     {
         var mainViewId = ApplicationView.GetApplicationViewIdForWindow(Window.Current.CoreWindow);
         await ApplicationViewSwitcher.TryShowAsStandaloneAsync(mainViewId);
     });
 }
        /* 複数ウィンドウでプレイヤーを一つだけ表示するための管理をしています
         *
         * 前提としてUnityContainer(PrismUnityApplication App.xaml.cs を参照)による依存性解決を利用しており
         * さらに「PerThreadLifetimeManager」を指定して依存解決時にウィンドウのUIスレッドごとに
         * PlayerViewManagerが生成されるように設定しています。
         *
         * これはObservableObjectによるINofityPropertyChangedイベントがウィンドウスレッドを越えて利用できないことが理由です。
         *
         * PlayerViewManagerはNowPlayingとPlayerViewModeの2つを公開プロパティとして保持しています。
         * NowPlaying
         *
         */

        // プレイヤーの表示状態を管理する
        // これまでHohoemaPlaylist、MenuNavigationViewModelBaseなどに散らばっていた

        public SecondaryViewPlayerManager(
            IScheduler scheduler,
            RestoreNavigationManager restoreNavigationManager
            )
        {
            _scheduler = scheduler;
            _restoreNavigationManager = restoreNavigationManager;
            MainViewId = ApplicationView.GetApplicationViewIdForWindow(CoreApplication.MainView.CoreWindow);
        }
예제 #18
0
        /* 複数ウィンドウでプレイヤーを一つだけ表示するための管理をしています
         *
         * 前提としてUnityContainer(PrismUnityApplication App.xaml.cs を参照)による依存性解決を利用しており
         * さらに「PerThreadLifetimeManager」を指定して依存解決時にウィンドウのUIスレッドごとに
         * PlayerViewManagerが生成されるように設定しています。
         *
         * これはBindableBaseによるINofityPropertyChangedイベントがウィンドウスレッドを越えて利用できないことが理由です。
         *
         * PlayerViewManagerはNowPlayingとPlayerViewModeの2つを公開プロパティとして保持しています。
         * NowPlaying
         *
         */

        // プレイヤーの表示状態を管理する
        // これまでHohoemaPlaylist、MenuNavigationViewModelBaseなどに散らばっていた

        public ScondaryViewPlayerManager(
            IScheduler scheduler,
            IEventAggregator eventAggregator
            )
        {
            _scheduler      = scheduler;
            EventAggregator = eventAggregator;
            MainViewId      = ApplicationView.GetApplicationViewIdForWindow(CoreApplication.MainView.CoreWindow);
        }
예제 #19
0
        private WindowAdministrator()
        {
            var coreWindow   = CoreApplication.GetCurrentView().CoreWindow;
            var mainWindowID = ApplicationView.GetApplicationViewIdForWindow(coreWindow);

            infos.Add(new WindowInfo {
                usage = WindowUsage.MainWindow, id = mainWindowID
            });
        }
예제 #20
0
        private void View_Consolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
        {
            var windowID = ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread());

            PlatformBase.CurrentCore.Logger.Log(LogLevels.Debug, $"Closed secondary window with ID {windowID}");
            AppWindows.Remove(windowID);
            ApplicationView.GetForCurrentView().Consolidated -= View_Consolidated;
            Window.Current.Close();
        }
예제 #21
0
        // 禁止通过 new 实例化
        private SecondaryViewHelper(CoreWindow newWindow)
        {
            _dispatcher = newWindow.Dispatcher;
            _viewId     = ApplicationView.GetApplicationViewIdForWindow(newWindow);

            _applicationView = ApplicationView.GetForCurrentView();

            RegisterForEvents();
        }
        // Instantiate views using "CreateForCurrentView"
        private ViewLifetimeController(CoreWindow newWindow)
        {
            dispatcher = newWindow.Dispatcher;
            window     = newWindow;
            viewId     = ApplicationView.GetApplicationViewIdForWindow(window);

            // This class will automatically tell the view when its time to close
            // or stay alive in a few cases
            RegisterForEvents();
        }
예제 #23
0
        // public INavigationService NavigationService { get; set; }
        #endregion

        private ViewLifetimeControl(CoreWindow newWindow)
        {
            CoreDispatcher = newWindow.Dispatcher;
            WindowWrapper  = Services.WindowWrapper.WindowWrapper.Current();
            Id             = ApplicationView.GetApplicationViewIdForWindow(newWindow);

            // This class will automatically tell the view when its time to close
            // or stay alive in a few cases
            RegisterForEvents();
        }
예제 #24
0
        internal static async Task <AuthResult> AuthenticateAsync(Uri requestUri, Uri callbackUri)
        {
            //var broker = new WebAuthBrokerOld();
            CoreApplicationView newView = CoreApplication.CreateNewView();
            int      newViewId          = 0;
            var      tcs    = new TaskCompletionSource <AuthResult>();
            AuthPage broker = null;
            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Frame frame = new Frame();
                frame.Navigate(typeof(AuthPage));
                broker         = frame.Content as AuthPage;
                broker.Loaded += (sender, e) => broker.MainWebView.Navigate(requestUri);
                broker.MainWebView.NavigationStarting += (sender, e) =>
                {
                    var uriString = e.Uri.ToString();
                    if (uriString.StartsWith(callbackUri.OriginalString))
                    {
                        if (!CoreApplication.GetCurrentView().IsMain)
                        {
                            Window.Current.Close();
                        }
                        var parsedResult = ParseAuthResult(e.Uri.OriginalString);
                        if (parsedResult.ContainsKey("error"))
                        {
                            tcs.SetResult(new AuthResult(null, AuthResponseStatus.UserCancel));
                        }
                        else
                        {
                            tcs.SetResult(new AuthResult(ParseAuthResult(e.Uri.OriginalString), AuthResponseStatus.Success));
                        }
                    }
                };
                SystemNavigationManager.GetForCurrentView().BackRequested += (sender, e) =>
                {
                    var isSet = tcs.TrySetResult(new AuthResult(null, AuthResponseStatus.UserCancel));
                };
                ApplicationView.GetForCurrentView().Consolidated += (sender, e) =>
                {
                    var isSet = tcs.TrySetResult(new AuthResult(null, AuthResponseStatus.UserCancel));
                    if (!CoreApplication.GetCurrentView().IsMain)
                    {
                        Window.Current.Close();
                    }
                };
                Window.Current.Content = frame;
                Window.Current.Activate();
                newViewId = ApplicationView.GetApplicationViewIdForWindow(newView.CoreWindow);
            });

            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

            return(await tcs.Task);
        }
예제 #25
0
        private async void ShowCompactButton_Click(object sender, RoutedEventArgs e)
        {
            if (LyricsView != null)
            {
                return;
            }

            var mainWindow = CoreWindow.GetForCurrentThread();
            var mainViewId = ApplicationView.GetApplicationViewIdForWindow(mainWindow);

            #region Create a new View ,named LyricsView
            var currentView = CoreApplication.CreateNewView();
            await currentView.Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                LyricsView = ApplicationView.GetForCurrentView();
                LyricsView.Consolidated += LyricsView_Consolidated;

                #region Set the content of Window in LyricsView
                var rootContainer = new Grid()
                {
                    Background = new SolidColorBrush()
                    {
                        Color = Colors.Black
                    }
                };
                var lyricTextBlock = new TextBlock()
                {
                    Foreground = new SolidColorBrush()
                    {
                        Color = Colors.White
                    },
                    Text = "I'm lyrics window.",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    FontSize            = 20
                };
                rootContainer.Children.Add(lyricTextBlock);
                Window.Current.Content = rootContainer;
                Window.Current.Activate();
                #endregion

                #region Show the LyricsView as standalone
                var currentWindow = CoreWindow.GetForCurrentThread();
                var viewId        = ApplicationView.GetApplicationViewIdForWindow(currentWindow);
                var viewShown     = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(viewId, ViewSizePreference.Default, mainViewId, ViewSizePreference.Default);
                #endregion

                #region Set the LyricsView as CompactOverlay mode
                await LyricsView.TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
                #endregion
            });

            #endregion
        }
예제 #26
0
        private async Task CreateSecondaryView()
        {
            var secondaryView = CoreApplication.CreateNewView();

            var result = await secondaryView.ExecuteOnUIThreadAsync(async() =>
            {
                secondaryView.TitleBar.ExtendViewIntoTitleBar = true;

                var content = new Views.SecondaryViewCoreLayout();

                var ns = content.CreateNavigationService();
                await ns.NavigateAsync(nameof(Views.BlankPage));

                Window.Current.Content = content;

                var id = ApplicationView.GetApplicationViewIdForWindow(secondaryView.CoreWindow);

                var view = ApplicationView.GetForCurrentView();

                view.TitleBar.ButtonBackgroundColor         = Windows.UI.Colors.Transparent;
                view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent;

                await Task.Delay(250);

                Window.Current.Activate();

                await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.UseHalf, MainViewId, ViewSizePreference.UseHalf);

                // ウィンドウサイズの保存と復元
                if (Services.Helpers.DeviceTypeHelper.IsDesktop)
                {
                    var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                    if (localObjectStorageHelper.KeyExists(secondary_view_size))
                    {
                        view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size));
                    }

                    view.VisibleBoundsChanged += View_VisibleBoundsChanged;
                }

                view.Consolidated += SecondaryAppView_Consolidated;

                return(id, view, ns);
            });

            SecondaryAppView     = result.view;
            SecondaryCoreAppView = secondaryView;
            SecondaryViewPlayerNavigationService = result.ns;

            var primaryView = ApplicationView.GetForCurrentView();

            primaryView.Consolidated += MainView_Consolidated;
        }
예제 #27
0
        // Instantiate views using "CreateForCurrentView"
        private ViewLifetimeControl(CoreWindow newWindow)
        {
            _window        = newWindow;
            _referenceLock = new object();

            Dispatcher = newWindow.Dispatcher;
            Id         = ApplicationView.GetApplicationViewIdForWindow(_window);

            // This class will automatically tell the view when its time to close
            // or stay alive in a few cases
            RegisterForEvents();
        }
예제 #28
0
        public const char LRO = (char)0x202d; // Left-to-Right Override

        // Returns windowId for the current view
        public static int GetWindowId()
        {
            int windowId = -1;

            var window = CoreWindow.GetForCurrentThread();

            if (window != null)
            {
                windowId = ApplicationView.GetApplicationViewIdForWindow(window);
            }

            return(windowId);
        }
 private async void LaunchSecondaryViewButton_Click(object sender, RoutedEventArgs e)
 {
     var newView = CoreApplication.CreateNewView();
     await newView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         var frame = new Frame();
         frame.Navigate(typeof(SecondaryViewPage));
         Window.Current.Content = frame;
         // This is a change from 8.1: In order for the view to be displayed later it needs to be activated.
         Window.Current.Activate();
         await ApplicationViewSwitcher.TryShowAsStandaloneAsync(ApplicationView.GetApplicationViewIdForWindow(Windows.UI.Core.CoreWindow.GetForCurrentThread()));
     });
 }
예제 #30
0
        private async void ShowWindowButton_Click(object sender, RoutedEventArgs e)
        {
            if (moveSelectCB.SelectedIndex == 1)
            {
                move_independently = true;
            }

            await SetupSubPage();

            var currentViewId = ApplicationView.GetForCurrentView().Id;

            if (sensorCB.SelectedIndex == 1)
            {
                await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    Window.Current.Content = new Frame();
                    ((Frame)Window.Current.Content).Navigate(typeof(SensorDataPage));

                    Window.Current.Activate();
                    await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                        ApplicationView.GetApplicationViewIdForWindow(Window.Current.CoreWindow),
                        ViewSizePreference.Default,
                        currentViewId,
                        ViewSizePreference.Default);
                });

                use_sensor = true;
            }

            if (cameraCB.SelectedIndex == 1)
            {
                await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    Window.Current.Content = new Frame();

                    ((Frame)Window.Current.Content).Navigate(typeof(CameraViewPage));

                    Window.Current.Activate();
                    await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                        ApplicationView.GetApplicationViewIdForWindow(Window.Current.CoreWindow),
                        ViewSizePreference.Default,
                        currentViewId,
                        ViewSizePreference.Default);
                });

                use_camera = true;
            }

            showWindowButton.IsEnabled = false;
            startTrialButton.IsEnabled = true;
        }