SetLineDash() 공개 메소드

public SetLineDash ( float phase, float lenghts ) : void
phase float
lenghts float
리턴 void
예제 #1
0
        public static void DrawLine(CGContext context, List<PointF> points, CGColor color, float lineWidth, bool closePath, bool dashed)
        {
            if (points == null)
                throw new NullReferenceException();

            if (points.Count == 0)
                throw new ArgumentException("The line must have at least one point.");

            context.SaveState();
            context.SetStrokeColor(color);
            context.SetLineWidth(lineWidth);
            context.MoveTo(points[0].X, points[0].Y);
            for(int a = 1; a < points.Count; a++)
                context.AddLineToPoint(points[a].X, points[a].Y);
            if (dashed)
                context.SetLineDash(0, new float[2] { 1, 2 }, 2);
            if (closePath)
                context.ClosePath();
            context.StrokePath();
            context.RestoreState();
        }
        protected void HatchGrid(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchSize, false);

            /* draw background */
            drawBackground (context, backColor, hatchSize, hatchSize);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            hatchSize -=HALF_PIXEL_X;
            float yoffset = 0;

            if (hatchStyle == HatchStyle.DottedGrid)
            {
                yoffset = 1;
                float[] dash = new float[] { 1, 1};
                context.SetLineDash(2,dash);

            }

            /* draw a horizontal line */
            context.MoveTo(0,yoffset);
            context.AddLineToPoint(0,hatchSize);
            context.StrokePath();
            /* draw a vertical line */
            context.MoveTo(0,hatchSize);
            context.AddLineToPoint(hatchSize, hatchSize);

            context.StrokePath();
        }