SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
RemoveComponent.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.Config
10 {
11  public partial class RemoveComponent : Form
12  {
13 
14  private String[] toRemove;
15 
16  public RemoveComponent()
17  {
18  InitializeComponent();
19  }
20 
21  private void RemoveComponent_Load(object sender, EventArgs e)
22  {
23 
24  List<String> names = Seci.SeciInterface.Components_GetNames();
25  if (names != null)
26  {
27  lstComps.Items.AddRange(names.ToArray());
28  }
29 
30  }
31 
32  private void btnRemove_Click(object sender, EventArgs e)
33  {
34  if (lstComps.SelectedIndex != -1)
35  {
36  lstToRemove.Items.Add(lstComps.SelectedItem);
37  lstComps.Items.RemoveAt(lstComps.SelectedIndex);
38  }
39  }
40 
41  private void btnUndo_Click(object sender, EventArgs e)
42  {
43  if (lstToRemove.SelectedIndex != -1)
44  {
45  lstComps.Items.Add(lstToRemove.SelectedItem);
46  lstToRemove.Items.RemoveAt(lstToRemove.SelectedIndex);
47  }
48 
49  }
50 
51  private void btnOK_Click(object sender, EventArgs e)
52  {
53  if (lstToRemove.Items.Count > 0)
54  {
55  //Copy the names to remove
56  toRemove = new String[lstToRemove.Items.Count];
57 
58  for (int i = 0; i < lstToRemove.Items.Count; ++i)
59  {
60  toRemove[i] = lstToRemove.Items[i].ToString();
61  }
62  }
63 
64  if (toRemove != null)
65  {
66  //Remove the Components
67  for (int i = 0; i < toRemove.GetLength(0); ++i)
68  {
69  Seci.SeciInterface.Components_Remove(toRemove[i]);
70  }
71  }
72 
73  DialogResult = DialogResult.OK;
74  Close();
75  }
76 
77  }
78 }