public TimedTextElement()
 {
     Type = "captionelement";
     Style = new TimedTextStyle();
     animations = new MediaMarkerCollection<TimedTextAnimation>();
     children = new MediaMarkerCollection<TimedTextElement>();
 }
示例#2
0
 public TimedTextElement()
 {
     Type       = "captionelement";
     Style      = new TimedTextStyle();
     animations = new MediaMarkerCollection <TimedTextAnimation>();
     children   = new MediaMarkerCollection <TimedTextElement>();
 }
示例#3
0
        /// <summary>
        /// Depressed edge text has a dark leading edge
        /// </summary>
        /// <param name="text">the text</param>
        /// <param name="style">the timed text style</param>
        /// <param name="panelWidth">the panel width</param>
        /// <param name="height">the height</param>
        /// <param name="textblock">the original TextBlock</param>
        /// <param name="outlineWidth">the outline width</param>
        /// <returns>a new Grid</returns>
        private FrameworkElement AddDepressedEdgeTextStyle(string text, TimedTextStyle style, double panelWidth, double height, TextBlock textblock, double outlineWidth)
        {
            var textBlocks = new TextBlock[]
            {
                GetStyledTextblock(style, panelWidth, height, true),
                GetStyledTextblock(style, panelWidth, height, true),
                GetStyledTextblock(style, panelWidth, height, true)
            };


            // top left
            textBlocks[0].RenderTransform = new TranslateTransform()
            {
                X = -outlineWidth, Y = -outlineWidth
            };
            // top
            textBlocks[1].RenderTransform = new TranslateTransform()
            {
                X = 0, Y = -outlineWidth
            };
            // left
            textBlocks[2].RenderTransform = new TranslateTransform()
            {
                X = -outlineWidth, Y = 0
            };

            var grid = new Grid();

            // The cache mode composites all of the elements together so the
            // opacity is applied to the whole grid instead of the individual
            // elements.
            grid.CacheMode = new BitmapCache();


            foreach (var item in textBlocks)
            {
                SetContent(item, text);
                grid.Children.Add(item);
            }

            grid.Children.Add(textblock);

            return(grid);
        }
示例#4
0
        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);
        }
        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;
        }
        /// <summary>
        /// Add outlined text style
        /// </summary>
        /// <param name="text">the text</param>
        /// <param name="style">the timed text style</param>
        /// <param name="panelWidth">the panel width</param>
        /// <param name="height">the height</param>
        /// <param name="textblock">the base text block</param>
        /// <param name="outlineWidth">the outline width</param>
        /// <returns>a Grid</returns>
        private FrameworkElement AddOutlineTextStyle(string text, TimedTextStyle style, double panelWidth, double height, TextBlock textblock, double outlineWidth)
        {
            FrameworkElement contentElement;
            Grid cnv = new Grid();

            // The cache mode composites all of the elements together so the 
            // opacity is applied to the whole grid instead of the individual 
            // elements.
            cnv.CacheMode = new BitmapCache();
            
            // do outline image up and to left
            TextBlock tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = -outlineWidth, Y = -outlineWidth };
            // do outline image left
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = -outlineWidth, Y = 0 };

            // do outline image down and to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = outlineWidth, Y = outlineWidth };
            // do outline image to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = outlineWidth, Y = 0 };

            // do outline image up and to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = outlineWidth, Y = -outlineWidth };
            // do outline image up
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = 0, Y = -outlineWidth };

            // do outline image down and to left
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = -outlineWidth, Y = outlineWidth };
            // do outline image down
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform() { X = 0, Y = outlineWidth };

            // add the main text
            cnv.Children.Add(textblock);

            // add the border
            contentElement = cnv;
            return contentElement;
        }
        /// <summary>
        /// Depressed edge text has a dark leading edge
        /// </summary>
        /// <param name="text">the text</param>
        /// <param name="style">the timed text style</param>
        /// <param name="panelWidth">the panel width</param>
        /// <param name="height">the height</param>
        /// <param name="textblock">the original TextBlock</param>
        /// <param name="outlineWidth">the outline width</param>
        /// <returns>a new Grid</returns>
        private FrameworkElement AddDepressedEdgeTextStyle(string text, TimedTextStyle style, double panelWidth, double height, TextBlock textblock, double outlineWidth)
        {
            var textBlocks = new TextBlock[]
            {
                GetStyledTextblock(style, panelWidth, height, true),
                GetStyledTextblock(style, panelWidth, height, true),
                GetStyledTextblock(style, panelWidth, height, true)
            };

            
            // top left
            textBlocks[0].RenderTransform = new TranslateTransform() { X = -outlineWidth, Y = -outlineWidth };
            // top
            textBlocks[1].RenderTransform = new TranslateTransform() { X = 0, Y = -outlineWidth };
            // left
            textBlocks[2].RenderTransform = new TranslateTransform() { X = -outlineWidth, Y = 0};

            var grid = new Grid();

            // The cache mode composites all of the elements together so the 
            // opacity is applied to the whole grid instead of the individual 
            // elements.
            grid.CacheMode = new BitmapCache();


            foreach (var item in textBlocks)
            {
                SetContent(item, text);
                grid.Children.Add(item);
            }

            grid.Children.Add(textblock);

            return grid;
        }
示例#8
0
        /// <summary>
        /// Add outlined text style
        /// </summary>
        /// <param name="text">the text</param>
        /// <param name="style">the timed text style</param>
        /// <param name="panelWidth">the panel width</param>
        /// <param name="height">the height</param>
        /// <param name="textblock">the base text block</param>
        /// <param name="outlineWidth">the outline width</param>
        /// <returns>a Grid</returns>
        private FrameworkElement AddOutlineTextStyle(string text, TimedTextStyle style, double panelWidth, double height, TextBlock textblock, double outlineWidth)
        {
            FrameworkElement contentElement;
            Grid             cnv = new Grid();

            // The cache mode composites all of the elements together so the
            // opacity is applied to the whole grid instead of the individual
            // elements.
            cnv.CacheMode = new BitmapCache();

            // do outline image up and to left
            TextBlock tb2 = GetStyledTextblock(style, panelWidth, height, true);

            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = -outlineWidth, Y = -outlineWidth
            };
            // do outline image left
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = -outlineWidth, Y = 0
            };

            // do outline image down and to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = outlineWidth, Y = outlineWidth
            };
            // do outline image to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = outlineWidth, Y = 0
            };

            // do outline image up and to right
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = outlineWidth, Y = -outlineWidth
            };
            // do outline image up
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = 0, Y = -outlineWidth
            };

            // do outline image down and to left
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = -outlineWidth, Y = outlineWidth
            };
            // do outline image down
            tb2 = GetStyledTextblock(style, panelWidth, height, true);
            SetContent(tb2, text);
            cnv.Children.Add(tb2);
            tb2.RenderTransform = new TranslateTransform()
            {
                X = 0, Y = outlineWidth
            };

            // add the main text
            cnv.Children.Add(textblock);

            // add the border
            contentElement = cnv;
            return(contentElement);
        }