GetTextSize() public static method

public static GetTextSize ( Graphics graphics, string text, Font font, Size size ) : Size
graphics System.Drawing.Graphics
text string
font System.Drawing.Font
size System.Drawing.Size
return System.Drawing.Size
コード例 #1
0
ファイル: ButtonBase.cs プロジェクト: rotorliu/demo
        private void GetPoints()
        {
            int width  = base.Width;
            int height = base.Height;

            if (Image != null)
            {
                if (Text.Length == 0)
                {
                    iPoint = new Point((width - Image.Width) / 2, (height - Image.Height) / 2);
                }
                else
                {
                    iPoint = new Point(7, (height - Image.Height) / 2);
                }
                tPoint = new Point((7 + Image.Width) + 7, (height - Font.Height) / 2);
            }
            else
            {
                Size size = TextUtil.GetTextSize(base.CreateGraphics(), Text.Replace("&", ""), Font, new Size(width, height));
                tPoint = new Point(((width - size.Width) - 2) / 2, (height - Font.Height) / 2);
            }
        }
コード例 #2
0
        private void GetPoints()
        {
            int X = this.Width, Y = this.Height;

            if (Image != null)
            {
                if (Text.Length == 0)
                {
                    iPoint = new Point((X - Image.Width) / 2, (Y - Image.Height) / 2);
                }
                else
                {
                    iPoint = new Point(BT.LeftMargin, (Y - Image.Height) / 2);
                }

                tPoint = new Point(BT.LeftMargin + Image.Width + BT.TextMargin, (Y - this.Font.Height) / 2);
            }
            else
            {
                Size size = TextUtil.GetTextSize(this.CreateGraphics(), Text.Replace("&", ""), Font, new Size(X, Y));
                tPoint = new Point((X - size.Width - 2) / 2, (Y - this.Font.Height) / 2);
            }
        }