コード例 #1
0
 protected virtual void PaintShape(Graphics g, Brush b, RectangleF rectangle)
 {
     if (this.ShapeType == PulseButton.Shape.Round)
     {
         g.FillEllipse(b, rectangle);
     }
     else
     {
         using (GraphicsPath roundRect = PulseButton.GetRoundRect(g, rectangle, (float)this.CornerRadius))
         {
             g.FillPath(b, roundRect);
         }
     }
 }
コード例 #2
0
        protected virtual void DrawHighLight(Graphics g)
        {
            RectangleF rect = this.centerRect;

            rect.Inflate(-2f, -2f);
            using (Pen pen = new Pen(Color.FromArgb(60, Color.White), 4f))
            {
                if (this.ShapeType == PulseButton.Shape.Round)
                {
                    g.DrawEllipse(pen, rect);
                }
                else
                {
                    g.DrawPath(pen, PulseButton.GetRoundRect(g, rect, (float)this.CornerRadius));
                }
            }
        }
コード例 #3
0
ファイル: PulseButton.cs プロジェクト: viktortat/faq_net
        protected virtual void DrawText(Graphics g)
        {
            StringFormat stringFormat = new StringFormat(StringFormat.GenericDefault)
            {
                Trimming = StringTrimming.EllipsisCharacter
            };

            stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
            stringFormat.FormatFlags ^= StringFormatFlags.LineLimit;
            stringFormat.HotkeyPrefix = HotkeyPrefix.Show;
            SizeF      element        = g.MeasureString(this.Text, this.Font, new SizeF(this.centerRect.Width, this.centerRect.Height), stringFormat);
            RectangleF alignPlacement = PulseButton.GetAlignPlacement(this.TextAlign, this.centerRect, element);

            using (SolidBrush solidBrush = new SolidBrush(this.ForeColor))
            {
                g.DrawString(this.Text, this.Font, solidBrush, alignPlacement, stringFormat);
            }
        }