Пример #1
0
 protected virtual void OnCustomPaintForeground(MetroPaintEventArgs e)
 {
     if (GetStyle(ControlStyles.UserPaint) && CustomPaintForeground != null)
     {
         CustomPaintForeground(this, e);
     }
 }
 protected virtual void OnCustomPaintBackground(MetroPaintEventArgs e)
 {
     if (base.GetStyle(ControlStyles.UserPaint) && this.CustomPaintBackground != null)
     {
         this.CustomPaintBackground(this, e);
     }
 }
 protected virtual void OnCustomPaint(MetroPaintEventArgs e)
 {
     if (GetStyle(ControlStyles.UserPaint))
     {
         CustomPaint?.Invoke(this, e);
     }
 }
Пример #4
0
        protected virtual void OnCustomPaint(MetroPaintEventArgs e)
        {
            Rectangle rect = this.ClientRectangle;

            rect.Inflate(-1, -1);
            GraphicsPath path = new GraphicsPath();

            e.Graphics.FillEllipse(new SolidBrush(Color.Transparent), rect);
            path.AddEllipse(rect);
            this.Region = new Region(path);
            path.Dispose();
            //方案二:美观性较差
            //Rectangle rect = this.ClientRectangle;
            //rect.Inflate(-1, -1);
            //Pen pen = new Pen(Color.Gray);
            //e.Graphics.DrawEllipse(pen, rect);
            //pen.Dispose();
        }