Exemplo n.º 1
0
        /// <summary>
        /// 描画オーバーライド
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Enabled)
            {
                base.OnPaint(e);
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(disabledBackColor), DisplayRectangle);
                StringFormat strform = CommonProc.ConvertAlignmentProperty(TextAlign);
                e.Graphics.DrawString(Text, Font, new SolidBrush(disabledForeColor), DisplayRectangle, strform);
            }
            if (RoundFrame)
            {
                Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
                // 角丸長方形のGraphicsPathを作成します。
                GraphicsPath path = CommonProc.GetRoundRect(rect, 5);

                //Panelの形を角丸長方形に変更
                //this.Region = new Region(path);
                e.Graphics.DrawPath(new Pen(Color.Black, 2.0f), path);
            }
            else
            {
                Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
                e.Graphics.DrawRectangle(new Pen(Color.Black, 2.0f), rect);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 描画オーバーライド
 /// </summary>
 /// <param name="e"></param>
 protected override void OnPaint(PaintEventArgs e)
 {
     if (Image != null)
     {
         Graphics g = e.Graphics;
         g.DrawImage(Image, DisplayRectangle);
         StringFormat fmt = CommonProc.ConvertAlignmentProperty(TextAlign);
         fmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
         g.DrawString(base.Text, Font, new SolidBrush(ForeColor), DisplayRectangle, fmt);
     }
     else
     {
         base.OnPaint(e);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 描画オーバーライド
 /// </summary>
 /// <param name="pe"></param>
 protected override void OnPaint(PaintEventArgs pe)
 {
     if (Enabled)
     {
         base.OnPaint(pe);
     }
     else
     {//非活性のときだけ自分で描く・・・
         pe.Graphics.FillRectangle(new SolidBrush(disabledBackColor), DisplayRectangle);
         StringFormat strform = CommonProc.ConvertAlignmentProperty(TextAlign);
         pe.Graphics.DrawString(Text, Font, new SolidBrush(disabledForeColor), DisplayRectangle, strform);
     }
     if (BorderStyle == BorderStyle.None)
     {//BorderStyle != Noneのときは描かない
         //Panelの形を角丸長方形に変更
         Rectangle dstRect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
         pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
         GraphicsPath path = CommonProc.GetRoundRect(dstRect, 5);
         pe.Graphics.DrawPath(new Pen(borderColor, 1.5f), path);
     }
 }