Esempio n. 1
0
        /// <summary>
        /// 打印或者显示在指定画布,该方法的调用用在显示报表
        /// <remarks>使用x,y偏移量是为了绘图转换坐标系方便</remarks>
        /// </summary>
        /// <param name="g">绘图图面,拥有该参数是为了可以灵活的转移图形的输出画面</param>
        /// <param name="x">横坐标位置的偏移值</param>
        /// <param name="y">纵坐标位置的偏移值</param>
        public void Print(Canvas ca, float x, float y)
        {
            MoveX = x;
            MoveY = y;
            Graphics g = ca.Graphics;

            if (EnableMapping)
            {
                string result = GetMapValue(RealText);
                if (null != result)
                {
                    RealText = result;
                }
            }
            SizeF textSize = g.MeasureString(RealText, this.Font);
            float left     = x;
            float top      = y;

            if (AutoSize)
            {
                this.Width  = (int)textSize.Width;
                this.Height = (int)textSize.Height;
            }

            // 上面的计算可能会改变控件的大小,所以将
            // 边框的绘制放在放在这里
            if (null != Border)
            {
                Border.FillAreaBackground(g, x, y);
                Border.Print(ca, x, y);
                left += Border.BorderWidth;
                top  += Border.BorderWidth;
            }
            Brush foreBrush = new SolidBrush(this.ForeColor);

            try
            {
                float tempWidth  = this.Width - Border.BorderWidth;
                float tempHeight = this.Height - Border.BorderWidth;
                if (tempWidth != 0 && tempHeight != 0)
                {
                    StringFormat sf = GetStringFormat();
                    try
                    {
                        g.DrawString(RealText, this.Font, foreBrush, new RectangleF(left, top, tempWidth, tempHeight), sf);
                    }
                    finally
                    {
                        sf.Dispose();
                    }
                }
            }
            finally
            {
                foreBrush.Dispose();
            }
        }
Esempio n. 2
0
        public override void DirectDraw(Canvas ca, float x, float y, float dpiZoom)
        {
            SetBorder();
            Graphics g = ca.Graphics;

            if (null == g)
            {
                return;
            }

            if (null != Border)
            {
                Border.FillAreaBackground(ca.Graphics, x, y);
            }

            try
            {
                if (!string.IsNullOrEmpty(RealText))
                {
                    byte[] imageArr = Convert.FromBase64String(RealText);
                    if (null != imageArr)
                    {
                        this.Image = System.Drawing.Image.FromStream(new MemoryStream(imageArr));
                    }
                }

                switch (Mode)
                {
                case PictureBoxSizeMode.Normal:
                    if (null != Image)
                    {
                        int w = this.Width > Image.Width ? Image.Width : this.Width;
                        int h = this.Height > Image.Height ? Image.Height : this.Height;
                        g.DrawImage(this.Image, x, y, new Rectangle(0, 0, w, h), GraphicsUnit.Pixel);
                    }
                    else if (null != ErrorImage)
                    {
                        int w = this.Width > Image.Width ? Image.Width : this.Width;
                        int h = this.Height > Image.Height ? Image.Height : this.Height;
                        g.DrawImage(this.ErrorImage, x, y, new Rectangle(0, 0, w, h), GraphicsUnit.Pixel);
                    }
                    break;

                case PictureBoxSizeMode.CenterImage:
                    float imageLeft = 0, imageTop = 0;
                    float bckLeft = 0, bckTop = 0;
                    float imgDrawWidth = 0, imgDrawHeight = 0;
                    if (this.Width >= Image.Width)
                    {
                        //imageLeft = x;
                        imageLeft    = 0;
                        bckLeft      = x + ((this.Width - Image.Width) / 2);
                        imgDrawWidth = Image.Width;
                    }
                    else
                    {
                        imageLeft    = (Image.Width - this.Width) / 2;
                        bckLeft      = x;
                        imgDrawWidth = this.Width;
                    }

                    if (this.Height >= Image.Height)
                    {
                        //imageTop = y;
                        imageTop      = 0;
                        bckTop        = y + ((this.Height - Image.Height) / 2);
                        imgDrawHeight = Image.Height;
                    }
                    else
                    {
                        imageTop      = (Image.Height - this.Height) / 2;
                        bckTop        = y;
                        imgDrawHeight = this.Height;
                    }
                    if (null != Image)
                    {
                        g.DrawImage(Image, bckLeft, bckTop,
                                    new Rectangle((int)imageLeft, (int)imageTop, (int)imgDrawWidth, (int)imgDrawHeight), GraphicsUnit.Pixel);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, bckLeft, bckTop,
                                    new Rectangle((int)imageLeft, (int)imageTop, (int)imgDrawWidth, (int)imgDrawHeight), GraphicsUnit.Pixel);
                    }

                    break;

                case PictureBoxSizeMode.AutoSize:
                    this.Width  = Image.Width;
                    this.Height = Image.Height;
                    if (null != Image)
                    {
                        g.DrawImage(Image, x, y, Image.Width, Image.Height);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, x, y, Image.Width, Image.Height);
                    }
                    break;

                case PictureBoxSizeMode.StretchImage:
                    if (null != Image)
                    {
                        g.DrawImage(Image, x, y, this.Width, this.Height);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, x, y, this.Width, this.Height);
                    }
                    break;

                case PictureBoxSizeMode.Zoom:
                    float imgWidthHeightScale = (float)Image.Width / Image.Height;
                    float imgWidth = 0, imgHeight = 0;
                    float drawLeft = 0, drawTop = 0;
                    float ctrlWidthHeightScale = (float)this.Width / this.Height;
                    if (ctrlWidthHeightScale > imgWidthHeightScale)
                    {
                        imgHeight = this.Height;
                        imgWidth  = imgHeight * imgWidthHeightScale;
                        drawLeft  = ((float)this.Width - imgWidth) / 2 + x;
                        drawTop   = y;
                    }
                    else
                    {
                        imgWidth  = this.Width;
                        imgHeight = imgWidth / imgWidthHeightScale;
                        drawLeft  = x;
                        drawTop   = ((float)this.Height - imgHeight) / 2 + y;
                    }
                    if (null != Image)
                    {
                        g.DrawImage(Image, drawLeft, drawTop, imgWidth, imgHeight);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, drawLeft, drawTop, imgWidth, imgHeight);
                    }

                    break;
                }
            }
            catch
            {
                if (null != ErrorImage)
                {
                    g.DrawImage(ErrorImage, x, y, this.Width, this.Height);
                }
            }

            if (null != Border)
            {
                Border.DirectDraw(ca, x, y, dpiZoom);
            }
        }
Esempio n. 3
0
        public override void Print(Canvas ca, float x, float y)
        {
            SetBorder();
            Graphics g = ca.Graphics;

            if (null == g)
            {
                return;
            }

            if (null != Border)
            {
                Border.FillAreaBackground(ca.Graphics, x, y);
            }
            try
            {
                switch (Mode)
                {
                case PictureBoxSizeMode.Normal:
                    if (null != Image)
                    {
                        int w = this.Width > Image.Width ? Image.Width : this.Width;
                        int h = this.Height > Image.Height ? Image.Height : this.Height;
                        g.DrawImage(this.Image, x, y, new Rectangle(0, 0, w, h), GraphicsUnit.Pixel);
                    }
                    else if (null != ErrorImage)
                    {
                        int w = this.Width > ErrorImage.Width ? ErrorImage.Width : this.Width;
                        int h = this.Height > ErrorImage.Height ? ErrorImage.Height : this.Height;
                        g.DrawImage(this.ErrorImage, x, y, new Rectangle(0, 0, w, h), GraphicsUnit.Pixel);
                    }
                    break;

                case PictureBoxSizeMode.CenterImage:
                    float imageLeft = 0, imageTop = 0;
                    float bckLeft = 0, bckTop = 0;
                    float imgDrawWidth = 0, imgDrawHeight = 0;
                    if (this.Width >= Image.Width)
                    {
                        //imageLeft = x;
                        imageLeft    = 0;
                        bckLeft      = x + ((this.Width - Image.Width) / 2);
                        imgDrawWidth = Image.Width;
                    }
                    else
                    {
                        imageLeft    = (Image.Width - this.Width) / 2;
                        bckLeft      = x;
                        imgDrawWidth = this.Width;
                    }

                    if (this.Height >= Image.Height)
                    {
                        //imageTop = y;
                        imageTop      = 0;
                        bckTop        = y + ((this.Height - Image.Height) / 2);
                        imgDrawHeight = Image.Height;
                    }
                    else
                    {
                        imageTop      = (Image.Height - this.Height) / 2;
                        bckTop        = y;
                        imgDrawHeight = this.Height;
                    }
                    if (null != Image)
                    {
                        g.DrawImage(Image, bckLeft, bckTop,
                                    new Rectangle((int)imageLeft, (int)imageTop, (int)imgDrawWidth, (int)imgDrawHeight), GraphicsUnit.Pixel);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, bckLeft, bckTop,
                                    new Rectangle((int)imageLeft, (int)imageTop, (int)imgDrawWidth, (int)imgDrawHeight), GraphicsUnit.Pixel);
                    }

                    break;

                case PictureBoxSizeMode.AutoSize:
                    this.Width  = Image.Width;
                    this.Height = Image.Height;
                    if (null != Image)
                    {
                        g.DrawImage(Image, x, y, Image.Width, Image.Height);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, x, y, Image.Width, Image.Height);
                    }
                    break;

                case PictureBoxSizeMode.StretchImage:
                    if (null != Image)
                    {
                        g.DrawImage(Image, x, y, this.Width, this.Height);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, x, y, this.Width, this.Height);
                    }
                    break;

                case PictureBoxSizeMode.Zoom:
                    float imgWidthHeightScale = (float)Image.Width / Image.Height;
                    float imgWidth = 0, imgHeight = 0;
                    float drawLeft = 0, drawTop = 0;
                    float ctrlWidthHeightScale = (float)this.Width / this.Height;
                    if (ctrlWidthHeightScale > imgWidthHeightScale)
                    {
                        imgHeight = this.Height;
                        imgWidth  = imgHeight * imgWidthHeightScale;
                        drawLeft  = ((float)this.Width - imgWidth) / 2 + x;
                        drawTop   = y;
                    }
                    else
                    {
                        imgWidth  = this.Width;
                        imgHeight = imgWidth / imgWidthHeightScale;
                        drawLeft  = x;
                        drawTop   = ((float)this.Height - imgHeight) / 2 + y;
                    }
                    if (null != Image)
                    {
                        g.DrawImage(Image, drawLeft, drawTop, imgWidth, imgHeight);
                    }
                    else if (null != ErrorImage)
                    {
                        g.DrawImage(ErrorImage, drawLeft, drawTop, imgWidth, imgHeight);
                    }

                    break;
                }
            }
            catch
            {
            }

            if (null != Border)
            {
                Border.Print(ca, x, y);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 打印或者显示在指定画布,该方法的调用用在显示报表
        /// <remarks>使用x,y偏移量是为了绘图转换坐标系方便</remarks>
        /// </summary>
        /// <param name="g">绘图图面,拥有该参数是为了可以灵活的转移图形的输出画面</param>
        /// <param name="x">横坐标位置的偏移值</param>
        /// <param name="y">纵坐标位置的偏移值</param>
        public void Print(Canvas ca, float x, float y)
        {
            if (!Transparent)
            {
                return;
            }
            MoveX = x;
            MoveY = y;
            Graphics g        = ca.Graphics;
            SizeF    textSize = g.MeasureString(Text, this.Font);
            //Size textSize = TextRenderer.MeasureText(Text, this.Font);
            //textSize.Width = textSize.Width;
            //textSize.Height = textSize.Height;
            float left = x;
            float top  = y;

            // 上面的计算可能会改变控件的大小,所以将
            // 边框的绘制放在放在这里
            Border.FillAreaBackground(g, x, y);
            Border.Print(ca, x, y);
            if (IsRedrawText)
            {
                //非自动大小的情况下的文本位置
                #region   计算文本的 XY坐标
                switch (TextAlign)
                {
                case ContentAlignment.BottomCenter:
                    left += (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 + Border.BorderWidth;
                    top  += this.Height - textSize.Height - Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;
                    break;

                case ContentAlignment.BottomLeft:
                    top  += this.Height - textSize.Height - 2 * Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;
                    left += Border.BorderWidth;
                    break;

                case ContentAlignment.BottomRight:
                    left += this.Width - textSize.Width - 2 * Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += this.Height - textSize.Height - Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;;
                    break;

                case ContentAlignment.MiddleCenter:
                    left += (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 + Border.BorderWidth;
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    break;

                case ContentAlignment.MiddleLeft:
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    left += Border.BorderWidth;;
                    break;

                case ContentAlignment.MiddleRight:
                    left += this.Width - textSize.Width - Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    break;

                case ContentAlignment.TopCenter:
                    left += (this.Width - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - textSize.Width) / 2 + Border.BorderWidth;
                    top  += Border.BorderWidth;
                    break;

                case ContentAlignment.TopLeft:
                    top  += Border.BorderWidth;
                    left += Border.BorderWidth;
                    break;

                case ContentAlignment.TopRight:
                    left += this.Width - textSize.Width - Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += Border.BorderWidth;
                    break;
                }
                #endregion
                Brush foreBrush = new SolidBrush(this.ForeColor);
                try
                {
                    float tempWidth  = this.Width - left + MoveX - Border.BorderWidth - textSize.Width <= 0 ? this.Width - left + MoveX - Border.BorderWidth : textSize.Width;
                    float tempHeight = this.Height - top + MoveY - Border.BorderWidth - textSize.Height <= 0 ? this.Height - top + MoveY - Border.BorderWidth : textSize.Height;
                    if (tempWidth != 0 && tempHeight != 0)
                    {
                        g.DrawString(Text, this.Font, foreBrush, new RectangleF(left, top, tempWidth, tempHeight));
                    }
                }
                finally
                {
                    foreBrush.Dispose();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 直接绘制
        /// </summary>
        /// <param name="ca"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public override void DirectDraw(Canvas ca, float x, float y, float dpiZoom)
        {
            SetBorder();
            MoveX = x;
            MoveY = y;
            Graphics g = ca.Graphics;

            SizeF textSize = SizeF.Empty;

            if (null != RealText)
            {
                textSize = g.MeasureString(RealText, this.Font);
            }
            float left = x;
            float top  = y;

            if (AutoSize)
            {
                this.Width  = (int)textSize.Width;
                this.Height = (int)textSize.Height;
            }

            // 上面的计算可能会改变控件的大小,所以将
            // 边框的绘制放在放在这里
            if (null != Border)
            {
                Border.FillAreaBackground(g, x, y);
                Border.DirectDraw(ca, x, y, dpiZoom);
                left += Border.BorderWidth;
                top  += Border.BorderWidth;
            }
            Brush foreBrush  = new SolidBrush(this.ForeColor);
            float tempWidth  = this.Width - Border.BorderWidth;
            float tempHeight = this.Height - Border.BorderWidth;

            if (null != RealText && tempWidth != 0 && tempHeight != 0)
            {
                StringFormat sf = GetStringFormat();
                try
                {
                    //GraphicsContainer container = g.BeginContainer();

                    System.Drawing.Drawing2D.GraphicsState state = g.Save();

                    RectangleF rect = new RectangleF(left, top, tempWidth, tempHeight);

                    Matrix mx = new Matrix();

                    if (RotateDegree != 0)
                    {
                        mx.RotateAt(RotateDegree, new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2));
                        //mx.Translate(textSize.Height, textSize.Width / 2);
                        mx.Multiply(g.Transform, MatrixOrder.Append);
                        g.Transform = mx;
                    }

                    g.DrawString(RealText, this.Font, foreBrush, rect /*new RectangleF(0, 0, tempWidth, tempHeight)*/, sf);
                    mx.Reset();
                    mx.Dispose();

                    g.Restore(state);
                    //g.EndContainer(container);
                }
                finally
                {
                    sf.Dispose();
                }
            }
            foreBrush.Dispose();
        }
Esempio n. 6
0
        /// <summary>
        /// 绘制
        /// </summary>
        /// <param name="ca"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public override void Print(Canvas ca, float x, float y)
        {
            SetBorder();
            MoveX = x;
            MoveY = y;
            Graphics g = ca.Graphics;

            if (null != this.Site)
            {
                if (!string.IsNullOrEmpty(Expression) && Expression.Trim().StartsWith("="))
                {
                    RealText = Expression;
                }
            }

            if (null == this.Site && EnableMapping)
            {
                string result = GetMapValue(RealText);
                if (null != result)
                {
                    RealText = result;
                }
            }
            StringFormat sf       = GetStringFormat();
            SizeF        textSize = SizeF.Empty;

            if (null != RealText)
            {
                textSize = g.MeasureString(RealText, this.Font, (int)(this.Width - Border.BorderWidth), sf);
            }
            float left = x;
            float top  = y;

            if (AutoSize)
            {
                this.Width  = (int)textSize.Width;
                this.Height = (int)textSize.Height;
            }

            // 上面的计算可能会改变控件的大小,所以将
            // 边框的绘制放在放在这里
            if (null != Border)
            {
                Border.FillAreaBackground(g, x, y);
                Border.Print(ca, x, y);
                left += Border.BorderWidth;
                top  += Border.BorderWidth;
            }
            Brush foreBrush  = new SolidBrush(this.ForeColor);
            float tempWidth  = this.Width - Border.BorderWidth;
            float tempHeight = this.Height - Border.BorderWidth;

            if (null != RealText && tempWidth != 0 && tempHeight != 0)
            {
                try
                {
                    //GraphicsContainer container = g.BeginContainer();

                    System.Drawing.Drawing2D.GraphicsState state = g.Save();

                    RectangleF rect = new RectangleF(left, top, tempWidth, tempHeight);

                    Matrix mx = new Matrix();

                    if (RotateDegree != 0)
                    {
                        mx.RotateAt(RotateDegree, new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2));
                        //mx.Translate((float)(Math.Sin(RotateDegree * Math.PI / 180) * textSize.Width), 0);
                        //left += (int)(textSize.Height / 2);

                        //mx.RotateAt(RotateDegree, new PointF(x, y));
                        //if (Math.Sin(RotateDegree * Math.PI / 180) < 0)
                        //    mx.Translate((float)(Math.Sin(RotateDegree * Math.PI / 180) * textSize.Width),0 /*(float)Math.Cos(RotateDegree * Math.PI / 180) * textSize.Width*/ );
                        mx.Multiply(g.Transform, MatrixOrder.Append);
                        g.Transform = mx;
                    }

                    g.DrawString(RealText, this.Font, foreBrush, rect, sf);
                    mx.Reset();
                    mx.Dispose();

                    g.Restore(state);
                    //g.EndContainer(container);
                    //g.DrawString(RealText, this.Font, foreBrush, new RectangleF(left, top, tempWidth, tempHeight), sf);
                }
                finally
                {
                    sf.Dispose();
                }
            }
            foreBrush.Dispose();
        }
Esempio n. 7
0
        public override void Print(Canvas ca, float x, float y)
        {
            if (Transparent && this.Site == null)
            {
                return;
            }
            SetBorder();
            MoveX = x;
            MoveY = y;
            Graphics g = ca.Graphics;

            if (null != this.Site)
            {
                if (!string.IsNullOrEmpty(Expression) && Expression.Trim().StartsWith("="))
                {
                    RealText = Expression;
                }
            }
            float left = x;
            float top  = y;

            // 上面的计算可能会改变控件的大小,所以将
            // 边框的绘制放在放在这里
            Border.FillAreaBackground(g, x, y);
            Border.Print(ca, x, y);
            if (null != RealText && IsRedrawText)
            {
                SizeF textSize = g.MeasureString(RealText, this.Font);

                //非自动大小的情况下的文本位置
                #region   计算文本的 XY坐标
                switch (TextAlign)
                {
                case ContentAlignment.BottomCenter:
                    left += (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 + Border.BorderWidth;
                    top  += this.Height - textSize.Height - Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;
                    break;

                case ContentAlignment.BottomLeft:
                    top  += this.Height - textSize.Height - 2 * Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;
                    left += Border.BorderWidth;
                    break;

                case ContentAlignment.BottomRight:
                    left += this.Width - textSize.Width - 2 * Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += this.Height - textSize.Height - Border.BorderWidth < 0 ? Border.BorderWidth : this.Height - textSize.Height - Border.BorderWidth;;
                    break;

                case ContentAlignment.MiddleCenter:
                    left += (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - 2 * Border.BorderWidth - textSize.Width) / 2 + Border.BorderWidth;
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    break;

                case ContentAlignment.MiddleLeft:
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    left += Border.BorderWidth;;
                    break;

                case ContentAlignment.MiddleRight:
                    left += this.Width - textSize.Width - Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 < 0 ? Border.BorderWidth : (this.Height - 2 * Border.BorderWidth - textSize.Height) / 2 + Border.BorderWidth;
                    break;

                case ContentAlignment.TopCenter:
                    left += (this.Width - textSize.Width) / 2 < 0 ? Border.BorderWidth : (this.Width - textSize.Width) / 2 + Border.BorderWidth;
                    top  += Border.BorderWidth;
                    break;

                case ContentAlignment.TopLeft:
                    top  += Border.BorderWidth;
                    left += Border.BorderWidth;
                    break;

                case ContentAlignment.TopRight:
                    left += this.Width - textSize.Width - Border.BorderWidth < Border.BorderWidth ? Border.BorderWidth : this.Width - textSize.Width - Border.BorderWidth;
                    top  += Border.BorderWidth;
                    break;
                }
                #endregion
                Brush foreBrush = new SolidBrush(this.ForeColor);
                try
                {
                    float tempWidth  = this.Width - left + MoveX - Border.BorderWidth - textSize.Width <= 0 ? this.Width - left + MoveX - Border.BorderWidth : textSize.Width;
                    float tempHeight = this.Height - top + MoveY - Border.BorderWidth - textSize.Height <= 0 ? this.Height - top + MoveY - Border.BorderWidth : textSize.Height;
                    if (tempWidth != 0 && tempHeight != 0)
                    {
                        g.DrawString(RealText, this.Font, foreBrush, new RectangleF(left, top, tempWidth, tempHeight));
                    }
                }
                finally
                {
                    foreBrush.Dispose();
                }
            }
        }