转自:http://blog.csdn.net/hooyke/article/details/7528305
- private void DrawStringAndRotateAt(System.Windows.Forms.Panel panel,string strChar)
- {
- //以(100,100)为中心画字符串并旋转
- Graphics g = panel.CreateGraphics(); //需要在上面写字的控件
- Font font = new Font("Impact ", 30);//字体名称大小
- PointF rotatePoint = new PointF(this.panel1.Height / 2, this.panel1.Width / 2); //设定旋转的中心点
- SizeF size = g.MeasureString(strChar, font);
- Matrix myMatrix = new Matrix();
- myMatrix.RotateAt(270, rotatePoint, MatrixOrder.Append); //旋转270度
- g.Transform = myMatrix;
- g.DrawString(str, font, new SolidBrush(Color.Black), rotatePoint.X - size.Width, rotatePoint.Y - size.Height); //写字
- }
|