ShadowEffect.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 shadow effect to text and shapes in a DOCX.
    public class ShadowEffect
    {
        public GcWordDocument CreateDocx()
        {
            var doc = new GcWordDocument();

            // Create paragraph styling:
            var style = doc.Styles.Add("My Style", StyleType.Paragraph);
            style.Font.Size = 48;
            style.Font.Name = "Lucida";
            style.Font.Bold = true;
            style.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // Create top right offset shadow effect for paragraph text:
            OuterShadow shadow = style.Font.Effects.Shadow;
            shadow.Alignment = RectangleAlignment.BottomLeft;
            shadow.Angle = 250f;
            shadow.Blur = 3f;
            shadow.Distance = 10f;
            shadow.ScaleX = 100f;
            shadow.ScaleY = 50f;
            shadow.SkewX = -30f;
            shadow.SkewY = 0f;
            shadow.Color.RGB = Color.Gray;
            shadow.Color.Transparency = 0.3f;

            // Apply top right offset shadow effect to the text:
            doc.Body.Paragraphs.Add("\n TREADSTONE", style);

            // Add a shape to the document:
            var para = doc.Body.Paragraphs.Add("\n \n \n");
            para.Format.Alignment = ParagraphAlignment.Center;
            var run = para.GetRange().Runs.Add();
            var shape = run.GetRange().Shapes.Add(450, 100, GeometryType.HorizontalScroll);
            shape.Fill.SolidFill.RGB = Color.SteelBlue;

            // Append text to the shape:
            var txtstyle = doc.Styles.Add("Text Style", StyleType.Paragraph);
            txtstyle.Font.Size = 28;
            txtstyle.Font.Bold = true;
            txtstyle.Font.Color.RGB = Color.White;
            txtstyle.ParagraphFormat.Alignment = ParagraphAlignment.Center;
            TextFrame frame = shape.AddTextFrame("FINANCIAL REPORT \n 2021-2022", txtstyle);

            // Apply built-in shadow effect to the shape:
            shape.Effects.ApplyBuiltInShadow(BuiltInShadowId.ProspectiveLowerLeft);

            // Done:
            return doc;
        }
    }
}