2 using System.Collections;
 
    3 using System.Collections.Generic;
 
    4 using System.ComponentModel;
 
    8 using System.Windows.Forms;
 
   10 namespace Sample_Environment_Control_Interface.Dialogs.Blocks
 
   21             InitializeComponent();
 
   39                 txtBlockName.Text = Block.BlockName;
 
   40                 txtUnits.Text = Block.BlockUnits;
 
   41                 txtAlias.Text = Block.Alias;
 
   43                 txtLogRate.Text = Block.LoggingRate.ToString();
 
   45                 comVI.SelectedItem = Block.ParentVI;
 
   46                 comRead.SelectedItem = Block.ReadControl;
 
   48                 chkEnabled.Checked = Block.BlockEnabled;
 
   50                 radLog.Checked = Block.LogValueToFile;
 
   51                 radOnlyChanges.Checked = Block.LogChangesOnly;
 
   52                 radOnlyChangesTol.Checked = Block.LogChangesTolerance;
 
   53                 txtTolerance.Text = Block.Tolerance.ToString();
 
   55                 if (Block.WriteControl != null)
 
   57                     comWrite.SelectedItem = Block.WriteControl;
 
   60                 if (Block.GoButton != null)
 
   62                     comGo.SelectedItem = Block.GoButton;
 
   65                 if (Block.WaitForControl != null)
 
   67                     comWaitfor.SelectedItem = Block.WaitForControl;
 
   70                 if (Block.UnderRunControl)
 
   72                     chkRuncontrol.Checked = 
true;
 
   73                     txtUpper.Text = Block.UpperLimit.ToString();
 
   74                     txtLower.Text = Block.LowerLimit.ToString();
 
   77                 chkSaveSettings.Checked = Block.SaveSettings;
 
   84             for (
int i = 0; i < Seci.SeciInterface.LVPanelProperties.Count; ++i)
 
   86                 comVI.Items.Add(Seci.SeciInterface.LVPanelProperties[i].PanelName);
 
   90             comVI.Items.Add(Seci.SeciInterface.DAE_GetLocation());
 
   93             comVI.Items.Add(Seci.SeciInterface.BeamLogger_GetLocation());
 
   99             String[] controls = Seci.SeciInterface.LV_GetListOfControls(VIname).ToArray();
 
  102             comRead.Items.Clear();
 
  103             comRead.Items.AddRange(controls);
 
  104             comRead.SelectedIndex = -1;
 
  107             comWrite.Items.Clear();
 
  108             comWrite.Items.AddRange(controls);
 
  109             comWrite.SelectedIndex = -1;
 
  113             comGo.Items.AddRange(controls);
 
  114             comGo.SelectedIndex = -1;
 
  117             comWaitfor.Items.Clear();
 
  118             comWaitfor.Items.AddRange(controls);
 
  119             comWaitfor.SelectedIndex = -1;
 
  124             if (comVI.SelectedIndex != -1)
 
  126                 fillInControls(comVI.SelectedItem.ToString());
 
  132             comWrite.SelectedIndex = -1;
 
  137             comGo.SelectedIndex = -1;
 
  142             comWaitfor.SelectedIndex = -1;
 
  148             if (checkFilledOutCorrectly())
 
  150                 Seci.BlockInfo newBlock = 
new Seci.BlockInfo();
 
  153                 newBlock.BlockName = txtBlockName.Text;
 
  154                 newBlock.BlockUnits = txtUnits.Text;
 
  155                 newBlock.ParentVI = comVI.SelectedItem.ToString();
 
  156                 newBlock.Alias = txtAlias.Text;
 
  158                 newBlock.ReadControl = comRead.SelectedItem.ToString();
 
  159                 newBlock.LoggingRate = Convert.ToSingle(txtLogRate.Text);
 
  161                 newBlock.BlockEnabled = chkEnabled.Checked;
 
  164                 newBlock.LogValueToFile = radLog.Checked;
 
  165                 newBlock.LogChangesOnly = radOnlyChanges.Checked;
 
  166                 newBlock.LogChangesTolerance = radOnlyChangesTol.Checked;
 
  168                 newBlock.Tolerance = Convert.ToDouble(txtTolerance.Text);
 
  170                 newBlock.UnderRunControl = chkRuncontrol.Checked;
 
  171                 newBlock.UpperLimit = Convert.ToDouble(txtUpper.Text);
 
  172                 newBlock.LowerLimit = Convert.ToDouble(txtLower.Text);
 
  173                 newBlock.SaveSettings = chkSaveSettings.Checked;
 
  175                 if (comWrite.SelectedIndex != -1)
 
  177                     newBlock.WriteControl = comWrite.SelectedItem.ToString();
 
  180                 if (comGo.SelectedIndex != -1)
 
  182                     newBlock.GoButton = comGo.SelectedItem.ToString();
 
  185                 if (comWaitfor.SelectedIndex != -1)
 
  187                     newBlock.WaitForControl = comWaitfor.SelectedItem.ToString();
 
  195                         Dictionary.Add(newBlock.BlockName, newBlock);
 
  197                     catch (Exception err)
 
  199                         MessageBox.Show(err.Message, 
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
  209                         Dictionary.Remove(Block.BlockName);
 
  210                         Dictionary.Add(newBlock.BlockName, newBlock);
 
  212                     catch (Exception err)
 
  214                         MessageBox.Show(err.Message, 
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
  219                 DialogResult = DialogResult.OK;
 
  227             List<String> filledList = checkFilledOutandValid();
 
  229             if (filledList.Count > 0)
 
  231                 String message = 
"The following entries are invalid:";
 
  233                 for (
int i = 0; i < filledList.Count; ++i)
 
  235                     message = message + Environment.NewLine + filledList[i];
 
  238                 MessageBox.Show(message, 
"Invalid Entries!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 
  251             List<String> list = 
new List<String>();
 
  255             if (txtBlockName.Text == 
"")
 
  257                 list.Add(
" - No block name entered.");
 
  260             if (comVI.SelectedIndex == -1)
 
  262                 list.Add(
" - No VI selected.");
 
  265             if (comRead.SelectedIndex == -1)
 
  267                 list.Add(
" - No read control selected.");
 
  270             if (chkRuncontrol.Checked)
 
  272                 if (txtUpper.Text == 
"")
 
  274                     list.Add(
" - No upper limit entered for run-control.");
 
  276                 else if (!Double.TryParse(txtUpper.Text, out dummy))
 
  278                     list.Add(
" - upper limit value not valid.");
 
  281                 if (txtLower.Text == 
"")
 
  283                     list.Add(
" - No lower limit entered for run-control.");
 
  285                 else if (!Double.TryParse(txtLower.Text, out dummy))
 
  287                     list.Add(
" - lower limit value not valid.");
 
  292                 if ((txtUpper.Text == 
"")||(!Double.TryParse(txtUpper.Text, out dummy)))
 
  297                 if ((txtLower.Text == 
"")||(!Double.TryParse(txtLower.Text, out dummy)))
 
  306                 if (txtLogRate.Text == 
"")
 
  308                     list.Add(
" - No log rate entered.");
 
  312                     if (!Double.TryParse(txtLogRate.Text, out dummy))
 
  314                         list.Add(
" - log-rate value not valid.");
 
  318             else if (radOnlyChangesTol.Checked)
 
  320                 if (txtTolerance.Text == 
"")
 
  322                     list.Add(
" - No tolerance entered.");
 
  326                     if (!Double.TryParse(txtTolerance.Text, out dummy))
 
  328                         list.Add(
" - tolerance value not valid.");
 
  358             if (Char.IsDigit(e.KeyChar) || e.KeyChar == 
'.' || e.KeyChar == 
'\b')
 
  371             if (Char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == 
'_' || e.KeyChar == 
'\b')
 
  383             if (chkRuncontrol.Checked)
 
  385                 txtUpper.Enabled = 
true;
 
  386                 txtLower.Enabled = 
true;
 
  390                 txtUpper.Enabled = 
false;
 
  391                 txtLower.Enabled = 
false;
 
void btnClearWaitfor_Click(object sender, EventArgs e)
void chkRuncontrol_CheckedChanged(object sender, EventArgs e)
void isCharValid_KeyPress(object sender, KeyPressEventArgs e)
void comVI_SelectedIndexChanged(object sender, EventArgs e)
void fillInControls(String VIname)
Boolean isNumeric(KeyPressEventArgs e)
void btnOK_Click(object sender, EventArgs e)
void NumericOnly_KeyPress(object sender, KeyPressEventArgs e)
void btnClearWrite_Click(object sender, EventArgs e)
Boolean isCharValid(KeyPressEventArgs e)
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
Seci.BlockDictionary Dictionary
List< String > checkFilledOutandValid()
void AddBlock_Load(object sender, EventArgs e)
void btnClearGo_Click(object sender, EventArgs e)
Boolean checkFilledOutCorrectly()