Advertisement
Fhernd

ElipseControl.cs

Mar 9th, 2018
1,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using System.Windows.Forms;
  5.  
  6. namespace R804MoverFigura
  7. {
  8.     public partial class ElipseControl : UserControl
  9.     {
  10.         private GraphicsPath path = null;
  11.  
  12.         public ElipseControl()
  13.         {
  14.             InitializeComponent();
  15.         }
  16.  
  17.         private void ActualizarPath()
  18.         {
  19.             path = new GraphicsPath();
  20.             path.AddEllipse(this.ClientRectangle);
  21.             this.Region = new Region(path);
  22.         }
  23.  
  24.         protected override void OnPaint(PaintEventArgs e)
  25.         {
  26.             base.OnPaint(e);
  27.  
  28.             if (path != null)
  29.             {
  30.                 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  31.                 e.Graphics.FillPath(new SolidBrush(this.BackColor), path);
  32.                 e.Graphics.DrawPath(new Pen(this.ForeColor, 4), path);
  33.             }
  34.         }
  35.  
  36.         protected override void OnResize(EventArgs e)
  37.         {
  38.             base.OnResize(e);
  39.             ActualizarPath();
  40.             Invalidate();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement