SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
RemoveVI.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.Text;
7 using System.Windows.Forms;
8 
9 namespace Sample_Environment_Control_Interface.Dialogs.VI
10 {
11  public partial class RemoveVI : Form
12  {
13 
14  private String[] toRemove;
15 
16  public RemoveVI()
17  {
18  InitializeComponent();
19  }
20 
21  private void RemoveVI_Load(object sender, EventArgs e)
22  {
23 
24  for (int i = 0; i < Seci.SeciInterface.LVPanelProperties.Count; ++i)
25  {
26  lstVIs.Items.Add(Seci.SeciInterface.LVPanelProperties[i].PanelName);
27  }
28 
29  }
30 
31  private void btnRemove_Click(object sender, EventArgs e)
32  {
33  if (lstVIs.SelectedIndex != -1)
34  {
35  lstToRemove.Items.Add(lstVIs.SelectedItem);
36  lstVIs.Items.RemoveAt(lstVIs.SelectedIndex);
37  }
38  }
39 
40  private void btnUndo_Click(object sender, EventArgs e)
41  {
42  if (lstToRemove.SelectedIndex != -1)
43  {
44  lstVIs.Items.Add(lstToRemove.SelectedItem);
45  lstToRemove.Items.RemoveAt(lstToRemove.SelectedIndex);
46  }
47  }
48 
49  private void btnOK_Click(object sender, EventArgs e)
50  {
51  if (lstToRemove.Items.Count > 0)
52  {
53  //Copy the names to remove
54  toRemove = new String[lstToRemove.Items.Count];
55 
56  for (int i = 0; i < lstToRemove.Items.Count; ++i)
57  {
58  toRemove[i] = lstToRemove.Items[i].ToString();
59  }
60  }
61 
62  if (toRemove != null)
63  {
64  //Remove the VIs
65  for (int i = 0; i < toRemove.GetLength(0); ++i)
66  {
67  //Find out which objects correspond to the names to remove
68  for (int j = 0; j < Seci.SeciInterface.LVPanelProperties.Count; ++j)
69  {
70  if (Seci.SeciInterface.LVPanelProperties[j].PanelName == toRemove[i])
71  {
72  //First remove any blocks that correspond to the VI's being removed
73  Seci.SeciInterface.Blocks.RemoveByVI(toRemove[i]);
74 
75  //Then remove the VI
76  Seci.SeciInterface.LVPanelProperties.Remove(Seci.SeciInterface.LVPanelProperties[j]);
77  Seci.SeciInterface.LV_RemoveVI(toRemove[i]);
78 
79  SECI_GUI.CurrentLayout.RemoveVIFromAllGroups(toRemove[i]);
80 
81  break;
82  }
83  }
84  }
85  }
86 
87  DialogResult = DialogResult.OK;
88  Close();
89  }
90  }
91 }
void btnOK_Click(object sender, EventArgs e)
Definition: RemoveVI.cs:49
void btnRemove_Click(object sender, EventArgs e)
Definition: RemoveVI.cs:31
void RemoveVI_Load(object sender, EventArgs e)
Definition: RemoveVI.cs:21
void btnUndo_Click(object sender, EventArgs e)
Definition: RemoveVI.cs:40