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 SeciUserInterface.Dialogs.VIs
11 {
12  public partial class AddVI : Form
13  {
14  private List<String> _toAdd = new List<String>();
15  public List<String> VIsToAdd { get { return _toAdd; } }
16 
17  public AddVI()
18  {
19  InitializeComponent();
20  viArrangement();
21 
22  //Set path for LabView VI's
23  browseDialog.InitialDirectory = Seci.Definitions.Status.LabViewDir;
24  }
25 
26  private void viArrangement()
27  {
28  dataGridView1.Visible = false;
29  btnAdd.Location = new System.Drawing.Point(btnAdd.Location.X, 34);
30  btnCancel.Location = new System.Drawing.Point(btnCancel.Location.X, 34);
31  this.Size = new System.Drawing.Size(this.Size.Width, 100);
32  }
33 
34  private void llbArrangement()
35  {
36  dataGridView1.Visible = true;
37  btnAdd.Location = new System.Drawing.Point(btnAdd.Location.X, 236);
38  btnCancel.Location = new System.Drawing.Point(btnCancel.Location.X, 236);
39  this.Size = new System.Drawing.Size(this.Size.Width, 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.ToLower().EndsWith(".llb"))
53  {
54  //Get available panels
55  try
56  {
57  List<String> panels = Seci.Managers.LabViewMgr.GetLlbInfo(browseDialog.FileName);
58 
59  if ((panels != null) && (panels.Count > 0))
60  {
61  //Fill dataGrid
62  for (int i = 0; i < panels.Count; ++i)
63  {
64  String[] rowInfo = panels[i].Split(';');
65 
66  String VIname = rowInfo[0].Replace(browseDialog.FileName, "");
67 
68  if (rowInfo[1] == "no")
69  {
70  dataGridView1.Rows.Add(VIname, false, false);
71  }
72  else
73  {
74  dataGridView1.Rows.Add(VIname, true, false);
75  }
76  }
77 
78  //Show Datagrid and rearrange dialog
79  llbArrangement();
80  }
81  }
82  catch (Exception err)
83  {
84  //throw error up to next level
85  throw err;
86  }
87  }
88  }
89  }
90 
91  private void btnAdd_Click(object sender, EventArgs e)
92  {
93  if (!String.IsNullOrEmpty(txtVI.Text))
94  {
95  btnAdd.Enabled = false;
96 
97  if (txtVI.Text.ToLower().EndsWith(".vi"))
98  {
99  _toAdd.Add(txtVI.Text);
100  }
101  else if (txtVI.Text.ToLower().EndsWith(".llb"))
102  {
103 
104  for (int i = 0; i < dataGridView1.Rows.Count; ++i)
105  {
106  if (dataGridView1.Rows[i].Cells[2].Value.ToString() == "True")
107  {
108  _toAdd.Add(txtVI.Text + dataGridView1.Rows[i].Cells[0].Value.ToString());
109  }
110  }
111  }
112 
113  DialogResult = DialogResult.OK;
114  Close();
115  }
116  else
117  {
118  MessageBox.Show("Please select a VI to add.", "VI Not Selected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
119  }
120  }
121  }
122 }
void btnBrowse_Click(object sender, EventArgs e)
Definition: AddVI.cs:42
void btnAdd_Click(object sender, EventArgs e)
Definition: AddVI.cs:91