/// <summary>Stroke and fill the MetaPen and MetaBrush paths.</summary> public virtual void StrokeAndFill() { MetaPen pen = state.GetCurrentPen(); MetaBrush brush = state.GetCurrentBrush(); int penStyle = pen.GetStyle(); int brushStyle = brush.GetStyle(); if (penStyle == MetaPen.PS_NULL) { cb.ClosePath(); if (state.GetPolyFillMode() == MetaState.ALTERNATE) { cb.EoFill(); } else { cb.Fill(); } } else { bool isBrush = brushStyle == MetaBrush.BS_SOLID || brushStyle == MetaBrush.BS_HATCHED && state.GetBackgroundMode () == MetaState.OPAQUE; if (isBrush) { if (state.GetPolyFillMode() == MetaState.ALTERNATE) { cb.ClosePathEoFillStroke(); } else { cb.ClosePathFillStroke(); } } else { cb.ClosePathStroke(); } } }
/// <summary>Return true if the pen style is null and if it isn't a brush.</summary> /// <param name="isRectangle"> /// value to decide how to change the state. If true state.setLineJoinRectangle(cb) is called, /// if false state.setLineJoinPolygon(cb) is called. /// </param> /// <returns>true if the pen style is null and if it isn't a brush</returns> public virtual bool IsNullStrokeFill(bool isRectangle) { MetaPen pen = state.GetCurrentPen(); MetaBrush brush = state.GetCurrentBrush(); bool noPen = pen.GetStyle() == MetaPen.PS_NULL; int style = brush.GetStyle(); bool isBrush = style == MetaBrush.BS_SOLID || style == MetaBrush.BS_HATCHED && state.GetBackgroundMode() == MetaState.OPAQUE; bool result = noPen && !isBrush; if (!noPen) { if (isRectangle) { state.SetLineJoinRectangle(cb); } else { state.SetLineJoinPolygon(cb); } } return(result); }
/// <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; } } }