protected override void OnCreateControl() { base.OnCreateControl(); if (DesignMode) { return; } MouseState = MouseStateBase.OUT; MouseEnter += (sender, args) => { MouseState = MouseStateBase.HOVER; _hoverAnimationManager.StartNewAnimation(AnimationDirection.In); Invalidate(); }; MouseLeave += (sender, args) => { MouseState = MouseStateBase.OUT; _hoverAnimationManager.StartNewAnimation(AnimationDirection.Out); Invalidate(); }; MouseDown += (sender, args) => { if (args.Button == MouseButtons.Left) { MouseState = MouseStateBase.DOWN; _animationManager.StartNewAnimation(AnimationDirection.In, args.Location); Invalidate(); } }; MouseUp += (sender, args) => { MouseState = MouseStateBase.HOVER; Invalidate(); }; }
public AdvancedCheckBox() { _animationManager = new AnimationManager { AnimationType = AnimationType.EaseInOut, Increment = 0.05 }; _rippleAnimationManager = new AnimationManager(false) { AnimationType = AnimationType.Linear, Increment = 0.10, SecondaryIncrement = 0.08 }; _animationManager.OnAnimationProgress += sender => Invalidate(); _rippleAnimationManager.OnAnimationProgress += sender => Invalidate(); CheckedChanged += (sender, args) => { _animationManager.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); }; Ripple = true; MouseLocation = new Point(-1, -1); }