Beispiel #1
0
        private static void Write(Stream stream, LayerState ls)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (ls == null)
            {
                throw new ArgumentNullException(nameof(ls));
            }

            TextCodeValueWriter chunk = new TextCodeValueWriter(new StreamWriter(stream));

            chunk.Write(0, LayerStateDictionary);
            chunk.Write(0, LayerStateName);
            chunk.Write(1, ls.Name);
            chunk.Write(91, 2047); // unknown code functionality <- 32-bit integer value
            chunk.Write(301, ls.Description);
            chunk.Write(290, ls.PaperSpace);
            chunk.Write(302, ls.CurrentLayer);

            foreach (LayerStateProperties lp in ls.Properties.Values)
            {
                chunk.Write(8, lp.Name);
                chunk.Write(90, (int)lp.Flags);
                chunk.Write(62, lp.Color.Index);
                chunk.Write(370, (short)lp.Lineweight);
                chunk.Write(6, lp.LinetypeName);
                //chunk.Write(2, properties.PlotStyleName);
                chunk.Write(440, lp.Transparency.Value == 0 ? 0 : Transparency.ToAlphaValue(lp.Transparency));
                if (lp.Color.UseTrueColor)
                {
                    // this code only appears if the layer color has been defined as true color
                    chunk.Write(92, AciColor.ToTrueColor(lp.Color));
                }
            }
            chunk.Flush();
        }
Beispiel #2
0
        /// <summary>
        /// Obtains the string that represents the formatted text applying the current options.
        /// </summary>
        /// <param name="text">Text to be formatted.</param>
        /// <returns>The formatted text string.</returns>
        public string FormatText(string text)
        {
            string formattedText = text;

            if (this.overline)
            {
                formattedText = string.Format("\\O{0}\\o", formattedText);
            }
            if (this.underline)
            {
                formattedText = string.Format("\\L{0}\\l", formattedText);
            }
            if (this.strikeThrough)
            {
                formattedText = string.Format("\\K{0}\\k", formattedText);
            }
            if (this.color != null)
            {
                formattedText = this.color.UseTrueColor ?
                                string.Format("\\C{0};\\c{1};{2}", this.color.Index, AciColor.ToTrueColor(this.color), formattedText) :
                                string.Format("\\C{0};{1}", this.color.Index, formattedText);
            }
            if (this.fontName != null)
            {
                if (this.bold && this.italic)
                {
                    formattedText = string.Format("\\f{0}|b1|i1;{1}", this.fontName, formattedText);
                }
                else if (this.bold && !this.italic)
                {
                    formattedText = string.Format("\\f{0}|b1|i0;{1}", this.fontName, formattedText);
                }
                else if (!this.bold && this.italic)
                {
                    formattedText = string.Format("\\f{0}|i1|b0;{1}", this.fontName, formattedText);
                }
                else
                {
                    formattedText = string.Format("\\F{0};{1}", this.fontName, formattedText);
                }
            }
            else
            {
                if (this.bold && this.italic)
                {
                    formattedText = string.Format("\\f{0}|b1|i1;{1}", this.style.FontFamilyName, formattedText);
                }
                if (this.bold && !this.italic)
                {
                    formattedText = string.Format("\\f{0}|b1|i0;{1}", this.style.FontFamilyName, formattedText);
                }
                if (!this.bold && this.italic)
                {
                    formattedText = string.Format("\\f{0}|i1|b0;{1}", this.style.FontFamilyName, formattedText);
                }
            }
            if (this.aligment != TextAligment.Default)
            {
                formattedText = string.Format("\\A{0};{1}", (int)this.aligment, formattedText);
            }
            if (!MathHelper.IsOne(this.heightFactor))
            {
                formattedText = string.Format("\\H{0}x;{1}", this.heightFactor, formattedText);
            }
            if (!MathHelper.IsZero(this.obliqueAngle))
            {
                formattedText = string.Format("\\Q{0};{1}", this.obliqueAngle, formattedText);
            }
            if (!MathHelper.IsOne(this.characterSpaceFactor))
            {
                formattedText = string.Format("\\T{0};{1}", this.characterSpaceFactor, formattedText);
            }
            if (!MathHelper.IsOne(this.widthFactor))
            {
                formattedText = string.Format("\\W{0};{1}", this.widthFactor, formattedText);
            }
            return("{" + formattedText + "}");
        }