SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
ComponentOrder.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 ComponentOrder : Form
12  {
13  public ComponentOrder()
14  {
15  InitializeComponent();
16  }
17 
18  private void ComponentOrder_Load(object sender, EventArgs e)
19  {
20  List<String> comps = Seci.SeciInterface.Components_GetNames();
21  lstComponents.Items.AddRange(comps.ToArray());
22  }
23 
24  private void btnUp_Click(object sender, EventArgs e)
25  {
26  if (lstComponents.SelectedIndex > 0)
27  {
28  int index = lstComponents.SelectedIndex;
29 
30  lstComponents.Items.Insert(lstComponents.SelectedIndex - 1, lstComponents.SelectedItem);
31  lstComponents.Items.RemoveAt(lstComponents.SelectedIndex);
32 
33  lstComponents.SelectedIndex = index - 1;
34  }
35  }
36 
37  private void btnDown_Click(object sender, EventArgs e)
38  {
39  if ((lstComponents.SelectedIndex != -1) && (lstComponents.SelectedIndex < lstComponents.Items.Count - 1))
40  {
41  int index = lstComponents.SelectedIndex;
42  lstComponents.Items.Insert(lstComponents.SelectedIndex + 2, lstComponents.SelectedItem);
43  lstComponents.Items.RemoveAt(lstComponents.SelectedIndex);
44 
45  lstComponents.SelectedIndex = index + 1;
46  }
47  }
48 
49  private void btnOK_Click(object sender, EventArgs e)
50  {
51  List<String> newOrder = new List<String>();
52 
53  for (int i = 0; i < lstComponents.Items.Count; ++i)
54  {
55  newOrder.Add(lstComponents.Items[i].ToString());
56  }
57 
58  Seci.SeciInterface.Components_Reorder(newOrder);
59  DialogResult = DialogResult.OK;
60 
61  Close();
62  }
63 
64  }
65 }