XPTable.Models.Table.OnMouseUp C# (CSharp) Method

OnMouseUp() protected method

Raises the MouseUp event
protected OnMouseUp ( MouseEventArgs e ) : void
e MouseEventArgs A MouseEventArgs that contains the event data
return void
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (!this.CanRaiseEvents)
                return;

            // work out the current state of  play
            this.CalcTableState(e.X, e.Y);

            TableRegion region = this.HitTest(e.X, e.Y);

            if (e.Button == MouseButtons.Left)
            {
                // if the left mouse button was down for a cell,
                // Raise a mouse up for that cell
                if (!this.LastMouseDownCell.IsEmpty)
                {
                    if (this.IsValidCell(this.LastMouseDownCell))
                        this.RaiseCellMouseUp(this.LastMouseDownCell, e);

                    // reset the lastMouseDownCell
                    this.lastMouseDownCell = CellPos.Empty;
                }

                #region Finish column resizing
                // if we have just finished resizing, it might
                // be a good idea to relayout the table
                if (this.resizingColumnIndex != -1)
                {
                    if (this.resizingColumnWidth != -1)
                    {
                        this.DrawReversibleLine(this.ColumnRect(this.resizingColumnIndex).Left + this.resizingColumnWidth);
                        this.ColumnModel.Columns[this.resizingColumnIndex].Width = this.resizingColumnWidth;
                    }

                    this.resizingColumnIndex = -1;
                    this.resizingColumnWidth = -1;

                    this.UpdateScrollBars();
                    this.Invalidate(this.PseudoClientRect, true);
                }
                #endregion

                // check if the mouse was released in a column header
                if (region == TableRegion.ColumnHeader)
                {
                    #region In column header
                    int column = this.ColumnIndexAt(e.X, e.Y);

                    // if we are in the header, check if we are in the pressed column
                    if (this.pressedColumn != -1)
                    {
                        if (this.pressedColumn == column)
                        {
                            if (this.hotColumn != -1 && this.hotColumn != column)
                                this.ColumnModel.Columns[this.hotColumn].InternalColumnState = ColumnState.Normal;

                            this.ColumnModel.Columns[this.pressedColumn].InternalColumnState = ColumnState.Hot;
                            this.RaiseHeaderMouseUp(column, e);
                        }

                        this.pressedColumn = -1;

                        // only sort the column if we have rows to sort
                        if ((this.IsValidColumn(column)) && (this.ColumnModel.Columns[column].Sortable))
                        {
                            if (this.TableModel != null && this.TableModel.Rows.Count > 0)
                                this.Sort(column);
                        }

                        this.Invalidate(this.HeaderRectangle, false);
                    }

                    return;
                    #endregion
                }

                // the mouse wasn't released in a column header, so if we
                // have a pressed column then we need to make it unpressed
                if (this.pressedColumn != -1)
                {
                    this.pressedColumn = -1;
                    this.Invalidate(this.HeaderRectangle, false);
                }

                _dragDropHelper.MouseUp();

            } // e.Button == MouseButtons.Left
        }
Table