/// <summary> /// Show the caption settings /// </summary> /// <param name="command">the command</param> private void OnShowCaptionSettings(IUICommand command) { if (this.OnLoadCaptionSettings != null) { this.OnLoadCaptionSettings(this, new CustomCaptionSettingsEventArgs(this.Settings)); } this.windowBounds = Window.Current.Bounds; var transitions = new TransitionCollection(); transitions.Add(new EntranceThemeTransition()); Window.Current.Activated += this.Current_Activated; var control = new CaptionSettingsControl { CaptionSettings = this.Settings, IsDefault = this.IsDefault, }; control.OnApplyCaptionSettings += this.OnApplyCaptionSettings; control.IsDefaultChanged += delegate(object sender, System.EventArgs e) { this.IsDefault = control.IsDefault; this.ApplyCaptionSettings(this.Settings); }; var settingsControl = new SettingsControl { Style = this.Style, Label = this.Label, Content = control, Width = NarrowWidth, Height = this.windowBounds.Height }; this.settingsPopup = new Popup { Child = settingsControl, Transitions = transitions, IsLightDismissEnabled = true, Width = NarrowWidth, Height = this.windowBounds.Height, }; this.settingsPopup.Closed += this.OnPopupClosed; this.settingsPopup.SetValue(Canvas.LeftProperty, this.windowBounds.Width - NarrowWidth); this.settingsPopup.SetValue(Canvas.TopProperty, 0); this.settingsPopup.IsOpen = true; }
/// <summary> /// Show the settings pane as a popup /// </summary> /// <param name="page">the current phone application page</param> /// <param name="parent">the parent panel on the page (typically the /// LayoutRoot Grid)</param> /// <param name="pauseVideo">true to pause the video when the popup is /// shown and play it when the popup is hidden.</param> public void ShowSettingsPopup(Page page, Panel parent, bool pauseVideo = false) { if (this.popup != null && this.popup.IsOpen) { return; } this.pauseVideo = pauseVideo; bool isEnabled = false; object value; if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue(CaptionSettingsPage.OverrideDefaultKey, out value)) { isEnabled = (bool)value; } if (this.Settings == null) { this.Activate(); this.Settings.PropertyChanged += this.Settings_PropertyChanged; } if (!isEnabled) { this.Settings.BackgroundColor = null; this.Settings.FontColor = null; this.Settings.FontFamily = Model.FontFamily.Default; this.Settings.FontSize = null; this.Settings.FontStyle = Model.FontStyle.Default; this.Settings.WindowColor = null; } Border border = null; if (this.popup == null) { this.control = new CaptionSettingsControl { ApplyCaptionSettings = this.ApplyCaptionSettings, Settings = this.Settings, Page = page, Width = page.ActualWidth, Height = page.ActualHeight, Style = this.CaptionSettingsControlStyle, IsOverrideDefaults = isEnabled }; this.popup = new Popup { Child = new Border { Child = this.control } }; this.popup.Opened += delegate(object sender, object e) { if (this.MediaPlayer != null) { this.MediaPlayer.IsEnabled = false; if (this.pauseVideo) { if (this.MediaPlayer.CurrentState == MediaElementState.Playing) { this.resumeVideo = true; this.MediaPlayer.InteractiveViewModel.Pause(); } } } HardwareButtons.BackPressed += HardwareButtons_BackPressed; this.IsPopupOpen = true; }; this.popup.Closed += delegate(object sender, object e) { if (this.MediaPlayer != null) { this.MediaPlayer.IsEnabled = true; if (this.resumeVideo) { if (this.MediaPlayer.CurrentState == MediaElementState.Paused) { this.MediaPlayer.InteractiveViewModel.PlayResume(); } } } HardwareButtons.BackPressed -= HardwareButtons_BackPressed; this.IsPopupOpen = false; if (this.PopupClosed != null) { this.PopupClosed(this, e); } }; if (parent != null) { parent.Children.Add(this.popup); } border = this.popup.Child as Border; } else { border = this.popup.Child as Border; var control = border.Child as CaptionSettingsControl; control.Page = page; control.Style = this.CaptionSettingsControlStyle; control.IsOverrideDefaults = isEnabled; } if (this.MediaPlayer == null) { border.Background = new SolidColorBrush(Colors.Black); } else { border.Background = null; } this.popup.IsOpen = true; }
/// <summary> /// Show the settings pane as a popup /// </summary> /// <param name="page">the current phone application page</param> /// <param name="parent">the parent panel on the page (typically the /// LayoutRoot Grid)</param> /// <param name="pauseVideo">true to pause the video when the popup is /// shown and play it when the popup is hidden.</param> public void ShowSettingsPopup(Page page, Panel parent, bool pauseVideo = false) { if (this.popup != null && this.popup.IsOpen) { return; } this.pauseVideo = pauseVideo; bool isEnabled = false; object value; if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue(CaptionSettingsPage.OverrideDefaultKey, out value)) { isEnabled = (bool)value; } if (this.Settings == null) { this.Activate(); this.Settings.PropertyChanged += this.Settings_PropertyChanged; } if (!isEnabled) { this.Settings.BackgroundColor = null; this.Settings.FontColor = null; this.Settings.FontFamily = Model.FontFamily.Default; this.Settings.FontSize = null; this.Settings.FontStyle = Model.FontStyle.Default; this.Settings.WindowColor = null; } Border border = null; if (this.popup == null) { this.control = new CaptionSettingsControl { ApplyCaptionSettings = this.ApplyCaptionSettings, Settings = this.Settings, Page = page, Width = page.ActualWidth, Height = page.ActualHeight, Style = this.CaptionSettingsControlStyle, IsOverrideDefaults = isEnabled }; this.popup = new Popup { Child = new Border { Child = this.control } }; this.popup.Opened += delegate(object sender, object e) { if (this.MediaPlayer != null) { this.MediaPlayer.IsEnabled = false; if (this.pauseVideo) { if (this.MediaPlayer.CurrentState == MediaElementState.Playing) { this.resumeVideo = true; this.MediaPlayer.InteractiveViewModel.Pause(); } } } HardwareButtons.BackPressed += HardwareButtons_BackPressed; this.IsPopupOpen = true; }; this.popup.Closed += delegate(object sender, object e) { if (this.MediaPlayer != null) { this.MediaPlayer.IsEnabled = true; if (this.resumeVideo) { if (this.MediaPlayer.CurrentState == MediaElementState.Paused) { this.MediaPlayer.InteractiveViewModel.PlayResume(); } } } HardwareButtons.BackPressed -= HardwareButtons_BackPressed; this.IsPopupOpen = false; if (this.PopupClosed != null) { this.PopupClosed(this, e); } }; if (parent != null) { parent.Children.Add(this.popup); } border = this.popup.Child as Border; } else { border = this.popup.Child as Border; var control = border.Child as CaptionSettingsControl; control.Page = page; control.Style = this.CaptionSettingsControlStyle; control.IsOverrideDefaults = isEnabled; } if (this.MediaPlayer == null) { border.Background = new SolidColorBrush(Colors.Black); } else { border.Background = null; } this.popup.IsOpen = true; }