SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
AddVI.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Data;
6 using System.Drawing;
7 using System.Text;
8 using System.Windows.Forms;
9 
10 namespace Sample_Environment_Control_Interface.Dialogs.VI
11 {
12  public partial class AddVI : Form
13  {
14  private List<String> _toAdd = new List<String>();
15 
16  public AddVI()
17  {
18  InitializeComponent();
19  viArrangement();
20 
21  //Set path for LabView VI's
22  browseDialog.InitialDirectory = Seci.SeciInterface.SeciStatus.LabViewDir;
23 
24  }
25 
26  private void viArrangement()
27  {
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);
32  }
33 
34  private void llbArrangement()
35  {
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);
40  }
41 
42  private void btnBrowse_Click(object sender, EventArgs e)
43  {
44  //Make sure controls are in their default arrangement
45  viArrangement();
46 
47  DialogResult res = browseDialog.ShowDialog();
48  if (res == DialogResult.OK)
49  {
50  txtVI.Text = browseDialog.FileName;
51 
52  if (browseDialog.FileName.EndsWith(".llb"))
53  {
54 
55  //Get available panels
56  try
57  {
58  List<String> panels = Seci.SeciInterface.LV_GetLLBInfo(browseDialog.FileName);
59 
60  if ((panels != null) && (panels.Count > 0))
61  {
62  //Fill dataGrid
63  for (int i = 0; i < panels.Count; ++i)
64  {
65  String[] rowInfo = panels[i].Split(';');
66 
67  String VIname = rowInfo[0].Replace(browseDialog.FileName, "");
68 
69  if (rowInfo[1] == "no")
70  {
71  dataGridView1.Rows.Add(VIname, false, false);
72  }
73  else
74  {
75  dataGridView1.Rows.Add(VIname, true, false);
76  }
77  }
78 
79  //Show Datagrid and rearrange dialog
80  llbArrangement();
81  }
82  }
83  catch (Exception err)
84  {
85  //throw error up to next level
86  throw err;
87  }
88  }
89  }
90  }
91 
92  private void btnAdd_Click(object sender, EventArgs e)
93  {
94  if (!String.IsNullOrEmpty(txtVI.Text))
95  {
96 
97  btnAdd.Enabled = false;
98 
99  if (txtVI.Text.ToLower().EndsWith(".vi"))
100  {
101  _toAdd.Add(txtVI.Text);
102  }
103  else if (txtVI.Text.ToLower().EndsWith(".llb"))
104  {
105 
106  for (int i = 0; i < dataGridView1.Rows.Count; ++i)
107  {
108  if (dataGridView1.Rows[i].Cells[2].Value.ToString() == "True")
109  {
110  _toAdd.Add(txtVI.Text + dataGridView1.Rows[i].Cells[0].Value.ToString());
111  }
112  }
113  }
114 
115  List<String> vis = Seci.SeciInterface.LV_GetListOfVIs();
116 
117  //Add and Load the VIs
118  for (int i = 0; i < _toAdd.Count; ++i)
119  {
120  if (!vis.Contains(_toAdd[i]))
121  {
122  Seci.SeciInterface.LVPanelProperties.Add(new Seci.LabView.LabViewPanelInfo(_toAdd[i], true, false));
123  Seci.SeciInterface.LV_AddVI(_toAdd[i]);
124  Seci.SeciInterface.LV_ShowVI(_toAdd[i]);
125  }
126  else
127  {
128  MessageBox.Show("The VI " + _toAdd[i] + " is already in this configuration and will not be added again!", "Duplicate VI!", MessageBoxButtons.OK, MessageBoxIcon.Information);
129  }
130  }
131 
132  DialogResult = DialogResult.OK;
133  Close();
134  }
135  else
136  {
137  MessageBox.Show("Please select a VI to add.", "VI Not Selected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
138  }
139  }
140  }
141 }
void btnBrowse_Click(object sender, EventArgs e)
Definition: AddVI.cs:42
void btnAdd_Click(object sender, EventArgs e)
Definition: AddVI.cs:92
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...