BlurEffect.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using GrapeCity.Documents.Word;
  11.  
  12. namespace DsWordWeb.Demos
  13. {
  14. // This example shows how to add blur effect to shapes in a DOCX.
  15. public class BlurEffect
  16. {
  17. public GcWordDocument CreateDocx()
  18. {
  19. var doc = new GcWordDocument();
  20.  
  21. // Shape Blur - direct:
  22. Paragraph p = doc.Body.Paragraphs.Add();
  23. Run run = p.GetRange().Runs.Add();
  24. Shape shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star4);
  25. shape.Fill.Type = FillType.Solid;
  26. shape.Fill.SolidFill.RGB = Color.Yellow;
  27. shape.Line.Width = 4;
  28. shape.Line.Fill.SolidFill.RGB = Color.Red;
  29. // apply 7 point blur effect to the shape
  30. shape.Effects.Blur.Radius = 7f;
  31. p.GetRange().Runs.Add("Shape Blur - direct.", doc.Styles[BuiltInStyleId.Strong]);
  32.  
  33. // Shape Blur - shapes style:
  34. p = doc.Body.Paragraphs.Add();
  35. p.Style.ParagraphFormat.Spacing.SpaceBefore = 30;
  36. run = p.GetRange().Runs.Add();
  37. shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star4);
  38. shape.Fill.Type = FillType.Solid;
  39. shape.Fill.SolidFill.RGB = Color.Yellow;
  40. shape.Line.Width = 4;
  41. shape.Line.Fill.SolidFill.RGB = Color.Red;
  42. // apply 7 point blur effect to the shape
  43. var fmtEffect = doc.Theme.FormatScheme.Effects.Add();
  44. fmtEffect.Blur.Radius = 7f;
  45. //
  46. shape.Style.Effects.ThemeEffects = fmtEffect;
  47. p.GetRange().Runs.Add("Shape Blur - shapes style.", doc.Styles[BuiltInStyleId.Strong]);
  48.  
  49. // Done:
  50. return doc;
  51. }
  52. }
  53. }
  54.