GlowEffect.cs
//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;

namespace DsWordWeb.Demos
{
    // This example shows how to add glow effect to text and shapes in a DOCX.
    public class GlowEffect
    {
        public GcWordDocument CreateDocx()
        {
            var doc = new GcWordDocument();

            // Custom text glow:
            var style0 = doc.Styles.Add("style0", StyleType.Paragraph);
            style0.Font.Size = 48;
            // apply 5 point accent 6 glow effect to the text
            Glow glow = style0.Font.Effects.Glow;
            glow.Radius = 5f;
            glow.Color.ThemeColor = ThemeColorId.Accent6;
            glow.Color.Transparency = 0.6f;
            doc.Body.Paragraphs.Add("Custom text glow.", style0);

            // Built-in text glow:
            var style1 = doc.Styles.Add("style1", StyleType.Paragraph);
            style1.Font.Size = 48;
            // apply 5 point accent 5 glow effect to the text
            style1.Font.Effects.ApplyBuiltInGlow(BuiltInGlowId.Radius5Accent5);
            doc.Body.Paragraphs.Add("Built-in text glow.", style1);

            // Shape glow - direct:
            var p = doc.Body.Paragraphs.Add();
            var run = p.GetRange().Runs.Add();
            var shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star5);
            shape.Fill.Type = FillType.Solid;
            shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
            // apply 18 point accent 6 glow effect to the shape
            shape.Effects.ApplyBuiltInGlow(BuiltInGlowId.Radius18Accent6);
            p.GetRange().Runs.Add("Shape glow - direct.", doc.Styles[BuiltInStyleId.Strong]);

            // Shape Glow - shapes style - direct color in format scheme’s effect:
            p = doc.Body.Paragraphs.Add();
            p.Style.ParagraphFormat.Spacing.SpaceBefore = 30;
            run = p.GetRange().Runs.Add();
            shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star5);
            shape.Fill.Type = FillType.Solid;
            shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
            // apply 18 point accent 6 glow effect to the shape's style
            var fmtEffect = doc.Theme.FormatScheme.Effects.Add();
            fmtEffect.ApplyBuiltInGlow(BuiltInGlowId.Radius18Accent6);
            shape.Style.Effects.ThemeEffects = fmtEffect;
            p.GetRange().Runs.Add("Shape Glow - shapes style - direct color in format scheme’s effect.", doc.Styles[BuiltInStyleId.Strong]);

            // Shape Glow - shapes style - placeholder color in format scheme’s effect:
            p = doc.Body.Paragraphs.Add();
            p.Style.ParagraphFormat.Spacing.SpaceBefore = 30;
            run = p.GetRange().Runs.Add();
            shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star5);
            shape.Fill.Type = FillType.Solid;
            shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
            //
            fmtEffect = doc.Theme.FormatScheme.Effects.Add();
            fmtEffect.Glow.Color.ThemeColor = ThemeColorId.None;
            // apply 18 point accent 6 glow effect to the shape's style
            fmtEffect.Glow.Radius = 18f;
            shape.Style.Effects.PlaceholderColor.ThemeColor = ThemeColorId.Accent6;
            shape.Style.Effects.PlaceholderColor.Transparency = 0.6f;
            shape.Style.Effects.ThemeEffects = fmtEffect;
            p.GetRange().Runs.Add("Shape Glow - shapes style - placeholder color in format scheme’s effect.", doc.Styles[BuiltInStyleId.Strong]);

            // Done:
            return doc;
        }
    }
}