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.VI
12 public partial class AddVI : Form
14 private List<String> _toAdd =
new List<String>();
18 InitializeComponent();
22 browseDialog.InitialDirectory = Seci.SeciInterface.SeciStatus.LabViewDir;
28 dataGridView1.Visible =
false;
29 btnAdd.Location =
new System.Drawing.Point(265, 34);
30 btnCancel.Location =
new System.Drawing.Point(346, 34);
31 this.Size =
new System.Drawing.Size(439,100);
36 dataGridView1.Visible =
true;
37 btnAdd.Location =
new System.Drawing.Point(265, 236);
38 btnCancel.Location =
new System.Drawing.Point(346, 236);
39 this.Size =
new System.Drawing.Size(439, 303);
47 DialogResult res = browseDialog.ShowDialog();
48 if (res == DialogResult.OK)
50 txtVI.Text = browseDialog.FileName;
52 if (browseDialog.FileName.EndsWith(
".llb"))
58 List<String> panels = Seci.SeciInterface.LV_GetLLBInfo(browseDialog.FileName);
60 if ((panels != null) && (panels.Count > 0))
63 for (
int i = 0; i < panels.Count; ++i)
65 String[] rowInfo = panels[i].Split(
';');
67 String VIname = rowInfo[0].Replace(browseDialog.FileName,
"");
69 if (rowInfo[1] ==
"no")
71 dataGridView1.Rows.Add(VIname,
false,
false);
75 dataGridView1.Rows.Add(VIname,
true,
false);
94 if (!String.IsNullOrEmpty(txtVI.Text))
97 btnAdd.Enabled =
false;
99 if (txtVI.Text.ToLower().EndsWith(
".vi"))
101 _toAdd.Add(txtVI.Text);
103 else if (txtVI.Text.ToLower().EndsWith(
".llb"))
106 for (
int i = 0; i < dataGridView1.Rows.Count; ++i)
108 if (dataGridView1.Rows[i].Cells[2].Value.ToString() ==
"True")
110 _toAdd.Add(txtVI.Text + dataGridView1.Rows[i].Cells[0].Value.ToString());
115 List<String> vis = Seci.SeciInterface.LV_GetListOfVIs();
118 for (
int i = 0; i < _toAdd.Count; ++i)
120 if (!vis.Contains(_toAdd[i]))
123 Seci.SeciInterface.LV_AddVI(_toAdd[i]);
124 Seci.SeciInterface.LV_ShowVI(_toAdd[i]);
128 MessageBox.Show(
"The VI " + _toAdd[i] +
" is already in this configuration and will not be added again!",
"Duplicate VI!", MessageBoxButtons.OK, MessageBoxIcon.Information);
132 DialogResult = DialogResult.OK;
137 MessageBox.Show(
"Please select a VI to add.",
"VI Not Selected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
void btnBrowse_Click(object sender, EventArgs e)
void btnAdd_Click(object sender, EventArgs e)
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...