Beispiel #1
0
 protected override void OnResize(EventArgs e)
 {
     Width    = (Height - 2) * 2;
     diameter = Width / 2;
     artis    = 4 * diameter / 30;
     rect     = new RoundedRectangleF(2 * diameter, diameter + 2, diameter / 2, 1, 1);
     circle   = new RectangleF(!isOn ? 1 : Width - diameter - 1, 1, diameter, diameter);
     base.OnResize(e);
 }
Beispiel #2
0
        public SlideButton()
        {
            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.ResizeRedraw |
                ControlStyles.Selectable |
                ControlStyles.DoubleBuffer | ControlStyles.Selectable |
                ControlStyles.SupportsTransparentBackColor |
                ControlStyles.ContainerControl |
                ControlStyles.UserPaint, true);
            this.UpdateStyles();

            Cursor = Cursors.Hand;

            artis    = 4; //increment for sliding animation
            diameter = 30;
            rect     = new RoundedRectangleF(2 * diameter, diameter + 2, diameter / 2, 1, 1);
            circle   = new RectangleF(1, 1, diameter, diameter);

            paintTicker.Tick    += paintTicker_Tick;
            paintTicker.Interval = 1;
        }