diverse änderungen
This commit is contained in:
1 parent
3dc1ad623c
commit
f51631100d
85 files changed
+1880
-56
No files matched your search
@@ -5,7 +5,7 @@ interface PropText {
|
||||
x: number,
|
||||
y: number,
|
||||
text:string
|
||||
centeredBox?: { width: number; height: number; fontSize: number };
|
||||
centeredBox?: { width: number; height: number; fontSize: number; color?: string };
|
||||
}
|
||||
|
||||
interface SvgOptions {
|
||||
@@ -18,6 +18,10 @@ interface SvgOptions {
|
||||
|
||||
|
||||
export class DrawText extends DrawElement {
|
||||
private escapeText(value: string): string {
|
||||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,13 +44,13 @@ export class DrawText extends DrawElement {
|
||||
drawSvg() {
|
||||
const box = this.posAndText.centeredBox;
|
||||
if (box) {
|
||||
return `<text x="${this.posAndText.x + box.width / 2}" y="${this.posAndText.y + box.height / 2}" text-anchor="middle" dominant-baseline="central" font-family="Arial" font-size="${box.fontSize}" font-weight="bold" fill="#000000">${this.posAndText.text}</text>`;
|
||||
return `<text x="${this.posAndText.x + box.width / 2}" y="${this.posAndText.y + box.height / 2}" text-anchor="middle" dominant-baseline="central" font-family="Arial" font-size="${box.fontSize}" font-weight="bold" fill="${box.color ?? '#000000'}">${this.escapeText(this.posAndText.text)}</text>`;
|
||||
}
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const posSvg = this.getSvgPositions(this.posAndText)
|
||||
const posStr = this.convertAttributesToString(posSvg);
|
||||
|
||||
const shape = this.drawElementSvg(posStr,this.posAndText.text, paraStr);
|
||||
const shape = this.drawElementSvg(posStr,this.escapeText(this.posAndText.text), paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
@@ -54,14 +58,14 @@ export class DrawText extends DrawElement {
|
||||
drawXaml(): string {
|
||||
const box = this.posAndText.centeredBox;
|
||||
if (box) {
|
||||
return `<Grid Canvas.Left="${this.posAndText.x}" Canvas.Top="${this.posAndText.y}" Width="${box.width}" Height="${box.height}"><TextBlock Text="${this.posAndText.text}" FontFamily="Arial" FontSize="${box.fontSize}" FontWeight="Bold" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/></Grid>`;
|
||||
return `<Grid Canvas.Left="${this.posAndText.x}" Canvas.Top="${this.posAndText.y}" Width="${box.width}" Height="${box.height}"><TextBlock Text="${this.escapeText(this.posAndText.text)}" FontFamily="Arial" FontSize="${box.fontSize}" FontWeight="Bold" Foreground="${box.color ?? '#000000'}" HorizontalAlignment="Center" VerticalAlignment="Center"/></Grid>`;
|
||||
}
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
//const posXaml = this.getXamlPositions(this.posAndText)
|
||||
//const posStr = this.convertAttributesToString(posXaml, true);
|
||||
|
||||
|
||||
const shape = this.drawElementXaml(this.posAndText.x,this.posAndText.y,this.posAndText.text, paraStr);
|
||||
const shape = this.drawElementXaml(this.posAndText.x,this.posAndText.y,this.escapeText(this.posAndText.text), paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user