1 protected override voidOnPaint(PaintEventArgs e)2 {3 base.OnPaint(e);4
5 Graphics g =e.Graphics;6
7 int text_padding = 2;8 SizeF text_size =SizeF.Empty;9 RectangleF text_rect =RectangleF.Empty;10
11 Pen line_pen = new Pen(this.LineColor, this.LineThickness);12 int circular = this.lineCircular ? this.LineThickness : 0;13 PointF line_left_s =PointF.Empty;14 PointF line_left_e =PointF.Empty;15 PointF line_right_s =PointF.Empty;16 PointF line_right_e =PointF.Empty;17
18 #region 文字
19 if (!String.IsNullOrEmpty(this.Text))20 {21 SolidBrush text_sb = new SolidBrush(this.ForeColor);22 StringFormat text_sf = null;23
24 #region
25 if (this.LineOrientation ==LineOrientations.Horizontal)26 {27 text_size = g.MeasureString(this.Text, this.Font, 1000, text_sf);28 #region
29 float y = 0;30 if (this.textAlign ==TextAligns.Top)31 {32 y = (this.ClientRectangle.Height - (this.lineThickness + text_size.Height)) /2f;33 }34 else if (this.textAlign ==TextAligns.Center)35 {36 y = (this.ClientRectangle.Height - text_size.Height) /2f;37 }38 else if (this.textAlign ==TextAligns.Bottom)39 {40 y = (this.ClientRectangle.Height - (this.lineThickness + text_padding + text_size.Heigh