Shapes3DEffect.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 a 3D effect to a shape.
  15. public class Shapes3DEffect
  16. {
  17. public GcWordDocument CreateDocx()
  18. {
  19. var doc = new GcWordDocument();
  20.  
  21. Paragraph paragraph = doc.Body.Paragraphs.Add();
  22. Run run = paragraph.GetRange().Runs.Add();
  23. Shape shape = run.GetRange().Shapes.Add(200, 200, GeometryType.Rectangle);
  24. shape.Fill.Type = FillType.Solid;
  25. shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
  26.  
  27. // apply 3D format
  28. ThreeDFormat threeD = shape.Effects.ThreeDFormat;
  29. threeD.TopBevel.ApplyPreset(BevelType.Convex);
  30. threeD.Contour.Color.ThemeColor = ThemeColorId.Accent2;
  31. threeD.Contour.Width = 3f;
  32. threeD.Contour.Color.ThemeColor = ThemeColorId.Accent6;
  33. threeD.Contour.Width = 12f;
  34.  
  35. // apply 3D scene
  36. ThreeDScene scene = shape.Effects.ThreeDScene;
  37. scene.Camera.Preset = CameraPreset.PerspectiveContrastingRightFacing;
  38. scene.Lighting.Type = LightRigType.BrightRoom;
  39. scene.Lighting.Rotation.Latitude = 90f;
  40. scene.Lighting.Rotation.Revolution = 5f;
  41.  
  42. // Done:
  43. return doc;
  44. }
  45. }
  46. }
  47.