SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
AddBeamlineParameter.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 
10 namespace SeciControls
11 {
12  public partial class AddBeamlineParameter : Form
13  {
14  private List<String> _parameterNames = new List<String>();
15  private List<String> _parameterTypes = new List<String>();
16 
18  {
20  _parameterNames = Seci.Standard.BeamlineParameters.GetParameterNames();
21  _parameterTypes = Seci.Standard.BeamlineParameters.GetParameterTypes();
22  }
23 
24  private void AddSampleParameter_Load(object sender, EventArgs e)
25  {
26  comName.Items.AddRange(_parameterNames.ToArray());
27  comType2.Items.AddRange(_parameterTypes.ToArray());
28 
29  comType.SelectedIndex = 0;
30  }
31 
32  private void comType_SelectedIndexChanged(object sender, EventArgs e)
33  {
34  if (comType.SelectedIndex == 0)
35  {
36  txtName.Visible = false;
37  txtUnits.Visible = false;
38  comType2.Visible = false;
39  lblUnits.Visible = false;
40  lblType.Visible = false;
41 
42  comName.Visible = true;
43  }
44  else
45  {
46  txtName.Visible = true;
47  txtUnits.Visible = true;
48  comType2.Visible = true;
49  lblUnits.Visible = true;
50  lblType.Visible = true;
51 
52  comName.Visible = false;
53  }
54  }
55 
56  private void btnCancel_Click(object sender, EventArgs e)
57  {
58  DialogResult = DialogResult.Cancel;
59  Close();
60  }
61 
62  private void btnAdd_Click(object sender, EventArgs e)
63  {
64  try
65  {
66  if (comType.SelectedIndex == 0)
67  {
68  //Standard parameter
69  if (comName.SelectedIndex != -1 && !String.IsNullOrEmpty(txtValue.Text))
70  {
71  Seci.Standard.BeamlineParameters.CreateParameter(comName.SelectedIndex, txtValue.Text);
72  }
73  else
74  {
75  MessageBox.Show("Please make sure all values have been entered correctly.", "Missing Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
76  return;
77  }
78  }
79  else if (comType.SelectedIndex == 1)
80  {
81  //custom parameter
82  if (comType.SelectedIndex != -1 && !String.IsNullOrEmpty(txtName.Text) && !String.IsNullOrEmpty(txtValue.Text))
83  {
84  Seci.Standard.BeamlineParameters.CreateParameter(txtName.Text, comType2.SelectedIndex, txtUnits.Text, txtValue.Text);
85  }
86  else
87  {
88  MessageBox.Show("Please make sure all values have been entered correctly.", "Missing Values", MessageBoxButtons.OK, MessageBoxIcon.Error);
89  return;
90  }
91  }
92  }
93  catch (Exception err)
94  {
95  MessageBox.Show(err.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
96  return;
97  }
98 
99  System.Threading.Thread.Sleep(500);
100 
101  DialogResult = DialogResult.OK;
102  Close();
103  }
104 
105  }
106 }
void AddSampleParameter_Load(object sender, EventArgs e)
void comType_SelectedIndexChanged(object sender, EventArgs e)
void btnAdd_Click(object sender, EventArgs e)
void InitializeComponent()
Required method for Designer support - do not modify the contents of this method with the code editor...
void btnCancel_Click(object sender, EventArgs e)