protected unsafe override bool TextLayout(textpara_t* text, byte** fontpath) { TextBlock label = new TextBlock(); label.Inlines.Add(text->Text); label.FontFamily = new FontFamily(text->FontName); label.FontSize = text->fontsize; switch ((char)text->just) { case 'l': label.TextAlignment = TextAlignment.Left; break; case 'n': label.TextAlignment = TextAlignment.Center; break; case 'r': label.TextAlignment = TextAlignment.Right; break; } label.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size desiredSize = label.DesiredSize; text->width = desiredSize.Width; text->height = desiredSize.Height; text->yoffset_centerline = 3; return true; }
protected virtual void TextParagraph(JobHandle job, pointf p, ref textpara_t text) { }
protected unsafe virtual bool TextLayout(textpara_t* text, byte** fontpath) { return false; }
protected override void TextParagraph(JobHandle job, pointf p, ref textpara_t text) { TextBlock block = new TextBlock(); block.Inlines.Add(text.Text); block.FontFamily = new FontFamily(text.FontName); block.FontSize = text.fontsize; block.Margin = new Thickness(p.x - text.width / 2, p.y - text.yoffset_centerline - text.height / 2, 0, 0); block.Height = text.height; block.Width = text.width; block.Foreground = GetForegroundBrush(job); block.Background = GetBackgroundBrush(job, false); switch ((char)text.just) { case 'l': block.TextAlignment = TextAlignment.Left; break; case 'n': block.TextAlignment = TextAlignment.Center; break; case 'r': block.TextAlignment = TextAlignment.Right; break; } _canvas.Children.Add(block); }