Example #1
0
        /// <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);
            }
        }