/// <summary> /// Opens the currently playing media item in full screen mode /// </summary> public void FullScreen() { Boolean playOnLoad = false; TimeSpan position = Position; Int32 selectedIndex = SelectedIndex; switch (PlayState) { case PlayStateEnum.Stopped: return; case PlayStateEnum.Playing: mipPlayer.Stop(); playOnLoad = true; break; case PlayStateEnum.Paused: mipPlayer.Stop(); break; } FullScreenDialog fsd = new FullScreenDialog(playOnLoad, position); fsd.Owner = Application.Current.MainWindow; fsd.MediaItems = MediaItems; fsd.SelectedIndex = selectedIndex; fsd.Volume = Volume; fsd.Options = Options; fsd.OpeningMediaItem += new CancelMediaItemsOperationEventHandler(player_OpeningMediaItem); fsd.OpeningMediaItemPart += new MediaItemPartEventHandler(player_OpeningMediaItemPart); fsd.MediaItemSaved += new MediaItemEventHandler(element_MediaItemSaved); fsd.MediaItemEnded += new MediaItemEventHandler(player_MediaItemEnded); fsd.PlayStateChanged += player_PlayStateChanged; fsd.ShowDialog(); Volume = fsd.Volume; Options.ShowTimeRemaining = fsd.Options.ShowTimeRemaining; if (fsd.SelectedIndex == -1) { mipPlayer.Stop(); } else { mipPlayer.Play(); SelectedIndex = fsd.SelectedIndex; Position = fsd.Position; } }
private Task <bool> ShowCustomDialogAsync <T>(string title, T dialogContent) where T : ICustomDialogContent { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException(nameof(title)); } if (this.navigationService.HasFlyoutOpened) { this.navigationService.CloseFlyouts(); } var tcs = new TaskCompletionSource <bool>(); var customDialog = new FullScreenDialog { Title = title, BackButtonVisibility = Visibility.Visible, Background = Application.Current.Resources["AppFlyoutBackgroundBrush"] as SolidColorBrush, HorizontalAlignment = HorizontalAlignment.Stretch, }; var frame = Window.Current.Content as Frame; var page = frame.Content as Page; var panel = page.Content as Panel; if (this.navigationService.HasFlyoutOpened) { var flyout = this.navigationService.PeekFlyout(); Panel panelFlyout = null; if (flyout.Content is Panel) { panelFlyout = flyout.Content as Panel; } else if (flyout.Content is Page) { panelFlyout = ((Page)flyout.Content).Content as Panel; } if (panelFlyout != null) { customDialog.ForceWidth((double)flyout.Size); panel = panelFlyout; } } if (panel == null) { throw new NotSupportedException("Could not find a panel in the page of flyout"); } customDialog.Content = dialogContent; panel.Children.Add(customDialog); RoutedEventHandler backButtonHandler = null; backButtonHandler = (s, e) => { customDialog.BackButtonClicked -= backButtonHandler; tcs.SetResult(false); panel.Children.Remove(customDialog); dialogContent.OnDismissed(); customDialog.IsOpen = false; }; EventHandler requestCloseHandler = null; requestCloseHandler = (s, e) => { dialogContent.RequestClose -= requestCloseHandler; tcs.SetResult(true); panel.Children.Remove(customDialog); dialogContent.OnDismissed(); customDialog.IsOpen = false; }; dialogContent.RequestClose += requestCloseHandler; customDialog.BackButtonClicked += backButtonHandler; customDialog.IsOpen = true; return(tcs.Task); }