/// <summary>
        /// Apply the font style
        /// </summary>
        /// <param name="captionElement">the caption element</param>
        private static void ApplyFontStyle(TT.TimedTextElement captionElement)
        {
            var outlineWidth = 1.0;

            if (ClosedCaptionProperties.FontSize != ClosedCaptionSize.Default)
            {
                outlineWidth = GetComputedFontPercent(ClosedCaptionProperties.FontSize);
            }

            var outlineColor = Colors.Black;

            if (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default)
            {
                outlineColor = Color.FromArgb(255, 0, 0, 0);
            }

            switch (ClosedCaptionProperties.FontEffect)
            {
                case ClosedCaptionEdgeEffect.Default:
                    captionElement.Style.TextStyle = TT.TextStyle.Default;

                    // Todo: look at code for calculation of OutlineWidth and OutlineBlur
                    captionElement.Style.OutlineWidth = new TT.Length { Value = outlineWidth, Unit = TT.LengthUnit.Pixel };
                    captionElement.Style.OutlineColor = outlineColor;
                    break;

                case ClosedCaptionEdgeEffect.Depressed:
                    captionElement.Style.TextStyle = TT.TextStyle.DepressedEdge;
                    captionElement.Style.OutlineColor = outlineColor;
                    captionElement.Style.OutlineWidth = new TT.Length { Value = outlineWidth, Unit = TT.LengthUnit.Pixel };
                    break;

                case ClosedCaptionEdgeEffect.DropShadow:
                    captionElement.Style.TextStyle = TT.TextStyle.DropShadow;

                    // Todo: look at code for calculation of OutlineWidth and OutlineBlur
                    captionElement.Style.OutlineColor = outlineColor;
                    captionElement.Style.OutlineWidth = new TT.Length { Value = outlineWidth, Unit = TT.LengthUnit.Pixel };
                    break;

                case ClosedCaptionEdgeEffect.None:
                    captionElement.Style.TextStyle = TT.TextStyle.None;
                    break;

                case ClosedCaptionEdgeEffect.Uniform:
                    captionElement.Style.TextStyle = TT.TextStyle.Outline;
                    captionElement.Style.OutlineWidth = new TT.Length { Value = outlineWidth, Unit = TT.LengthUnit.Pixel };
                    captionElement.Style.OutlineColor = outlineColor;
                    break;

                case ClosedCaptionEdgeEffect.Raised:
                    captionElement.Style.TextStyle = TT.TextStyle.RaisedEdge;
                    captionElement.Style.OutlineWidth = new TT.Length { Value = outlineWidth, Unit = TT.LengthUnit.Pixel };
                    captionElement.Style.OutlineColor = outlineColor;
                    break;
            }
        }
        /// <summary>
        /// Update the caption elements when the captions are parsed
        /// </summary>
        /// <param name="sender">the sender</param>
        /// <param name="e">the caption parsed event arguments</param>
        private void OnCaptionParsed(object sender, TT.CaptionParsedEventArgs e)
        {
            var captionRegion = e.CaptionMarker as TT.CaptionRegion;

            UpdateElement(captionRegion, 0);
        }
        /// <summary>
        /// Recursively update the caption elements
        /// </summary>
        /// <param name="captionElement">the caption element</param>
        /// <param name="level">the 0-based level of the caption element</param>
        private static void UpdateElement(
            TT.TimedTextElement captionElement,
            uint level)
        {
            if (level == 0)
            {
                if (ClosedCaptionProperties.RegionColor != ClosedCaptionColor.Default || ClosedCaptionProperties.RegionOpacity != ClosedCaptionOpacity.Default)
                {
                    captionElement.Style.BackgroundColor = GetComputedColor(ClosedCaptionProperties.ComputedRegionColor, ClosedCaptionProperties.RegionOpacity);
                }
            }
            else if (level == 1)
            {
                if (ClosedCaptionProperties.BackgroundColor != ClosedCaptionColor.Default || ClosedCaptionProperties.BackgroundOpacity != ClosedCaptionOpacity.Default)
                {
                    captionElement.Style.BackgroundColor = GetComputedColor(ClosedCaptionProperties.ComputedBackgroundColor, ClosedCaptionProperties.BackgroundOpacity);
                }
            }

            if (ClosedCaptionProperties.FontColor != ClosedCaptionColor.Default || ClosedCaptionProperties.FontOpacity != ClosedCaptionOpacity.Default)
            {
                captionElement.Style.Color = GetComputedColor(ClosedCaptionProperties.ComputedFontColor, ClosedCaptionProperties.FontOpacity);
            }

            if (ClosedCaptionProperties.FontSize != ClosedCaptionSize.Default)
            {
                captionElement.Style.FontSize = new TT.Length
                {
                    Unit = captionElement.Style.FontSize.Unit,
                    Value = GetComputedFontPercent(ClosedCaptionProperties.FontSize) * captionElement.Style.FontSize.Value
                };
            }

            var fontFamily = GetFontFamily();

            if (fontFamily != null)
            {
                captionElement.Style.FontFamily = fontFamily;

#if WINDOWS_PHONE
                if (userSettings.FontFamily == FontFamily.Cursive)
                {
                    captionElement.Style.FontStyle = System.Windows.FontStyles.Italic;
                }
#endif
            }

            ApplyFontStyle(captionElement);

            var children = captionElement.Children as TT.MediaMarkerCollection<TT.TimedTextElement>;

            if (children != null)
            {
                foreach (var child in children)
                {
                    UpdateElement(child, level + 1);
                }
            }
        }