/// <summary> /// update the capitals for all of the TextBlock elements in a panel. /// </summary> /// <param name="customCaptionSettings">the custom caption settings /// </param> /// <param name="panel">the panel</param> /// <exception cref="ArgumentNullException">if customCaptionSettings /// or panel are null.</exception> private static void UpdateCaptials( CustomCaptionSettings customCaptionSettings, Panel panel) { if (customCaptionSettings == null) { throw new ArgumentNullException( "customCaptionSettings", "customCaptionSettings cannot be null."); } if (panel == null) { throw new ArgumentNullException( "panel", "panel cannot be null."); } var children = panel.Children.OfType <TextBlock>(); foreach (var item in children) { if (customCaptionSettings.FontFamily == Model.FontFamily.Smallcaps) { Typography.SetCapitals(item, FontCapitals.SmallCaps); } else { Typography.SetCapitals(item, FontCapitals.Normal); } ////System.Diagnostics.Debug.WriteLine("Captials for {0} are {1}", item.Name, Typography.GetCapitals(item)); } }
/// <summary> /// update the capitals for all of the TextBlock elements in a panel. /// </summary> /// <param name="customCaptionSettings">the custom caption settings /// </param> /// <param name="panel">the panel</param> /// <exception cref="ArgumentNullException">if customCaptionSettings /// or panel are null.</exception> private static void UpdateCaptials( CustomCaptionSettings customCaptionSettings, Panel panel) { if (customCaptionSettings == null) { throw new ArgumentNullException( "customCaptionSettings", "customCaptionSettings cannot be null."); } if (panel == null) { return; } var children = panel.Children.OfType <TextBlock>(); foreach (var item in children) { if (customCaptionSettings.FontFamily == Model.FontFamily.Smallcaps) { Typography.SetCapitals(item, FontCapitals.SmallCaps); } else { Typography.SetCapitals(item, FontCapitals.Normal); } } }
/// <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 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> /// Copy the attributes from the textBlock to the new text blocks /// </summary> /// <param name="textBlock">the original text block</param> /// <param name="newTextBlocks">the new text blocks</param> /// <param name="parent">the parent to add the new items to</param> /// <param name="opacity">the opacity to use</param> /// <param name="zIndex">the z index to use for the new text blocks</param> private static void CopyAttributes(TextBlock textBlock, TextBlock[] newTextBlocks, UIElement parent, double opacity, int zIndex = 1) { var border = parent as Border; Panel panel; if (border != null) { panel = new Grid(); border.Child = panel; panel.Children.Add(textBlock); } else { panel = parent as Panel; } foreach (var item in newTextBlocks) { item.Foreground = new Media.SolidColorBrush(ColorsNS.Colors.Black); item.Text = textBlock.Text; item.FontFamily = textBlock.FontFamily; item.FontSize = textBlock.FontSize; item.LineHeight = textBlock.LineHeight; item.LineStackingStrategy = textBlock.LineStackingStrategy; item.Opacity = opacity; item.FontStyle = textBlock.FontStyle; item.FontWeight = textBlock.FontWeight; item.Margin = textBlock.Margin; Canvas.SetZIndex(item, zIndex); Typography.SetCapitals(item, Typography.GetCapitals(textBlock)); panel.Children.Add(item); } }
private TextBlock GetStyledTextblock(TimedTextStyle style, double width, double height, bool fOutline) { TextBlock textblock = new TextBlock(); //textblock.Width = width; textblock.FontStyle = style.FontStyle; textblock.FontWeight = FontWeightConverter.Convert(style.FontWeight); textblock.VerticalAlignment = VerticalAlignment.Bottom; #if !WINDOWS_PHONE7 if (style.FontFamily.Source == "_Smallcaps") { Typography.SetCapitals(textblock, FontCapitals.SmallCaps); } else #endif { #if SILVERLIGHT textblock.FontFamily = style.FontFamily; #else textblock.FontFamily = style.FontFamily.WindowsFontFamily; #endif } if (!double.IsNaN(height) && height != 0) { textblock.FontSize = Math.Round(style.FontSize.ToPixelLength(height)); } textblock.Foreground = GetCachedBrush(fOutline ? style.OutlineColor : Color.FromArgb(255, style.Color.R, style.Color.G, style.Color.B)); textblock.Opacity = style.Visibility == Visibility.Visible ? style.Opacity : 0; //textblock.TextWrapping = style.WrapOption; textblock.TextAlignment = style.TextAlign; return(textblock); }
public void Typo3(object sender, RoutedEventArgs e) { Typography.SetVariants(fd1, FontVariants.Normal); Typography.SetCapitals(fd1, FontCapitals.Normal); Typography.SetHistoricalForms(fd1, true); }
public void typo2(object sender, RoutedEventArgs e) { Typography.SetHistoricalForms(fd1, false); Typography.SetCapitals(fd1, FontCapitals.Normal); Typography.SetVariants(fd1, FontVariants.Subscript); }