public TrackBar() : base() { _control = new TrackBarControl(); _control.OnTrackBarValueChanged += () => { if (OnTrackBarValueChanged != null) OnTrackBarValueChanged(); }; _control.OnInvalidateVisual += () => Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(InvalidateVisual)); _control.OnInvalidateVisualInRect += (rect) => Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { InvalidateVisual(); // TODO: It seems you can't invalidate a specific rect in WPF? What? // http://stackoverflow.com/questions/2576599/possible-to-invalidatevisual-on-a-given-region-instead-of-entire-wpf-control })); }
private void Initialize() { WantsLayer = true; OnTrackBarValueChanged += () => {}; OnTrackBarMouseDown += () => {}; OnTrackBarMouseUp += () => {}; // Add tracking area to receive mouse move and mouse dragged events var opts = NSTrackingAreaOptions.ActiveAlways | NSTrackingAreaOptions.InVisibleRect | NSTrackingAreaOptions.MouseMoved | NSTrackingAreaOptions.EnabledDuringMouseDrag; var trackingArea = new NSTrackingArea(Bounds, opts, this, new NSDictionary()); AddTrackingArea(trackingArea); _control = new TrackBarControl(); _control.OnTrackBarValueChanged += () => { OnTrackBarValueChanged(); }; _control.OnInvalidateVisual += () => InvokeOnMainThread(() => SetNeedsDisplayInRect(Bounds)); _control.OnInvalidateVisualInRect += (rect) => InvokeOnMainThread(() => SetNeedsDisplayInRect(GenericControlHelper.ToRect(rect))); }