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