namespace UglyToad.PdfPig.Graphics.Operations.MarkedContent { using System.IO; using Tokens; using Util.JetBrains.Annotations; using Writer; /// /// /// Begin a marked-content sequence with an associated property list terminated by a balancing operator. /// public class BeginMarkedContentWithProperties : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. /// public const string Symbol = "BDC"; /// public string Operator => Symbol; /// /// A name indicating the role or significance of the point. /// public NameToken Name { get; } /// /// The name of the property dictionary in the Properties subdictionary of the current resource dictionary. /// Can be if the property dictionary is provided inline. /// [CanBeNull] public NameToken PropertyDictionaryName { get; } /// /// The marked-content sequence properties. /// Can be if a name of the property dictionary is provided instead. /// [CanBeNull] public DictionaryToken Properties { get; } /// /// Create a new . /// /// The name of the marked-content point. /// The name of the property dictionary. public BeginMarkedContentWithProperties(NameToken name, NameToken propertyDictionaryName) { Name = name; PropertyDictionaryName = propertyDictionaryName; } /// /// Create a new . /// /// The name of the marked-content point. /// The properties of the marked-content point. public BeginMarkedContentWithProperties(NameToken name, DictionaryToken properties) { Name = name; Properties = properties; } /// public void Run(IOperationContext operationContext) { operationContext.BeginMarkedContent(Name, PropertyDictionaryName, Properties); } /// public void Write(Stream stream) { TokenWriter.WriteToken(Name, stream); stream.WriteWhiteSpace(); if (PropertyDictionaryName != null) { TokenWriter.WriteToken(PropertyDictionaryName, stream); } else { TokenWriter.WriteToken(Properties, stream); } stream.WriteWhiteSpace(); stream.WriteText(Symbol); stream.WriteNewLine(); } } }