private void drawLine(SSLine line, SSPosition position, SKCanvas canvas) { foreach (SSLabel label in line.labels) { position = drawLabel(label, canvas, position); } }
private void drawText(SSText text, SKCanvas canvas) { var lineNum = 0; float textheight = getTextHeight(text); SSPosition startPoint = PositionHelper.getPosition(text.alignX, text.alignY, 0, textheight, canvasSize); SSPosition position = startPoint; foreach (SSLine line in text.lines) { LineProps lineProps = calculateLineProps(line); if (text.alignX.style == AlignKeys.Center) { position.x -= (lineProps.width / 2); } else if (text.alignX.style == AlignKeys.Right) { position.x -= lineProps.width; } position.y += lineProps.maxHeight; if (lineNum > 0) { position.y += text.extraLineSpacing; } drawLine(line, position, canvas); lineNum++; position.x = startPoint.x; } }
private SSPosition drawLabel(SSLabel label, SKCanvas canvas, SSPosition position) { using (SKPaint paint = new SKPaint()) { paint.TextSize = label.fontSize; paint.IsAntialias = true; paint.Typeface = getFont(label); SKColor.TryParse(label.color, out SKColor color); color = color.WithAlpha(label.alpha); paint.Color = color; float height = label.fontSize; canvas.DrawText(label.text, position.x, position.y, paint); position.x += paint.MeasureText(label.text); return(position); } }
public static SSPosition getPosition(SSAlign alignX, SSAlign alignY, float width, float height, SSSize canvasSize) { var calculatedPos = new SSPosition(0, 0); if (alignX != null) { switch (alignX.style) { case AlignKeys.Center: calculatedPos.x = ((canvasSize.width - width) / 2) + alignX.value; break; case AlignKeys.Left: calculatedPos.x = alignX.value; break; case AlignKeys.Right: calculatedPos.x = canvasSize.width - width - alignX.value; break; } } if (alignY != null) { switch (alignY.style) { case AlignKeys.Center: calculatedPos.y = (canvasSize.height - height) / 2 + alignY.value; break; case AlignKeys.Top: calculatedPos.y = alignY.value; break; case AlignKeys.Bottom: calculatedPos.y = canvasSize.height - height - alignY.value; break; } } return(calculatedPos); }
public Device(DeviceModel name, SSSize screenSize, SSPosition screenOffset) { this.name = name; this.screenSize = screenSize; this.screenOffset = screenOffset; }