コード例 #1
0
        public override void OnGLPaint(C2DGraphics gr)
        {
            base.OnGLPaint(gr);
            if ((Text == null) || (Text.Length == 0))
            {
                return;
            }
            if (mGLFontCache == null)
            {
                mGLFontCache = gr.GetFont(mGLFont);
                if (mGLFontCache == null)
                {
                    return;
                }
            }

            gr.SetColor(Style.ForeColor);
            int dlen = mGLFontCache.DispLength(Text);
            int x    = (Width - dlen) / 2;

            if (mTextAlign == ContentAlignment.MiddleLeft)
            {
                x = 0;
            }
            else if (mTextAlign == ContentAlignment.MiddleRight)
            {
                x = Width - dlen;
            }
            int y = (Height - mGLFontCache.height) / 2;

            gr.Text(mGLFontCache, x, y, Text);
        }