Shape3DDirectColorEffect.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 direct colors to a shape.
  15. public class Shape3DDirectColorEffect
  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.Accent3;
  43. //Contour
  44. schemeFormat.Contour.Width = 43.5f;
  45. schemeFormat.Contour.Color.RGB = Color.Blue;
  46. //Material
  47. schemeFormat.Material = MaterialType.Metal;
  48. //DisnatceFromGround
  49. schemeFormat.DistanceFromGround = 48.5f;
  50.  
  51. //set scene
  52. schemeScene.Camera.Preset = CameraPreset.OrthographicFront;
  53. schemeScene.Lighting.Direction = LightRigDirection.Top;
  54. schemeScene.Lighting.Type = LightRigType.ThreePoints;
  55.  
  56. shape.Style.Effects.ThemeEffects = schemeEffects;
  57.  
  58. // Done:
  59. return doc;
  60. }
  61. }
  62. }
  63.