2 using System.Collections;
 
    3 using System.Collections.Generic;
 
    4 using System.ComponentModel;
 
    8 using System.Windows.Forms;
 
   11 namespace Sample_Environment_Control_Interface.Dialogs.Blocks
 
   17         private Boolean _changesMade = 
false;
 
   21             InitializeComponent();
 
   27             foreach (DataGridViewColumn i 
in dataGridView1.Columns)
 
   29                 i.SortMode = DataGridViewColumnSortMode.NotSortable;
 
   36             if (_tempBlocks == null)
 
   48             dataGridView1.Rows.Clear();
 
   51             if (_tempBlocks != null)
 
   53                 for (
int i = 0; i < _tempBlocks.Count; ++i)
 
   55                     Seci.BlockInfo temp = _tempBlocks[i];
 
   57                     dataGridView1.Rows.Add(temp.BlockName, temp.BlockUnits, temp.OwningComponent,
 
   58                         temp.ParentVI.Substring(temp.ParentVI.LastIndexOf(
'\\') + 1),
 
   59                         temp.UnderRunControl, temp.LowerLimit, temp.UpperLimit,
 
   65             dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
 
   71             addBlock.Dictionary = _tempBlocks;
 
   73             if (addBlock.ShowDialog() == DialogResult.OK)
 
   83             if (dataGridView1.CurrentRow != null)
 
   86                 if (dataGridView1.CurrentRow.Cells[2].Value == null)
 
   89                     editBlock.Dictionary = _tempBlocks;
 
   91                     editBlock.Block = (Seci.BlockInfo)_tempBlocks[dataGridView1.CurrentRow.Cells[colName.Name].Value.ToString()];
 
   93                     if (editBlock.ShowDialog() == DialogResult.OK)
 
  102                     MessageBox.Show(
"The selected block cannot be edited as it is part of a component. However, the run-control settings can be changed via the table." 
  103                     , 
"Cannot edit component block", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 
  110             if (dataGridView1.CurrentRow != null)
 
  113                 if (dataGridView1.CurrentRow.Cells[2].Value == null)
 
  116                     if (dataGridView1.CurrentRow != null)
 
  118                         _tempBlocks.Remove(dataGridView1.CurrentRow.Cells[colName.Name].Value.ToString());
 
  119                         dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
 
  125                     MessageBox.Show(
"The selected block cannot be deleted as it is part of a component." 
  126                     , 
"Cannot delete component block", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 
  135             if (_tempBlocks != null)
 
  141             if (nexus.ShowDialog() == DialogResult.OK)
 
  143                 _tempBlocks = nexus.blocksNexus;
 
  151             SECI_GUI.Pause_Timers();
 
  154             Seci.SeciInterface.Blocks = _tempBlocks;
 
  156             if (Seci.SeciInterface.SeciStatus.UseDaeMonitorVi)
 
  158                 Seci.SeciInterface.DAEMonitor_SetBlocks();
 
  162             SECI_GUI.Resume_Timers();
 
  166                 DialogResult = DialogResult.OK;
 
  170                 DialogResult = DialogResult.Cancel;
 
  179             doChanges((Seci.BlockInfo)_tempBlocks[dataGridView1.CurrentRow.Cells[colName.Name].Value.ToString()]);
 
  185             if (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colRuncontrol"])
 
  187                 block.UnderRunControl = (bool)dataGridView1.CurrentRow.Cells[
"colRuncontrol"].Value;
 
  189             else if (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colLower"])
 
  193                     block.LowerLimit = Convert.ToDouble(dataGridView1.CurrentRow.Cells[
"colLower"].Value);
 
  197                     MessageBox.Show(
"Invalid value enter; value rest to previous value.", 
"Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
  198                     dataGridView1.CurrentRow.Cells[
"colLower"].Value = block.LowerLimit;
 
  201             else if (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colUpper"])
 
  205                     block.UpperLimit = Convert.ToDouble(dataGridView1.CurrentRow.Cells[
"colUpper"].Value);
 
  209                     MessageBox.Show(
"Invalid value enter; value rest to previous value.", 
"Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
  210                     dataGridView1.CurrentRow.Cells[
"colUpper"].Value = block.UpperLimit;
 
  214             else if (dataGridView1.CurrentCell == dataGridView1.CurrentRow.Cells[
"colEnabled"])
 
  216                 block.BlockEnabled = (bool)dataGridView1.CurrentRow.Cells[
"colEnabled"].Value;
 
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...