private void algorithmDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { AlgorithmGraphType currentType = this.directedGraphRadioButton.Checked ? AlgorithmGraphType.Directed : AlgorithmGraphType.Undirected; if ((this.algorithmDataGridView.Rows[e.RowIndex].Tag as AlgorithmGraphType?) == currentType || (this.algorithmDataGridView.Rows[e.RowIndex].Tag as AlgorithmGraphType?) == AlgorithmGraphType.Any) { this.algorithms[e.RowIndex].Invoke(); } else { MessageBox.Show($"Данный алгоритм применим к {(currentType == AlgorithmGraphType.Directed ? "неориентированному" : "ориентированному")} графу. По крайней мере в данной программе", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void AdjustAlgorithms() { AlgorithmGraphType currentType = this.directedGraphRadioButton.Checked ? AlgorithmGraphType.Directed : AlgorithmGraphType.Undirected; foreach (DataGridViewRow row in algorithmDataGridView.Rows) { if ((row.Tag as AlgorithmGraphType?) == currentType) { (row.Cells[0] as DataGridViewTextBoxCell).Style.ForeColor = (row.Cells[1] as DataGridViewButtonCell).Style.ForeColor = System.Drawing.Color.Black; } else if ((row.Tag as AlgorithmGraphType?) != AlgorithmGraphType.Any) { (row.Cells[0] as DataGridViewTextBoxCell).Style.ForeColor = (row.Cells[1] as DataGridViewButtonCell).Style.ForeColor = System.Drawing.Color.LightGray; } } }