C#でのウィンドウ・インタフェースは、フォントの回転を達成します

 主コアコード:

public  class PublicFunction
    {
        public static PublicFunction _publicFunc =new PublicFunction();

        public static PublicFunction CreateInstance()
        {
            return _publicFunc;
        }
        public PublicFunction()
        {          
        }
        public void RotateFont(PaintEventArgs e,String strChar,Panel ppanel,float angle,Font ffont,Color ccolor)
        {
            Graphics g = e.Graphics; //需要在上面写字的控件

            float w = ppanel.Width;
            float h = ppanel.Height;            //将graphics坐标原点移到矩形中心点            
            g.TranslateTransform(w / 2, h / 2);
            g.RotateTransform(angle);
            SizeF sz = g.MeasureString(strChar, ffont);
            float x = -sz.Width / 2;
            float y = -sz.Height / 2;
            Brush brush = new SolidBrush(ccolor);
            g.DrawString(strChar, ffont, brush, new PointF(x, y));
        }
    }

コールの例:

        プライベートボイドpanelAmplitude_Paint(オブジェクト送信者、PaintEventArgsのE)
        {
            _strChar = "振幅/ DB"。
            PublicFunction.CreateInstance()RotateFont(E、_strChar、panelAmplitude、_angle、label1.Font、this.ForeColor)。
        }

公開された147元の記事 ウォンの賞賛146 ビュー770 000 +

おすすめ

転載: blog.csdn.net/miao0967020148/article/details/98347480