Пример #1
0
        /// <summary>Select the MetaObject at the specified index and prepare the PdfCanvas.</summary>
        /// <param name="index">position of the MetaObject</param>
        /// <param name="cb">PdfCanvas to prepare</param>
        public virtual void SelectMetaObject(int index, PdfCanvas cb)
        {
            MetaObject obj = MetaObjects[index];

            if (obj == null)
            {
                return;
            }
            int style;

            switch (obj.GetObjectType())
            {
            case MetaObject.META_BRUSH: {
                currentBrush = (MetaBrush)obj;
                style        = currentBrush.GetStyle();
                if (style == MetaBrush.BS_SOLID)
                {
                    Color color = currentBrush.GetColor();
                    cb.SetFillColor(color);
                }
                else
                {
                    if (style == MetaBrush.BS_HATCHED)
                    {
                        Color color = currentBackgroundColor;
                        cb.SetFillColor(color);
                    }
                }
                break;
            }

            case MetaObject.META_PEN: {
                currentPen = (MetaPen)obj;
                style      = currentPen.GetStyle();
                if (style != MetaPen.PS_NULL)
                {
                    Color color = currentPen.GetColor();
                    cb.SetStrokeColor(color);
                    cb.SetLineWidth(Math.Abs(currentPen.GetPenWidth() * scalingX / extentWx));
                    switch (style)
                    {
                    case MetaPen.PS_DASH: {
                        cb.SetLineDash(18, 6, 0);
                        break;
                    }

                    case MetaPen.PS_DASHDOT: {
                        cb.WriteLiteral("[9 6 3 6]0 d\n");
                        break;
                    }

                    case MetaPen.PS_DASHDOTDOT: {
                        cb.WriteLiteral("[9 3 3 3 3 3]0 d\n");
                        break;
                    }

                    case MetaPen.PS_DOT: {
                        cb.SetLineDash(3, 0);
                        break;
                    }

                    default: {
                        cb.SetLineDash(0);
                        break;
                    }
                    }
                }
                break;
            }

            case MetaObject.META_FONT: {
                currentFont = (MetaFont)obj;
                break;
            }
            }
        }