private async Task ProjectioinViewToScreen(DevicePicker sender, DeviceSelectedEventArgs args) { // 更新 picker 上設備的 status sender.SetDisplayStatus(args.SelectedDevice, "Connecting", DevicePickerDisplayStatusOptions.ShowProgress); // 取得目前選到設備的資訊 activeDevice = args.SelectedDevice; // 現在 view 的 Id 與 CoreDispatcher int currentViewId = ApplicationView.GetForCurrentView().Id; CoreDispatcher currentDispatcher = Window.Current.Dispatcher; // 建立新的 view, if (projectionInstance.ProjectionViewPageControl == null) { await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // 建立新 viewe 的生命管理器 projectionInstance.ProjectionViewPageControl = ViewLifetimeControl.CreateForCurrentView(); projectionInstance.MainViewId = currentViewId; var rootFrame = new Frame(); rootFrame.Navigate(typeof(ProjectionPage), projectionInstance); // 這裏的 Window 代表是新建立這個 view 的 Window // 但是要等到呼叫 ProjectionManager.StartProjectingAsync 才會顯示 Window.Current.Content = rootFrame; Window.Current.Activate(); }); } // 直接切換到指定的 view id //bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(projectionInstance.ProjectionViewPageControl.Id); // 通知要使用新的 view projectionInstance.ProjectionViewPageControl.StartViewInUse(); await ProjectionManager.SwapDisplaysForViewsAsync(projectionInstance.ProjectionViewPageControl.Id, currentViewId); try { await ProjectionManager.StartProjectingAsync(projectionInstance.ProjectionViewPageControl.Id, currentViewId, activeDevice); player.Pause(); sender.SetDisplayStatus(args.SelectedDevice, "connected", DevicePickerDisplayStatusOptions.ShowDisconnectButton); } catch (Exception ex) { sender.SetDisplayStatus(args.SelectedDevice, ex.Message, DevicePickerDisplayStatusOptions.ShowRetryButton); if (ProjectionManager.ProjectionDisplayAvailable == false) { throw; } } }
public async void SwapViews() { // The view might arrive on the wrong display. The user can // easily swap the display on which the view appears broker.ProjectionViewPageControl.StartViewInUse(); await ProjectionManager.SwapDisplaysForViewsAsync( ApplicationView.GetForCurrentView().Id, broker.MainViewId ); broker.ProjectionViewPageControl.StopViewInUse(); }
private async void SwapViews_Click(object sender, RoutedEventArgs e) { // The view might arrive on the wrong display. The user can // easily swap the display on which the view appears thisViewControl.StartViewInUse(); await ProjectionManager.SwapDisplaysForViewsAsync( ApplicationView.GetForCurrentView().Id, mainViewId ); thisViewControl.StopViewInUse(); }
public ProjectionViewPage() { this.InitializeComponent(); Loaded += async(s, e) => { thisViewControl.StartViewInUse(); await ProjectionManager.SwapDisplaysForViewsAsync(secondViewId, mainViewId); thisViewControl.StopViewInUse(); }; }
public async Task SwapProjection() { try { if (projecting) { await ProjectionManager.SwapDisplaysForViewsAsync(externalViewId, ApplicationView.GetForCurrentView().Id); } } catch (Exception ex) { Debug.WriteLine("SwapProjection: " + ex.Message); } }
public async Task SwapProjection(int mainViewId) { await ProjectionManager.SwapDisplaysForViewsAsync( ApplicationView.GetForCurrentView().Id, mainViewId); }