Longkong.ColorPicker.Controls.ColorSwatchPanel.OnMouseMove C# (CSharp) Method

OnMouseMove() protected method

protected OnMouseMove ( MouseEventArgs e ) : void
e MouseEventArgs
return void
        protected override void OnMouseMove( MouseEventArgs e )
        {
            int width = m_swatchOuterRegionWidth - ( 2 * OUTER_PADDING );
            int height = m_swatchOuterRegionHeight - ( 2 * OUTER_PADDING );
            int x = e.X - OUTER_PADDING;
            int y = e.Y - OUTER_PADDING;

            Rectangle r = new Rectangle( m_startX, m_startY, width, height );
            Rectangle c = new Rectangle( e.X, e.Y, 1, 1 );

            if ( c.IntersectsWith( r ) ) {

                int swatchColumnIndex = ( x / ( SWATCH_WIDTH + PADDING ) );
                int swatchRowIndex = ( y / ( SWATCH_HEIGHT + PADDING ) );

                ColorSwatch potentialSwatch = m_swatchArray[ swatchColumnIndex, swatchRowIndex ];
                Rectangle potentialSwatchRectangle = new Rectangle( potentialSwatch.Location, potentialSwatch.Size );
                Point cursorPoint = new Point( e.X, e.Y );
                Rectangle cursorRectangle = new Rectangle( cursorPoint, new Size( 1, 1 ) );

                if ( cursorRectangle.IntersectsWith( potentialSwatchRectangle ) ) {

                    // hides the tooltip when moving from swatch to swatch.
                    if ( !m_lastSwatch.Equals( potentialSwatch ) ) {
                        this.colorTip.Active = false;
                    }

                    if ( !potentialSwatch.Description.Equals( colorTip.GetToolTip( this ) ) ) {
                        this.colorTip.SetToolTip( this, potentialSwatch.Description );
                    }

                    this.colorTip.Active = true;
                    m_lastSwatch = potentialSwatch;
                    this.Cursor = Cursors.Hand;

                } else {

                    this.Cursor = Cursors.Default;
                    this.colorTip.SetToolTip( this, "" );
                    this.colorTip.Active = false;

                }

            }
        }