コード例 #1
0
        // apply text formats to textbox & placeholer
        public void ApplyTextEffect(string fontFamily, string fontColor, int fontSizeToIncrease, int fontTransparency)
        {
            var shape = ShapeUtil.GetTextShapeToProcess(Shapes);

            if (shape == null)
            {
                return;
            }

            // a hack to enable the textbox layout
            shape.Width = shape.Width;

            shape.Fill.Visible = MsoTriState.msoFalse;
            shape.Line.Visible = MsoTriState.msoFalse;

            var font = shape.TextFrame2.TextRange.TrimText().Font;

            if (!string.IsNullOrEmpty(fontColor))
            {
                font.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(fontColor));
            }

            if (!StringUtil.IsEmpty(fontFamily))
            {
                shape.TextEffect.FontName = fontFamily;
            }

            if (StringUtil.IsEmpty(shape.Tags[Tag.OriginalFontSize]))
            {
                shape.Tags.Add(Tag.OriginalFontSize, shape.TextEffect.FontSize.ToString(CultureInfo.InvariantCulture));
            }

            if (fontSizeToIncrease != -1)
            {
                shape.TextFrame.AutoSize  = PowerPoint.PpAutoSize.ppAutoSizeNone;
                shape.TextEffect.FontSize = float.Parse(shape.Tags[Tag.OriginalFontSize]) + fontSizeToIncrease;
            }

            if (fontTransparency != -1)
            {
                font.Fill.Transparency = (float)fontTransparency / 100;
            }
        }
コード例 #2
0
        public void ApplyTextGlowEffect(bool isUseTextGlow, string textGlowColor)
        {
            PowerPoint.Shape shape = ShapeUtil.GetTextShapeToProcess(Shapes);
            if (shape == null)
            {
                return;
            }

            if (isUseTextGlow)
            {
                shape.TextFrame2.TextRange.Font.Glow.Radius    = 8;
                shape.TextFrame2.TextRange.Font.Glow.Color.RGB =
                    GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(textGlowColor));
                shape.TextFrame2.TextRange.Font.Glow.Transparency = 0.6f;
            }
            else
            {
                shape.TextFrame2.TextRange.Font.Glow.Radius    = 0;
                shape.TextFrame2.TextRange.Font.Glow.Color.RGB =
                    GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(textGlowColor));
                shape.TextFrame2.TextRange.Font.Glow.Transparency = 0.0f;
            }
        }