Documents for Word, .NET Edition
Features / Shapes / Shape Styles
In This Topic
    Shape Styles
    In This Topic

    GcWord allows you to define or customize shape styles to enhance the appearance of a shape. These styles can be applied to shapes as well as pictures. The ShapeStyle class provides Fill and Line properties to get the fill and line style of a shape.

    The StyleFill class provides ThemeFill property which defines the fill style and PlaceholderColor property which overrides the predefined color of a theme fill style. Similarly, the StyleLine class provides ThemeLine property which defines the line style and PlaceholderColor property which overrides the predefined color of a theme line style. The PlaceholderColor can be of the type SolidColor or GradientColor.

    The properties of FormatScheme class can be used to define the background fill styles, effect styles, fill styles, and line styles which define the style matrix for a theme.

    To apply themed style on a shape, refer Apply Themed Styles.

    Note: If FillFormat or LineFormat properties are not defined on a shape, their value is taken from Shape style (if present) by using ApplyThemedStyle method.

    To change existing style on a shape:

    1. Add a rectangle shape to a Word document by using Add method of ShapeCollection class and pass GeometryType.Rectangle as its parameter.
    2. Apply themed style on shape by using ApplyThemedStyle method and set ThemeShapedStyle enumeration to Accent6SolidFillLight1WidestOutline.
    3. Set ThemeColor to Accent3 to change the placeholder color of predefined themed style.
    4. Set the width of ThemeLine to 100 by using Width property of LineFormat class.
    5. Set the line color of ThemeLine to yellow by using RGB property of SolidColor class.
      Copy Code
      var doc = new GcWordDocument();
      var run = doc.Body.Paragraphs.Add().GetRange().Runs.Add();
      var shape = run.GetRange().Shapes.Add(300, 300, GeometryType.Rectangle);
      //Apply style to shape which will have Accent6 color and Light1 colored outline
      //Change Shape style placeholder color to Accent3
      //As it is Placeholder color, it will affect ONLY this shape
      shape.Style.Fill.PlaceholderColor.ThemeColor = ThemeColorId.Accent3;
      //Change Shape style line width. Now all shapes which apply this style will have outline of width 100 pixels.
      shape.Style.Line.ThemeLine.Width = 100;
      //Change Style line color. Now it will ignore Placeholder color and will always be yellow for every shape and ThemedStyle presets it used
      shape.Style.Line.ThemeLine.Fill.SolidFill.RGB = System.Drawing.Color.Yellow;
    Back to Top

    Note: When you change fill or line properties of a predefined themed style, it may affect other styles as well because many themed style presets point to same fill or line properties.


    Effects and derived classes (EffectsDAG,EffectsList) are not supported currently.