![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace Seal
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
... {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Drawing.Drawing2D;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Diagnostics;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Summary description for TextOnSeal.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class TextOnSeal
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private string _text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Font _font;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Color _pathcolor = Color.Red;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Color _color = Color.Black;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Color _fillcolor = Color.Black;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private int _letterspace = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private bool _showpath = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Rectangle _rectcircle;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Rectangle _rect;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private int _intentlength = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Char_Direction _chardirect = Char_Direction.Center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private int _degree = 90;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private string _basestring;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Class_Properties#region Class_Properties
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Char_Direction CharDirection
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _chardirect; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
set
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (_chardirect != value)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_chardirect = value;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
switch (_chardirect)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case Char_Direction.Center:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_degree = 90;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case Char_Direction.ClockWise:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_degree = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case Char_Direction.OutSide:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_degree = -90;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case Char_Direction.AntiClockWise:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_degree = 180;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public string BaseString
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _basestring; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _basestring = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public string Text
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _text; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _text = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Font TextFont
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _font; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _font = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Color PathColor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _pathcolor; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _pathcolor = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Color ColorTOP
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _color; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _color = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Color FillColor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _fillcolor; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _fillcolor = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public int LetterSpace
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _letterspace; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _letterspace = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public bool ShowPath
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
get ...{ return _showpath; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
set ...{ _showpath = value; }
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public int SealSize
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
set
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rect = new Rectangle(0, 0, value, value);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle = new Rectangle(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Point(_rect.X + _intentlength, _rect.Y + _intentlength),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Size(_rect.Width - 2 * _intentlength, _rect.Height - 2 * _intentlength));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion {Class_Properties}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void SetIndent(int IntentLength)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_intentlength = IntentLength;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle = new Rectangle(_intentlength, _intentlength,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rect.Width - _intentlength * 2, _rect.Height - _intentlength * 2);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public TextOnSeal()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Bitmap TextOnPathBitmap(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Rectangle rectCircle,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string strText,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Font fntText,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Color clrColor,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Color clrFill,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int nPercentage)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rect = rectCircle;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle = new Rectangle(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Point(_rect.X + _intentlength, _rect.Y + _intentlength),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Size(_rect.Width - 2 * _intentlength, _rect.Height - 2 * _intentlength));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_text = strText;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_font = fntText;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_color = clrColor;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_fillcolor = clrFill;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_letterspace = nPercentage;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TextOnPathBitmap();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Compute string total length and every char length
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="sText"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="g"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="fCharWidth"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="fIntervalWidth"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// <returns></returns>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private float ComputeStringLength(string sText, Graphics g, float[] fCharWidth,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float fIntervalWidth,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Char_Direction Direction)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Init string format
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StringFormat sf = new StringFormat();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.Trimming = StringTrimming.None;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
| StringFormatFlags.LineLimit;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Measure whole string length
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SizeF size = g.MeasureString(sText, _font, (int)_font.Style);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RectangleF rect = new RectangleF(0f, 0f, size.Width, size.Height);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Measure every character size
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CharacterRange[] crs = new CharacterRange[sText.Length];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < sText.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
crs[i] = new CharacterRange(i, 1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Reset string format
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.FormatFlags = StringFormatFlags.NoClip;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.SetMeasurableCharacterRanges(crs);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.Alignment = StringAlignment.Near;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Get every character size
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Region[] regs = g.MeasureCharacterRanges(sText,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_font, rect, sf);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Re-compute whole string length with space interval width
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float fTotalWidth = 0f;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < regs.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (Direction == Char_Direction.Center || Direction == Char_Direction.OutSide)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fCharWidth[i] = regs[i].GetBounds(g).Width;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fCharWidth[i] = regs[i].GetBounds(g).Height;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fTotalWidth += fCharWidth[i] + fIntervalWidth;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fTotalWidth -= fIntervalWidth;//Remove the last interval width
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return fTotalWidth;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Compute every char position
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="CharWidth"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="recChars"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="CharAngle"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// <param name="StartAngle"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void ComputeCharPos(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float[] CharWidth,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PointF[] recChars,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double[] CharAngle,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double StartAngle)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double fSweepAngle, fCircleLength;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Compute the circumference
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fCircleLength = _rectcircle.Width * Math.PI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < CharWidth.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Get char sweep angle
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fSweepAngle = CharWidth[i] * 360 / fCircleLength;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Set point angle
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CharAngle[i] = StartAngle + fSweepAngle / 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Get char position
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (CharAngle[i] < 270f)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
recChars[i] = new PointF(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle.X + _rectcircle.Width / 2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
- (float)(_rectcircle.Width / 2 *
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Math.Sin(Math.Abs(CharAngle[i] - 270) * Math.PI / 180)),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle.Y + _rectcircle.Width / 2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
- (float)(_rectcircle.Width / 2 * Math.Cos(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Math.Abs(CharAngle[i] - 270) * Math.PI / 180)));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
recChars[i] = new PointF(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle.X + _rectcircle.Width / 2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
+ (float)(_rectcircle.Width / 2 *
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Math.Sin(Math.Abs(CharAngle[i] - 270) * Math.PI / 180)),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rectcircle.Y + _rectcircle.Width / 2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
- (float)(_rectcircle.Width / 2 * Math.Cos(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Math.Abs(CharAngle[i] - 270) * Math.PI / 180)));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//Get total sweep angle with interval space
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fSweepAngle = (CharWidth[i] + _letterspace) * 360 / fCircleLength;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StartAngle += fSweepAngle;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Generate seal bitmap
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// <returns></returns>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Bitmap TextOnPathBitmap()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Create bitmap and graphics
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Bitmap bit = new Bitmap(_rect.Width, _rect.Height);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Graphics g = Graphics.FromImage(bit);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Compute string length in graphics
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float[] fCharWidth = new float[_text.Length];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float fTotalWidth = ComputeStringLength(_text, g, fCharWidth,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_letterspace, _chardirect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Compute arc's start-angle and end-angle
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double fStartAngle, fSweepAngle;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fSweepAngle = fTotalWidth * 360 / (_rectcircle.Width * Math.PI);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fStartAngle = 270 - fSweepAngle / 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Compute every character's position and angle
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PointF[] pntChars = new PointF[_text.Length];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double[] fCharAngle = new double[_text.Length];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ComputeCharPos(fCharWidth, pntChars, fCharAngle, fStartAngle);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.SmoothingMode = SmoothingMode.HighQuality;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.CompositingQuality = CompositingQuality.HighQuality;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DrawSealBase(g);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Draw every character
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < _text.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DrawRotatedText(g, _text[i].ToString(), (float)(fCharAngle[i] + _degree), pntChars[i]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.Dispose();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Return bitmap
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return bit;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Draw seal base
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// <param name="g"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void DrawSealBase(Graphics g)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Draw background
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillRectangle(Brushes.Black, _rect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillEllipse(new SolidBrush(_fillcolor),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Rectangle(1, 1, _rect.Width - 2, _rect.Height - 2));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillEllipse(Brushes.White,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new Rectangle(4, 4, _rect.Width - 8, _rect.Height - 8));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Draw start signal
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StringFormat sf = new StringFormat();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string strStar = "★";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Font fnt = new Font(_font.FontFamily, _font.Size * 3);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.Alignment = StringAlignment.Center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.LineAlignment = StringAlignment.Center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SizeF siz = g.MeasureString(strStar, fnt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.DrawString(strStar, fnt, new SolidBrush(_fillcolor),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
new RectangleF(_rect.Width / 2 - siz.Width / 2,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rect.Height / 2 - siz.Height / 2,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
siz.Width, siz.Height), sf);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Draw base string
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float[] fCharWidth = new float[_basestring.Length];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float fTotalWidths = ComputeStringLength(_basestring, g, fCharWidth, 0,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Char_Direction.Center);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
float fLeftPos = (_rect.Width - fTotalWidths) / 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PointF pt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < _basestring.Length; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pt = new PointF(fLeftPos + fCharWidth[i] / 2,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_rect.Height / 2 + siz.Height / 2 + 10);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DrawRotatedText(g, _basestring[i].ToString(), 0, pt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fLeftPos += fCharWidth[i];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// Draw every rotated character
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="g"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="_text"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="_angle"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// <param name="_PointCenter"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void DrawRotatedText(Graphics g, string _text, float _angle, PointF _PointCenter)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StringFormat sf = new StringFormat();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.Alignment = StringAlignment.Center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sf.LineAlignment = StringAlignment.Center;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GraphicsPath gp = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int x = (int)_PointCenter.X;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int y = (int)_PointCenter.Y;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gp.AddString(_text, _font.FontFamily, (int)_font.Style,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_font.Size, new Point(x, y), sf);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Matrix m = new Matrix();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m.RotateAt(_angle, new PointF(x, y));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.Transform = m;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.DrawPath(new Pen(_color), gp);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillPath(new SolidBrush(_fillcolor), gp);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public enum Char_Direction
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Center = 0,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
OutSide = 1,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ClockWise = 2,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AntiClockWise = 3,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}