/// <summary> /// Copies text and attributes from another cell state content. /// </summary> /// <param name="cell">The cell.</param> public void CopyFrom(ClosedCaptionsCellState cell) { Character = cell.Character; Opacity = cell.Opacity; Foreground = cell.Foreground; Background = cell.Background; IsUnderlined = cell.IsUnderlined; IsItalics = cell.IsItalics; }
/// <summary> /// Takes the current state of the CC packet buffer and projects the visual properties /// on to the CC visual grid of characters /// </summary> private void PaintBuffer() { TextBlock block = null; ClosedCaptionsCellState cell = null; Border border = null; for (var r = 0; r < ClosedCaptionsBuffer.RowCount; r++) { for (var c = 0; c < ClosedCaptionsBuffer.ColumnCount; c++) { block = CharacterLookup[r][c]; cell = Buffer.State[r][c].Display; border = block.Parent as Border; border.Visibility = string.IsNullOrEmpty(cell.Text) ? Visibility.Hidden : Visibility.Visible; if (border.Visibility != Visibility.Visible) { continue; } block.Text = cell.Text; block.FontStyle = cell.IsItalics ? FontStyles.Italic : FontStyles.Normal; block.HorizontalAlignment = cell.IsItalics ? HorizontalAlignment.Left : HorizontalAlignment.Center; block.Foreground = cell.Foreground; border.Background = cell.Background; border.Opacity = cell.Opacity; if (cell.IsUnderlined) { border.BorderBrush = cell.Foreground; border.BorderThickness = new Thickness(0, 0, 0, 4); } else { border.BorderBrush = null; border.BorderThickness = default; } } } }