SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
SetVIProperties.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.VI
11 {
12  public partial class SetVIProperties : Form
13  {
14  private Seci.SerialisableList<Seci.LabView.LabViewPanelInfo> tempPanels;
15 
16  public SetVIProperties()
17  {
18  InitializeComponent();
19  }
20 
21  private void SetVIProperties_Load(object sender, EventArgs e)
22  {
23  //Take a copy of the panels as they currently are
24  tempPanels = (Seci.SerialisableList<Seci.LabView.LabViewPanelInfo>)Seci.SeciInterface.LVPanelProperties.Clone();
25 
26  //load up the information about the panels
27  PopulateTable();
28 
29  //Disable sorting
30  foreach (DataGridViewColumn i in dataGridView1.Columns)
31  {
32  i.SortMode = DataGridViewColumnSortMode.NotSortable;
33  }
34 
35  }
36 
37  private void PopulateTable()
38  {
39  for (int i = 0; i < tempPanels.Count; ++i)
40  {
41  //Strip path off vi name
42  String temp = tempPanels[i].PanelName;
43 
44  dataGridView1.Rows.Add(temp.Substring(temp.LastIndexOf("\\") + 1), tempPanels[i].StartRunning, tempPanels[i].ShowPanel, colDelayAfter.Items[tempPanels[i].DelayAfter]);
45  }
46  }
47 
48  private void btnUp_Click(object sender, EventArgs e)
49  {
50  //Swap the labview panel order in the config
51  if (dataGridView1.Rows.Count > 0)
52  {
53  if (dataGridView1.CurrentRow.Index != -1 && dataGridView1.CurrentRow.Index != 0)
54  {
55  int row = dataGridView1.CurrentRow.Index;
56 
57  //Record any changes
58  UpdateRowSettings(row);
59  UpdateRowSettings(row - 1);
60 
61  //Swap the rows
62  Seci.LabView.LabViewPanelInfo temp = tempPanels[row - 1];
63  tempPanels[row - 1] = tempPanels[row];
64  tempPanels[row] = temp;
65 
66  //Repopulate the table
67  dataGridView1.Rows.Clear();
68  PopulateTable();
69 
70  dataGridView1.CurrentCell = dataGridView1.Rows[row - 1].Cells[0];
71  }
72  }
73  }
74 
75  private void btnDown_Click(object sender, EventArgs e)
76  {
77  //Swap the labview panel order in the config
78  if (dataGridView1.Rows.Count > 0)
79  {
80  if (dataGridView1.CurrentRow.Index != -1 && dataGridView1.CurrentRow.Index != dataGridView1.Rows.Count - 1)
81  {
82  int row = dataGridView1.CurrentRow.Index;
83 
84  //Record any changes
85  UpdateRowSettings(row);
86  UpdateRowSettings(row + 1);
87 
88  //Swap the rows
89  Seci.LabView.LabViewPanelInfo temp = tempPanels[row + 1];
90  tempPanels[row + 1] = tempPanels[row];
91  tempPanels[row] = temp;
92 
93  //Repopulate the table
94  dataGridView1.Rows.Clear();
95  PopulateTable();
96 
97  dataGridView1.CurrentCell = dataGridView1.Rows[row + 1].Cells[0];
98  }
99  }
100  }
101 
102  private void btnOK_Click(object sender, EventArgs e)
103  {
104  for (int i = 0; i < dataGridView1.Rows.Count; ++i)
105  {
106  UpdateRowSettings(i);
107  }
108 
109  //Set visibility
110  for (int i = 0; i < tempPanels.Count; ++i)
111  {
112  //Show panel or not
113  if (tempPanels[i].ShowPanel)
114  {
115  Seci.SeciInterface.LV_ShowVI(tempPanels[i].PanelName);
116  }
117  else
118  {
119  Seci.SeciInterface.LV_HideVI(tempPanels[i].PanelName);
120  }
121  }
122 
123  //Copy back
124  Seci.SeciInterface.LVPanelProperties = tempPanels;
125 
126  DialogResult = DialogResult.OK;
127  Close();
128 
129  }
130 
131  private void UpdateRowSettings(int i)
132  {
133  tempPanels[i].StartRunning = (Boolean)dataGridView1.Rows[i].Cells[1].Value;
134  tempPanels[i].ShowPanel = (Boolean)dataGridView1.Rows[i].Cells[2].Value;
135  tempPanels[i].DelayAfter = Convert.ToInt16(dataGridView1.Rows[i].Cells[3].Value);
136  }
137 
138  private void btnCancel_Click(object sender, EventArgs e)
139  {
140 
141  }
142 
143 
144 
145  }
146 }
Seci.SerialisableList< Seci.LabView.LabViewPanelInfo > tempPanels
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...