public BoxElement GetRenderedCue(WebVTTCue cue) { var alignment = cue.Settings.Alignment; var result = new BoxElement(); if (OutlineWidth > 0) { // create adjacent textblocks var textBlockOutline1 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Left, new TranslateTransform() { X = -OutlineWidth, Y = 0 }); textBlockOutline1.Margin = new Thickness(OutlineWidth); var textBlockOutline2 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Top, new TranslateTransform { X = 0, Y = -OutlineWidth }); textBlockOutline2.Margin = new Thickness(OutlineWidth); var textBlockOutline3 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Right, new TranslateTransform { X = OutlineWidth, Y = 0 }); textBlockOutline3.Margin = new Thickness(OutlineWidth); var textBlockOutline4 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Bottom, new TranslateTransform { X = 0, Y = OutlineWidth }); textBlockOutline4.Margin = new Thickness(OutlineWidth); // create diagonal textblocks var textBlockOutline5 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.TopLeft, new TranslateTransform { X = -OutlineWidth, Y = -OutlineWidth }); textBlockOutline5.Margin = new Thickness(OutlineWidth); var textBlockOutline6 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.TopRight, new TranslateTransform { X = OutlineWidth, Y = -OutlineWidth }); textBlockOutline6.Margin = new Thickness(OutlineWidth); var textBlockOutline7 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.BottomRight, new TranslateTransform { X = OutlineWidth, Y = OutlineWidth }); textBlockOutline7.Margin = new Thickness(OutlineWidth); var textBlockOutline8 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.BottomLeft, new TranslateTransform { X = -OutlineWidth, Y = OutlineWidth }); textBlockOutline8.Margin = new Thickness(OutlineWidth); result.AddBlock(textBlockOutline1); result.AddBlock(textBlockOutline2); result.AddBlock(textBlockOutline3); result.AddBlock(textBlockOutline4); result.AddBlock(textBlockOutline5); result.AddBlock(textBlockOutline6); result.AddBlock(textBlockOutline7); result.AddBlock(textBlockOutline8); } var textBlock = GetRenderedCueTextBlock(cue, alignment, InnerBrush, TextPosition.Center); textBlock.Margin = new Thickness(OutlineWidth); result.AddBlock(textBlock); return result; }
private void AddCue(WebVTTCue cue) { BoxElement element = renderer.GetRenderedCue(cue); if (BoxStyle != null) { element.Style = BoxStyle; } element.FontSize = currentFontSize; WebVTTLayoutPanel.SetAlignment(element, GetPanelAlignment(cue.Settings.Alignment)); WebVTTLayoutPanel.SetDirection(element, GetPanelAlignment(cue.Settings.WritingMode, cue.Content)); WebVTTLayoutPanel.SetLinePosition(element, cue.Settings.LinePosition); WebVTTLayoutPanel.SetOrientation(element, GetPanelOrientation(cue.Settings.WritingMode)); WebVTTLayoutPanel.SetPosition(element, cue.Settings.TextPosition); WebVTTLayoutPanel.SetSize(element, cue.Settings.Size); WebVTTLayoutPanel.SetSnapToLines(element, cue.Settings.SnapToLines); activeElements.Add(cue, element); captionPanel.Children.Add(element); }
public BoxElement GetRenderedCue(WebVTTCue cue) { var alignment = cue.Settings.Alignment; var result = new BoxElement(); if (OutlineWidth > 0) { // create adjacent textblocks var textBlockOutline1 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Left, new TranslateTransform() { X = -OutlineWidth, Y = 0 }); textBlockOutline1.Margin = new Thickness(OutlineWidth); var textBlockOutline2 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Top, new TranslateTransform { X = 0, Y = -OutlineWidth }); textBlockOutline2.Margin = new Thickness(OutlineWidth); var textBlockOutline3 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Right, new TranslateTransform { X = OutlineWidth, Y = 0 }); textBlockOutline3.Margin = new Thickness(OutlineWidth); var textBlockOutline4 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.Bottom, new TranslateTransform { X = 0, Y = OutlineWidth }); textBlockOutline4.Margin = new Thickness(OutlineWidth); // create diagonal textblocks var textBlockOutline5 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.TopLeft, new TranslateTransform { X = -OutlineWidth, Y = -OutlineWidth }); textBlockOutline5.Margin = new Thickness(OutlineWidth); var textBlockOutline6 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.TopRight, new TranslateTransform { X = OutlineWidth, Y = -OutlineWidth }); textBlockOutline6.Margin = new Thickness(OutlineWidth); var textBlockOutline7 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.BottomRight, new TranslateTransform { X = OutlineWidth, Y = OutlineWidth }); textBlockOutline7.Margin = new Thickness(OutlineWidth); var textBlockOutline8 = GetRenderedCueTextBlock(cue, alignment, OutlineBrush, TextPosition.BottomLeft, new TranslateTransform { X = -OutlineWidth, Y = OutlineWidth }); textBlockOutline8.Margin = new Thickness(OutlineWidth); result.AddBlock(textBlockOutline1); result.AddBlock(textBlockOutline2); result.AddBlock(textBlockOutline3); result.AddBlock(textBlockOutline4); result.AddBlock(textBlockOutline5); result.AddBlock(textBlockOutline6); result.AddBlock(textBlockOutline7); result.AddBlock(textBlockOutline8); } var textBlock = GetRenderedCueTextBlock(cue, alignment, InnerBrush, TextPosition.Center); textBlock.Margin = new Thickness(OutlineWidth); result.AddBlock(textBlock); return(result); }