コード例 #1
0
ファイル: MyLabel.cs プロジェクト: 894880010/MP
        private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            e.Surface.Canvas.DrawRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width,
                                      ClientRectangle.Height, new SKPaint()
            {
                Color = BackColor.SKColor(), Style = SKPaintStyle.Fill
            });

            var paint = Font.SKPaint();

            paint.Color = ForeColor.SKColor();

            if (noofchars <= label.Length && resize)
            {
                noofchars = label.Length;
                float textSize = paint.MeasureText(label);
                this.Width = (int)textSize;
            }

            e.Surface.Canvas.DrawText(label, 0, Height - 2, paint);
        }