Shape3DPlaceholderColorEffect.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 with placeholder colors to a shape.
  15. public class Shape3DPlaceholderColorEffect
  16. {
  17. public GcWordDocument CreateDocx()
  18. {
  19. var doc = new GcWordDocument();
  20.  
  21. Paragraph p = doc.Body.Paragraphs.Add();
  22. Run run = p.GetRange().Runs.Add();
  23. Shape shape = run.GetRange().Shapes.Add();
  24. shape.Fill.Type = FillType.Solid;
  25. shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
  26.  
  27. var shapeFormat = shape.Effects.ThreeDFormat;
  28.  
  29. var schemeEffects = doc.Theme.FormatScheme.Effects.Add();
  30. var schemeFormat = schemeEffects.ThreeDFormat;
  31. var schemeScene = schemeEffects.ThreeDScene;
  32. //TopBevel
  33. schemeFormat.TopBevel.Type = BevelType.Angle;
  34. schemeFormat.TopBevel.Width = 18.5f;
  35. schemeFormat.TopBevel.Height = 058.5f;
  36. //BottomBevel
  37. schemeFormat.BottomBevel.Type = BevelType.ArtDeco;
  38. schemeFormat.BottomBevel.Width = 11.5f;
  39. schemeFormat.BottomBevel.Height = 21.5f;
  40. //Depth
  41. schemeFormat.Depth.Width = 33.5f;
  42. schemeFormat.Depth.Color.ThemeColor = ThemeColorId.Accent1;
  43. //Contour
  44. schemeFormat.Contour.Width = 43.5f;
  45. //color will be retrieved from placeholder.
  46. schemeFormat.Contour.Color.ThemeColor = ThemeColorId.None;
  47. //Material
  48. schemeFormat.Material = MaterialType.Clear;
  49. //DisnatceFromGround
  50. schemeFormat.DistanceFromGround = 48.5f;
  51.  
  52. //set scene
  53. schemeScene.Camera.Preset = CameraPreset.OrthographicFront;
  54. schemeScene.Lighting.Direction = LightRigDirection.Top;
  55. schemeScene.Lighting.Type = LightRigType.ThreePoints;
  56.  
  57. //set placeholder color
  58. shape.Style.Effects.PlaceholderColor.ThemeColor = ThemeColorId.Accent6;
  59.  
  60. shape.Style.Effects.ThemeEffects = schemeEffects;
  61.  
  62. // Done:
  63. return doc;
  64. }
  65. }
  66. }
  67.