ComponentFactory.Krypton.Toolkit.ButtonController.MouseUp C# (CSharp) Method

MouseUp() public method

Mouse button has been released in the view.
public MouseUp ( Control c, Point pt, MouseButtons button ) : void
c Control Reference to the source control instance.
pt Point Mouse position relative to control.
button MouseButtons Mouse button released.
return void
        public virtual void MouseUp(Control c, Point pt, MouseButtons button)
        {
            // Is the controller allowed to track/click
            if (IsOperating)
            {
                // If the button is not enabled then we do nothing on a mouse down
                if (_target.Enabled)
                {
                    // Remove the repeat timer
                    if (_repeatTimer != null)
                    {
                        _repeatTimer.Stop();
                        _repeatTimer.Dispose();
                        _repeatTimer = null;
                    }

                    // If the mouse is currently captured
                    if (_captured)
                    {
                        // Not capturing mouse input anymore
                        _captured = false;

                        // Only interested in left mouse being released
                        if (button == MouseButtons.Left)
                        {
                            if (_dragging)
                                OnDragEnd(pt);

                            // Only if the button is still pressed, do we generate a click
                            if ((_target.ElementState == PaletteState.Pressed) ||
                                (_target.ElementState == (PaletteState.Pressed | PaletteState.Checked)))
                            {
                                if (!_fixedPressed)
                                {
                                    // Move back to hot tracking state, we have to do this
                                    // before the click is generated because the click processing
                                    // might change focus and so cause the MouseLeave to be
                                    // called and change the state. If this was after the click
                                    // then it would overwrite and lose that leave state change.
                                    _target.ElementState = PaletteState.Tracking;
                                }

                                // Can only click if enabled
                                if (_target.Enabled && !ClickOnDown)
                                {
                                    // Generate a click event
                                    OnClick(new MouseEventArgs(MouseButtons.Left, 1, pt.X, pt.Y, 0));
                                }
                            }

                            // Repaint to reflect new state
                            OnNeedPaint(true);
                        }
                        else
                        {
                            if (_dragging)
                                OnDragQuit();

                            // Update the visual state
                            UpdateTargetState(pt);
                        }
                    }
                }
            }
        }