Exemplo n.º 1
0
        void setTextPosition()
        {
            int x = 0, y = 0;

            switch (_textPosition)
            {
            case AnchorStyles.Left:
                x = 0 + this.Padding.Left;
                y = (this.Height - L_Text.Height) / 2;
                break;

            case AnchorStyles.Right:
                x = this.Width - L_Text.Width - this.Padding.Right;
                y = (this.Height - L_Text.Height) / 2;
                break;

            case AnchorStyles.Top:
                x = (this.Width - L_Text.Width) / 2;
                y = this.Padding.Top;
                break;

            case AnchorStyles.Bottom:
                x = (this.Width - L_Text.Width) / 2;
                y = (this.Height - L_Text.Height) - this.Padding.Bottom;
                break;

            case AnchorStyles.None:
            default:
                x = (this.Width - L_Text.Width) / 2;
                y = (this.Height - L_Text.Height) / 2;
                break;
            }
            L_Text.SetBounds(x, y, 0, 0, BoundsSpecified.Location);
        }
Exemplo n.º 2
0
        private void SetLayout()
        {
            //this.Hide();
            if (this.TextAlign == ContentAlignment.BottomCenter)
            {
                //SizeF textSize = g.MeasureString(this.Text, this.Font);

                float x = (this.Width - L_Text.Width) / 2;
                float y = (this.Height - L_Text.Height) / 2;

                if (BackgroundImage != null)
                {
                    int ix = (this.Width - _picture.Width) / 2;
                    _picture.SetBounds(ix, this.Padding.Top, _picture.Width, _picture.Height);
                    L_Text.SetBounds((int)x, this.Height - (int)(L_Text.Height) - this.Padding.Bottom, 0, 0, BoundsSpecified.Location);

                    /*
                     *  DrawImage(g, this.BackgroundImage, this.Padding.Left, this.Padding.Top);
                     *  //g.DrawImage(this.BackgroundImage, new Point(this.Padding.Left, this.Padding.Top));
                     *  g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(x, this.Height - textSize.Height - this.Padding.Bottom));
                     */
                }
                else
                {
                    L_Text.SetBounds((int)x, (int)y, 0, 0, BoundsSpecified.Location);
                    //g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(x, y));
                }
            }
            else if (this.TextAlign == ContentAlignment.MiddleRight)
            {
                //float textHeight = g.MeasureString("Tj", this.Font).Height;
                float y = (this.Height - L_Text.Height) / 2;

                if (BackgroundImage != null)
                {
                    int iy = (this.Height - _picture.Height) / 2;
                    _picture.SetBounds(this.Padding.Left, iy, _picture.Width, _picture.Height);
                    L_Text.SetBounds(this._picture.Width + this.Padding.Left, (int)y, 0, 0, BoundsSpecified.Location);

                    //DrawImage(g, this.BackgroundImage, this.Padding.Left, this.Padding.Top);
                    //g.DrawImage(this.BackgroundImage, new Point(this.Padding.Left, this.Padding.Top));
                    //g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(this.BackgroundImage.Width + this.Padding.Left, y));
                }
                else
                {
                    L_Text.SetBounds(this._picture.Width + this.Padding.Left, (int)y, 0, 0, BoundsSpecified.Location);
                    //g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(this.BackgroundImage.Width + this.Padding.Left, y));
                }
            }

            /*
             *  try{
             *      this.BackgroundImage = this._images[_buttonType * 3 + _imageIndex];
             *  }catch{
             *      try{
             *          this.BackgroundImage = this._images[_imageIndex];
             *      }catch{
             *          try{
             *              this.BackgroundImage = this._images[0];
             *          }catch{
             *              this.BackgroundImage = null;
             *          }
             *      }
             *  }
             */

            //L_Text.Refresh();
            setTextPosition();
            //this.Show();
        }
Exemplo n.º 3
0
        void setTextPosition()
        {
            int x = 0, y = 0;

            if ((_textPosition & AnchorStyles.Top) > 0)
            {
                y = this.Padding.Top + this.Padding.Top;
                if ((_textPosition & AnchorStyles.Left) > 0)
                {
                    x = 0 + this.Padding.Left;
                }
                else if ((_textPosition & AnchorStyles.Right) > 0)
                {
                    x = this.Width - L_Text.Width - this.Padding.Right;
                }
                else
                {
                    x = (this.Width - L_Text.Width) / 2;
                }
            }
            else if ((_textPosition & AnchorStyles.Bottom) > 0)
            {
                y = (this.Height - L_Text.Height) - this.Padding.Bottom;
                if ((_textPosition & AnchorStyles.Left) > 0)
                {
                    x = 0 + this.Padding.Left;
                }
                else if ((_textPosition & AnchorStyles.Right) > 0)
                {
                    x = this.Width - L_Text.Width - this.Padding.Right;
                }
                else
                {
                    x = (this.Width - L_Text.Width) / 2;
                }
            }
            else
            {
                y = (this.Height - L_Text.Height) / 2;
                if ((_textPosition & AnchorStyles.Left) > 0)
                {
                    x = 0 + this.Padding.Left;
                }
                else if ((_textPosition & AnchorStyles.Right) > 0)
                {
                    x = this.Width - L_Text.Width - this.Padding.Right;
                }
                else
                {
                    x = (this.Width - L_Text.Width) / 2;
                }
            }

            /*
             * switch (_textPosition)
             * {
             *  case AnchorStyles.Left:
             *      x = 0+this.Padding.Left;
             *      y = (this.Height - L_Text.Height) / 2;
             *      break;
             *  case AnchorStyles.Right:
             *      x = this.Width - L_Text.Width - this.Padding.Right;
             *      y = (this.Height - L_Text.Height) / 2;
             *      break;
             *  case AnchorStyles.Top:
             *      x = (this.Width - L_Text.Width) / 2;
             *      y = this.Padding.Top;
             *      break;
             *  case AnchorStyles.Bottom:
             *      x = (this.Width - L_Text.Width) / 2;
             *      y = (this.Height - L_Text.Height) - this.Padding.Bottom;
             *      break;
             *  case AnchorStyles.None:
             *  default:
             *      x = (this.Width - L_Text.Width) / 2;
             *      y = (this.Height - L_Text.Height) / 2;
             *      break;
             * }
             */
            L_Text.SetBounds(x, y, 0, 0, BoundsSpecified.Location);
        }