示例#1
0
 //clear cell style
 void ClearCellStyle(CellStyleState StyleState)
 {
     for (int i = 0; i < BLOCK_ROWS * CELL_ROWS; i++)
     {
         for (int j = 0; j < BLOCK_COLUMNS * CELL_COLUMNS; j++)
         {
             if (Numbers[i, j].StyleState == StyleState)
             {
                 Numbers[i, j].StyleState = CellStyleState.Normal;
                 Numbers[i, j].Cell.BackColor = Color.White;
             }
         }
     }
 }
示例#2
0
        //set cell style
        void SetCellStyle(int row, int column, CellStyleState StyleState)
        {
            Color BackgroundColor = Color.White;
            TextBox tb = Numbers[row, column].Cell;

            if (!tb.InvokeRequired)
            {
                tb.Font = new Font(CELL_FONT_FAMILY, CELL_FONT_SIZE);
                switch (StyleState)
                {
                    case CellStyleState.Solved:
                        BackgroundColor = Color.LightGreen;
                        break;
                    case CellStyleState.Conflicted:
                        BackgroundColor = Color.Tan;
                        break;
                    case CellStyleState.Checked:
                        BackgroundColor = Color.Gainsboro;
                        break;
                    case CellStyleState.ShowedPossibles:
                        BackgroundColor = Color.Coral;
                        tb.Font = new Font(CELL_FONT_FAMILY, CELL_FONT_SIZE_SMALL);
                        break;
                    case CellStyleState.Guessed:
                        BackgroundColor = Color.DarkSeaGreen;
                        break;
                    case CellStyleState.Guessing:
                        BackgroundColor = Color.LightCoral;
                        break;
                    default:
                        break;
                }
                tb.BackColor = BackgroundColor;
                tb.Refresh();
            }
            else
            {
                SetCellStyleDelegate del = new SetCellStyleDelegate(SetCellStyle);
                tb.Invoke(del, new object[] { row, column, StyleState });
            }
        }