/// <summary> /// Apply the font style /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyFontStyle(CaptionTextEventArgs e) { switch (ClosedCaptionProperties.FontEffect) { case ClosedCaptionEdgeEffect.Default: break; case ClosedCaptionEdgeEffect.DropShadow: this.ApplyDropShadow(e); break; case ClosedCaptionEdgeEffect.Uniform: break; case ClosedCaptionEdgeEffect.Depressed: this.ApplyDepressedEdge(e); break; case ClosedCaptionEdgeEffect.None: if (e.Position != TextPosition.Center) { e.TextBlock.Visibility = Visibility.Collapsed; } break; case ClosedCaptionEdgeEffect.Raised: this.ApplyRaisedEdge(e); break; } }
/// <summary> /// If a Text rendering handler is registered, call it. /// </summary> /// <param name="sender">the sender</param> /// <param name="e">the caption text event arguments</param> private void OnTextRendering(object sender, CaptionTextEventArgs e) { if (this.TextRendering != null) { this.TextRendering(this, e); } }
/// <summary> /// Apply the font style /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyFontStyle(CaptionTextEventArgs e) { switch (this.Settings.FontStyle) { case PlayerFramework.CaptionSettings.Model.FontStyle.Default: break; case PlayerFramework.CaptionSettings.Model.FontStyle.DropShadow: this.ApplyDropShadow(e); break; case PlayerFramework.CaptionSettings.Model.FontStyle.Outline: break; case PlayerFramework.CaptionSettings.Model.FontStyle.DepressedEdge: this.ApplyDepressedEdge(e); break; case PlayerFramework.CaptionSettings.Model.FontStyle.None: if (e.Position != TextPosition.Center) { e.TextBlock.Visibility = Visibility.Collapsed; } break; case PlayerFramework.CaptionSettings.Model.FontStyle.RaisedEdge: this.ApplyRaisedEdge(e); break; } }
/// <summary> /// Text is about to be rendered so apply any styles /// </summary> /// <param name="sender">the sender</param> /// <param name="e">the caption text event arguments</param> private void OnTextRendering(object sender, CaptionTextEventArgs e) { this.ApplyFontFamily(e); this.ApplyTextColor(e); this.ApplyFontStyle(e); }
/// <summary> /// Apply the text color /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyTextColor(CaptionTextEventArgs e) { if (e.Position == TextPosition.Center && this.Settings.FontColor != null) { var fontColor = this.Settings.FontColor.ToColor(); e.TextBlock.Foreground = new Media.SolidColorBrush(fontColor); } }
/// <summary> /// Text is about to be rendered so apply any styles /// </summary> /// <param name="sender">the sender</param> /// <param name="e">the caption text event arguments</param> private void OnTextRendering(object sender, CaptionTextEventArgs e) { if (this.Settings == null || this.IsDefault) { return; } this.ApplyFontFamily(e); this.ApplyTextColor(e); this.ApplyFontStyle(e); }
/// <summary> /// Apply the text color /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyTextColor(CaptionTextEventArgs e) { if (e.Position == TextPosition.Center && (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default || ClosedCaptionProperties.FontOpacity != ClosedCaptionOpacity.Default)) { if (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default) { e.TextBlock.Foreground = new SolidColorBrush(ClosedCaptionProperties.ComputedFontColor); } if (ClosedCaptionProperties.FontOpacity != ClosedCaptionOpacity.Default) { e.TextBlock.Opacity = GetComputedOpacity(ClosedCaptionProperties.FontOpacity); } } }
/// <summary> /// Apply the font family /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyFontFamily(CaptionTextEventArgs e) { switch (ClosedCaptionProperties.FontStyle) { case ClosedCaptionStyle.SmallCapitals: Typography.SetCapitals(e.TextBlock, FontCapitals.SmallCaps); break; case ClosedCaptionStyle.Default: break; default: e.TextBlock.FontFamily = GetFont(); break; } }
/// <summary> /// Apply the font family /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyFontFamily(CaptionTextEventArgs e) { switch (this.Settings.FontFamily) { case PlayerFramework.CaptionSettings.Model.FontFamily.Smallcaps: Typography.SetCapitals(e.TextBlock, FontCapitals.SmallCaps); break; case PlayerFramework.CaptionSettings.Model.FontFamily.Default: break; default: e.TextBlock.FontFamily = this.GetFont(); break; } }
/// <summary> /// Apply a drop shadow text effect /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyDropShadow(CaptionTextEventArgs e) { var plugin = this.MediaPlayer.GetWebVTTPlugin(); var fontSize = plugin.CaptionsPanel.FontSize; var offset = this.DropShadowOffset; if (ClosedCaptionProperties.FontSize != ClosedCaptionSize.Default) { offset = this.DropShadowOffset * GetComputedFontPercent(ClosedCaptionProperties.FontSize); } switch (e.Position) { case TextPosition.Center: break; case TextPosition.Bottom: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new TranslateTransform { Y = offset }; break; case TextPosition.BottomRight: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new TranslateTransform { X = offset, Y = offset }; break; case TextPosition.Right: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new TranslateTransform { X = offset }; break; default: e.TextBlock.Visibility = Visibility.Collapsed; break; } }
/// <summary> /// Apply a drop shadow text effect /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyDropShadow(CaptionTextEventArgs e) { var plugin = this.MediaPlayer.GetWebVTTPlugin(); var fontSize = plugin.CaptionsPanel.FontSize; var offset = this.DropShadowOffset; if (this.Settings.FontSize.HasValue) { offset = this.DropShadowOffset * System.Convert.ToDouble(this.Settings.FontSize.Value) / 100.0; } switch (e.Position) { case TextPosition.Center: break; case TextPosition.Bottom: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new Media.TranslateTransform { Y = offset }; break; case TextPosition.BottomRight: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new Media.TranslateTransform { X = offset, Y = offset }; break; case TextPosition.Right: e.TextBlock.Foreground = this.DropShadowBrush; e.TextBlock.RenderTransform = new Media.TranslateTransform { X = offset }; break; default: e.TextBlock.Visibility = Visibility.Collapsed; break; } }
/// <summary> /// Apply dark overlay to the upper left text blocks /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyDepressedEdge(CaptionTextEventArgs e) { var offset = this.EdgeOffset; if (ClosedCaptionProperties.FontSize != ClosedCaptionSize.Default) { offset = this.EdgeOffset * GetComputedFontPercent(ClosedCaptionProperties.FontSize); } switch (e.Position) { case TextPosition.Center: break; case TextPosition.TopRight: case TextPosition.Bottom: case TextPosition.Right: case TextPosition.BottomLeft: case TextPosition.BottomRight: e.TextBlock.Visibility = Visibility.Collapsed; break; case TextPosition.TopLeft: e.TextBlock.RenderTransform = new TranslateTransform { X = -offset, Y = -offset }; break; case TextPosition.Top: e.TextBlock.RenderTransform = new TranslateTransform { Y = -offset }; break; case TextPosition.Left: e.TextBlock.RenderTransform = new TranslateTransform { X = -offset }; break; } }
/// <summary> /// Apply dark overlay to the upper left text blocks /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyDepressedEdge(CaptionTextEventArgs e) { var offset = this.EdgeOffset; if (this.Settings.FontSize.HasValue) { offset = this.EdgeOffset * System.Convert.ToDouble(this.Settings.FontSize.Value) / 100.0; } switch (e.Position) { case TextPosition.Center: break; case TextPosition.TopRight: case TextPosition.Bottom: case TextPosition.Right: case TextPosition.BottomLeft: case TextPosition.BottomRight: e.TextBlock.Visibility = Visibility.Collapsed; break; case TextPosition.TopLeft: e.TextBlock.RenderTransform = new Media.TranslateTransform { X = -offset, Y = -offset }; break; case TextPosition.Top: e.TextBlock.RenderTransform = new Media.TranslateTransform { Y = -offset }; break; case TextPosition.Left: e.TextBlock.RenderTransform = new Media.TranslateTransform { X = -offset }; break; } }
/// <summary> /// Apply the text color /// </summary> /// <param name="e">the caption text event arguments</param> private void ApplyTextColor(CaptionTextEventArgs e) { if (e.Position == TextPosition.Center && (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default || ClosedCaptionProperties.FontOpacity != ClosedCaptionOpacity.Default)) { if (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default) e.TextBlock.Foreground = new SolidColorBrush(ClosedCaptionProperties.ComputedFontColor); if (ClosedCaptionProperties.FontOpacity != ClosedCaptionOpacity.Default) e.TextBlock.Opacity = GetComputedOpacity(ClosedCaptionProperties.FontOpacity); } }