SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
GroupProgs.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.Layout.Groups
11 {
12  public partial class GroupProgs : Form
13  {
14 
15  private List<Group> localGroups = new List<Group>();
16  private Boolean _changesMade = false;
17 
18  public GroupProgs()
19  {
20  InitializeComponent();
21  }
22 
23  private void GroupVIs_Load(object sender, EventArgs e)
24  {
25  if (SECI_GUI.CurrentLayout.Groups != null)
26  {
27  Group[] temp = (Group[])SECI_GUI.CurrentLayout.Groups.Clone();
28 
29  for (int i = 0; i < temp.GetLength(0); ++i)
30  {
31  localGroups.Add(temp[i]);
32  }
33 
34  PopulateList();
35  }
36  }
37 
38  private void lstGroups_SelectedIndexChanged(object sender, EventArgs e)
39  {
40  lstMembers.Items.Clear();
41 
42  if (lstGroups.SelectedIndex != -1)
43  {
44  lstMembers.Items.AddRange(localGroups[lstGroups.SelectedIndex].VIMembers);
45  lstMembers.Items.AddRange(localGroups[lstGroups.SelectedIndex].ProgMembers);
46  }
47  }
48 
49  private void PopulateList()
50  {
51  lstGroups.Items.Clear();
52  lstMembers.Items.Clear();
53 
54  //Get a list of all groups
55  if (localGroups != null)
56  {
57  for (int i = 0; i < localGroups.Count; ++i)
58  {
59  lstGroups.Items.Add(localGroups[i].GroupName);
60  }
61  }
62  }
63 
64  private void btnAddGroup_Click(object sender, EventArgs e)
65  {
66  AddEditGroup addgrp = new AddEditGroup();
67 
68  if (addgrp.ShowDialog() == DialogResult.OK)
69  {
70  localGroups.Add(addgrp.myGroup);
71  PopulateList();
72  _changesMade = true;
73  }
74 
75  }
76 
77  private void btnEditGroup_Click(object sender, EventArgs e)
78  {
79  if (lstGroups.SelectedIndex != -1)
80  {
81 
82  int index = lstGroups.SelectedIndex;
83 
84  AddEditGroup editgrp = new AddEditGroup(localGroups[index]);
85 
86  if (editgrp.ShowDialog() == DialogResult.OK)
87  {
88  localGroups.RemoveAt(index);
89  localGroups.Insert(index, editgrp.myGroup);
90  PopulateList();
91  _changesMade = true;
92  }
93  }
94  }
95 
96  private void btnDelete_Click(object sender, EventArgs e)
97  {
98  if (lstGroups.SelectedIndex != -1)
99  {
100  localGroups.RemoveAt(lstGroups.SelectedIndex);
101  PopulateList();
102  _changesMade = true;
103  }
104  }
105 
106  private void btnOK_Click(object sender, EventArgs e)
107  {
108  SECI_GUI.CurrentLayout.OverWriteGroups(localGroups);
109 
110  if (_changesMade)
111  {
112  DialogResult = DialogResult.OK;
113  }
114  else
115  {
116  DialogResult = DialogResult.Cancel;
117  }
118 
119  Close();
120  }
121 
122  }
123 }