ApiExamples.ExStyles.OverwriteStyleDifferentDocument C# (CSharp) Метод

OverwriteStyleDifferentDocument() приватный Метод

private OverwriteStyleDifferentDocument ( ) : void
Результат void
        public void OverwriteStyleDifferentDocument()
        {         
            Document dstDoc = new Document();
            Document srcDoc = new Document();

            //ExStart
            //ExFor:StyleCollection.AddCopy
            //ExId:OverwriteStyleDifferentDocument   
            //ExSummary:Demonstrates how to copy a style from one document to another and overide an existing style in the destination document.
            // This is the style in the source document to copy to the destination document.
            Style srcStyle = srcDoc.Styles[StyleIdentifier.Heading1];

            // Change the font of the heading style to red.
            srcStyle.Font.Color = Color.Red;

            // The AddCopy method can be used to copy a style to a different document.
            Style newStyle = dstDoc.Styles.AddCopy(srcStyle);

            // The name of the new style can be changed to the name of any existing style. Doing this will override the existing style.
            newStyle.Name = "Heading 1";
            //ExEnd

            Assert.NotNull(newStyle);
            Assert.AreEqual("Heading 1", newStyle.Name);
            Assert.IsNull(dstDoc.Styles["Heading 1_0"]);
            Assert.AreEqual(Color.Red.ToArgb(), newStyle.Font.Color.ToArgb());
        }