コード例 #1
0
 private void SetCurrentCell(int?newRow, int?newColumn, int x, int y)
 {
     if (currentRow == newRow && currentColumn == newColumn) // make clicking a selected cell unselected
     {
         if (currentRow != null && currentColumn != null && currentColumn > 0)
         {
             bool buttonPressed = false;
             int  i             = 0;
             while (!buttonPressed && i < orderFocusButtons.Count())
             {
                 RoundButton button = orderFocusButtons[i];
                 if (button.GetButtonRegion(GetGridRectangle((int)currentRow, (int)currentColumn), buttonSize).IsVisible(x, y))
                 {
                     buttonPressed = true;
                     button.Invoke();
                 }
                 i++;
             }
             if (buttonPressed)
             {
                 gridPanel.Invalidate();
                 return;
             }
             newRow    = null;
             newColumn = null;
         }
     }
     currentRow    = newRow;
     currentColumn = newColumn;
     if (currentRow != null && currentRow != null)
     {
         gridPanel.Invalidate();
     }
 }
コード例 #2
0
        private void gridPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (currentRow != null && currentColumn != null)
            {
                bool buttonPressed = false;
                int  i             = 0;
                while (!buttonPressed && i < orderFocusButtons.Count())
                {
                    RoundButton button = orderFocusButtons[i];
                    if (button.GetButtonRegion(new Rectangle(currentColumn.Left, currentRow.Top, currentColumn.Width, currentRow.Height), buttonSize).IsVisible(e.Location))
                    {
                        buttonPressed = true;
                        button.Invoke();
                    }
                    i++;
                }
                if (buttonPressed) // we handled a button press, nothing else to do here
                {
                    return;
                }
                gridPanel.Invalidate(new Rectangle(currentColumn.Left - buttonSize, currentRow.Top, currentColumn.Width + buttonSize * 2, currentRow.Height));
            }
            Control columnCtrl = columnHeaderLayoutPanel.GetChildAtPoint(new Point(e.X, 0));
            Control rowCtrl    = rowHeaderLayoutPanel.GetChildAtPoint(new Point(0, e.Y));

            if (rowCtrl is BottleRowHeaderControl && columnCtrl is UserHeaderControl && (rowCtrl != currentRow || columnCtrl != currentColumn))
            {
                currentRow    = (BottleRowHeaderControl)rowCtrl;
                currentColumn = (UserHeaderControl)columnCtrl;
            }
            else
            {
                currentRow    = null;
                currentColumn = null;
            }
            if (currentRow != null && currentColumn != null)
            {
                gridPanel.Invalidate(new Rectangle(currentColumn.Left - buttonSize, currentRow.Top, currentColumn.Width + buttonSize * 2, currentRow.Height));
            }
        }