// This code is part of GrapeCity Documents for Word samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using GrapeCity.Documents.Word;
using GrapeCity.Documents.Imaging;

namespace GcWordWeb.Samples
    // This sample lists all built-in styles available in GcWord.
    public class ListBuiltInStyles
        public GcWordDocument CreateDocx()
            var doc = new GcWordDocument();
            var sec = doc.Body.Sections.First;
            var pars = sec.GetRange().Paragraphs;

            pars.Add("List of All Built-in Styles", doc.Styles[BuiltInStyleId.Title]);

            // List all built-in style names and types.
            // Note that BuiltInStyleId.User is a special case that is not associated
            // with any built-in style. This value is returned by the Style.BuiltInId
            // property for user-defined styles, but cannot be used as an index
            // on the Styles collection (an exception will occur):
            foreach (BuiltInStyleId id in Enum.GetValues(typeof(BuiltInStyleId)))
                if (id != BuiltInStyleId.User)
                    pars.Add($"Style name: '{doc.Styles[id].Name}', type: '{doc.Styles[id].Type}'.");

            // Done:
            return doc;