2 using System.Collections.Generic;
3 using System.ComponentModel;
7 using System.Windows.Forms;
9 namespace Sample_Environment_Control_Interface.Dialogs.Blocks
20 InitializeComponent();
26 foreach (DataGridViewColumn i
in dataGridView1.Columns)
28 i.SortMode = DataGridViewColumnSortMode.NotSortable;
32 if (blocksNexus != null)
34 for (
int i = 0; i < blocksNexus.Count; ++i)
36 dataGridView1.Rows.Add(blocksNexus[i].BlockName, blocksNexus[i].NexusName, blocksNexus[i].NexusGroup,
false);
41 if (compsBlocksNexus != null)
43 for (
int i = 0; i < compsBlocksNexus.GetLength(0); ++i)
45 for (
int j = 0; j < compsBlocksNexus[i].Count; ++j)
47 dataGridView1.Rows.Add(compsBlocksNexus[i][j].BlockName, compsBlocksNexus[i][j].NexusName, compsBlocksNexus[i][j].NexusGroup,
true);
48 dataGridView1.Rows[dataGridView1.Rows.Count - 1].ReadOnly =
true;
54 ((DataGridViewComboBoxColumn) dataGridView1.Columns[
"colNexusGroup"]).Items.AddRange(Seci.SeciInterface.SeciStatus.NexusGroups);
60 if ((dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colNexusName"]) || (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colNexusGroup"]))
62 if ((dataGridView1.CurrentRow.Cells[
"colNexusName"].Value != null)&&(dataGridView1.CurrentRow.Cells[
"colNexusGroup"].Value != null))
64 String name = dataGridView1.CurrentRow.Cells[
"colNexusName"].Value.ToString();
65 String group = dataGridView1.CurrentRow.Cells[
"colNexusGroup"].Value.ToString();
67 for (
int i = 0; i < dataGridView1.Rows.Count; ++i)
69 if ((i != dataGridView1.CurrentRow.Index)&&(dataGridView1.Rows[i].Cells[
"colNexusName"].Value != null)&&(dataGridView1.Rows[i].Cells[
"colNexusGroup"] != null))
71 if ((dataGridView1.Rows[i].Cells[
"colNexusName"].Value.ToString() == name) && (dataGridView1.Rows[i].Cells[
"colNexusGroup"].Value.ToString() == group))
73 MessageBox.Show(
"NeXus names must be unique within their group - please change this name!",
"Not Unique", MessageBoxButtons.OK, MessageBoxIcon.Error);
74 dataGridView1.CurrentRow.Cells[
"colNexusName"].Value =
"";
85 Boolean IsOkay =
true;
87 if (blocksNexus !=null)
89 for (
int i = 0; i < blocksNexus.Count; ++i)
91 if (dataGridView1.Rows[i].Cells[
"colNexusName"].Value.ToString() !=
"")
93 if (dataGridView1.Rows[i].Cells[
"colNexusGroup"].Value != null)
95 blocksNexus[i].NexusName = dataGridView1.Rows[i].Cells[
"colNexusName"].Value.ToString();
96 blocksNexus[i].NexusGroup = dataGridView1.Rows[i].Cells[
"colNexusGroup"].Value.ToString();
100 MessageBox.Show(
"A corresponding NeXus group must be chosen for each NeXus name",
"No NeXus Group Chosen!", MessageBoxButtons.OK, MessageBoxIcon.Error);
109 DialogResult = DialogResult.OK;
void SetNexusInfo_Load(object sender, EventArgs e)
void dataGridView1_CellValidated(object sender, DataGridViewCellEventArgs e)
Seci.BlockDictionary blocksNexus
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
void btnOK_Click(object sender, EventArgs e)
Seci.BlockDictionary[] compsBlocksNexus