protected override void Dispose(bool disposing) { if (disposing) { if (_timer != null) { _timer.Stop(); _timer.Tick -= OnTimerTick; _timer.Dispose(); _timer = null; } if (_trackBar != null) { _trackBar.Dispose(); _trackBar = null; } if (_style != null) { _style.Dispose(); _style = null; } if (_visualStyle != null) { _visualStyle.PropertyChanged -= VisualStyle_PropertyChanged; _visualStyle = null; } } base.Dispose(disposing); }
public TrackSlider() : base() { base.SetStyle(ControlStyles.UserPaint, true); base.SetStyle(ControlStyles.SupportsTransparentBackColor, true); base.SetStyle(ControlStyles.OptimizedDoubleBuffer, false); base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); base.BackColor = Color.Transparent; base.DoubleBuffered = true; _visualStyle = new StandardTrackSliderVisualStyle(); _visualStyle.PropertyChanged += VisualStyle_PropertyChanged; _style = _visualStyle.CreateReference(); _trackBar = new TrackBar(this); if (!base.DesignMode) { _timer = new Timer(); _timer.Interval = 10; _timer.Tick += OnTimerTick; _timer.Start(); } }