public AudioVisualizer(AudioVisualizerView imageView)
        {
            _imageView = imageView;

            _imageView.OnMouseClicked += (object sender, NSEvent e) =>
            {
                bool controlDown = (AppKit.NSEventModifierMask.ControlKeyMask & NSEvent.CurrentModifierFlags) > 0;
                bool altDown     = (AppKit.NSEventModifierMask.AlternateKeyMask & NSEvent.CurrentModifierFlags) > 0;
                bool shiftDown   = (AppKit.NSEventModifierMask.ShiftKeyMask & NSEvent.CurrentModifierFlags) > 0;

                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                WaveformMouseClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, shiftDown, controlDown, altDown);
            };

            _imageView.OnMouseDoubleClicked += (object sender, NSEvent e) =>
            {
                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                WaveformMouseDoubleClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true);
            };

            _imageView.OnMouseDown += (object sender, NSEvent e) =>
            {
                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                WaveformMouseDown(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, false);     // e.ButtonMask & NSEventButtonMask.);
            };

            _imageView.OnMouseEnter += (object sender, NSEvent e) =>
            {
                if (_wavePeaks == null)
                {
                    return;
                }
                if (_noClear)
                {
                    _noClear = false;
                }
                else
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor);  //Cursor = Cursors.Default;
                    _mouseDown          = false;
                    _mouseDownParagraph = null;
                    _mouseMoveStartX    = -1;
                    _mouseMoveEndX      = -1;
                }

                if (NewSelectionParagraph != null)
                {
                    _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - StartPositionSeconds);
                    _mouseMoveEndX   = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - StartPositionSeconds);
                }
            };

            _imageView.OnMouseLeave += (object sender, NSEvent e) =>
            {
                _mouseDown = false;
            };

            _imageView.OnMouseMoved += (object sender, NSEvent e) =>
            {
                if (_wavePeaks == null)
                {
                    return;
                }

                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                _mouseMoveLastX = (int)(Math.Round(pos.X));
                if (_mouseMoveLastX < 0 || _mouseMoveLastX > Width)
                {
                    return;
                }

                double seconds      = RelativeXPositionToSeconds(_mouseMoveLastX);
                var    milliseconds = (int)(seconds * TimeCode.BaseUnit);

                if (IsParagrapBorderHit(milliseconds, NewSelectionParagraph))
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // Cursors.VSplit
                }
                else if (IsParagrapBorderHit(milliseconds, _selectedParagraph) ||
                         IsParagrapBorderHit(milliseconds, _displayableParagraphs))
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // VSplit;
                }
                else
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor);
                }
            };

            _imageView.OnMouseDraged += (object sender, NSEvent e) =>
            {
                var  pos         = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                bool onlyAltDown = (AppKit.NSEventModifierMask.AlternateKeyMask == NSEvent.CurrentModifierFlags);
                WaveformMouseMove(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, onlyAltDown);
            };

            _imageView.OnMouseWheel += (object sender, NSEvent e) =>
            {
                var delta = e.DeltaY / 3.0f;
                if (!MouseWheelScrollUpIsForward)
                {
                    delta = delta * -1;
                }
                if (Locked)
                {
                    FireOnPositonSelected(new ParagraphEventArgs(_currentVideoPositionSeconds + delta, null));
                }
                else
                {
                    StartPositionSeconds += delta;
                    if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds)
                    {
                        FireOnPositonSelected(new ParagraphEventArgs(StartPositionSeconds, null));
                    }
                }
            };
        }
        public AudioVisualizer(AudioVisualizerView imageView)
        {
            _imageView = imageView;

            _imageView.OnMouseClicked += (object sender, NSEvent e) =>
            {
                bool controlDown = (AppKit.NSEventModifierMask.ControlKeyMask & NSEvent.CurrentModifierFlags) > 0;
                bool altDown = (AppKit.NSEventModifierMask.AlternateKeyMask & NSEvent.CurrentModifierFlags) > 0;
                bool shiftDown = (AppKit.NSEventModifierMask.ShiftKeyMask & NSEvent.CurrentModifierFlags) > 0;

                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                WaveformMouseClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, shiftDown, controlDown, altDown);
            };

            _imageView.OnMouseDoubleClicked += (object sender, NSEvent e) =>
            {
                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                WaveformMouseDoubleClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true);
                                                
            };

            _imageView.OnMouseDown += (object sender, NSEvent e) => 
                {
                    var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                    WaveformMouseDown(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, false); // e.ButtonMask & NSEventButtonMask.);
                };

            _imageView.OnMouseEnter += (object sender, NSEvent e) =>
            {
                if (_wavePeaks == null)
                    return;
                if (_noClear)
                {
                    _noClear = false;
                }
                else
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor);  //Cursor = Cursors.Default;
                    _mouseDown = false;
                    _mouseDownParagraph = null;
                    _mouseMoveStartX = -1;
                    _mouseMoveEndX = -1;
                }
                        
                if (NewSelectionParagraph != null)
                {
                    _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - StartPositionSeconds);
                    _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - StartPositionSeconds);
                }
            };
            
            _imageView.OnMouseLeave += (object sender, NSEvent e) =>
            {
                _mouseDown = false;
            };

            _imageView.OnMouseMoved += (object sender, NSEvent e) =>
            {
                if (_wavePeaks == null)
                {
                    return;
                }

                var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                _mouseMoveLastX = (int)(Math.Round(pos.X));
                if (_mouseMoveLastX < 0 || _mouseMoveLastX > Width)
                {
                    return;
                }                             

                double seconds = RelativeXPositionToSeconds(_mouseMoveLastX);
                var milliseconds = (int)(seconds * TimeCode.BaseUnit);
                   
                if (IsParagrapBorderHit(milliseconds, NewSelectionParagraph))
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // Cursors.VSplit
                else if (IsParagrapBorderHit(milliseconds, _selectedParagraph) ||
                         IsParagrapBorderHit(milliseconds, _displayableParagraphs))
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // VSplit;
                }
                else
                {
                    _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor); 
                }
            };

            _imageView.OnMouseDraged += (object sender, NSEvent e) => 
                {
                    var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView);
                    bool onlyAltDown = (AppKit.NSEventModifierMask.AlternateKeyMask == NSEvent.CurrentModifierFlags);
                    WaveformMouseMove(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, onlyAltDown);
                };

            _imageView.OnMouseWheel += (object sender, NSEvent e) =>
            {
                var delta = e.DeltaY / 3.0f;
                if (!MouseWheelScrollUpIsForward)
                    delta = delta * -1;
                if (Locked)
                {
                    FireOnPositonSelected(new ParagraphEventArgs(_currentVideoPositionSeconds + delta, null));
                }
                else
                {
                    StartPositionSeconds += delta; 
                    if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds)
                        FireOnPositonSelected(new ParagraphEventArgs(StartPositionSeconds, null));
                }
            };
        }
 protected override void SetCursorSplit()
 {
     _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // Cursors.VSplit
 }