public MatrixForm(Matrix matrix, ButtonModel button) { this.matrix = matrix; this.button = button; InitializeComponent(); labels = new MatrixCellControl[Settings.matrixSize, Settings.matrixSize]; int fontSize = Settings.fontsizes[Array.IndexOf(Settings.cellsizes, matrix.cellsize)]; int subFontSize = Settings.subTextSizes[Array.IndexOf(Settings.cellsizes, matrix.cellsize)]; for (int i = 0; i < Settings.ranks.Length; i++) { for (int j = 0; j < Settings.ranks.Length; j++) { MatrixCellControl tb = new MatrixCellControl(); tb.Text = Settings.ranks[i] + Settings.ranks[j]; tb.X = i; tb.Y = j; if (matrix.matrix[i, j] == null || matrix.matrix[i, j].color == null) { if (i < j) { tb.Text = tb.Text + "s"; } else if (i > j) { tb.Text = tb.Text + "o"; } setDefaultCellColor(tb); } else { tb.BackColor = (Color)matrix.matrix[i, j].color; tb.BorderColor = Settings.selectedCellBorder; } tb.Width = matrix.cellsize; tb.Height = matrix.cellsize; tb.Top = i * matrix.cellsize + i * margin; tb.Left = j * matrix.cellsize + j * margin; if (matrix.matrix[i, j] != null) { tb.text = matrix.matrix[i, j].text; } tb.SubFontSize = subFontSize; tb.TextAlign = ContentAlignment.MiddleCenter; tb.ContextMenuStrip = contextMenuStrip1; tb.Font = new Font(tb.Font.FontFamily, fontSize); this.matrixPanel.Controls.Add(tb); tb.Click += tb_Click; labels[i, j] = tb; } } colorBox.BackColor = matrix.color; Doresize(); setSizeCombo(); this.Left = matrix.x; this.Top = matrix.y; }
private void setDefaultCellColor(MatrixCellControl cell) { if (cell.X < cell.Y) { cell.BackColor = Color.FromArgb(0xFF, 0xE7, 0xB5); } else if (cell.X > cell.Y) { cell.BackColor = Color.FromArgb(0xE7, 0xEF, 0xF7); } else { cell.BackColor = Color.FromArgb(0xCE, 0xDE, 0xC6); } }