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 SeciUserInterface.Dialogs.VIs
11 {
12  public partial class SetVIProperties : Form
13  {
14  private Boolean _isSubconfig = false;
15  public Seci.SerialisableList<Seci.LabView.LabViewPanelInfo> Panels { get; private set; }
16 
17  public SetVIProperties(Seci.SerialisableList<Seci.LabView.LabViewPanelInfo> panels, Boolean isSubconfig)
18  {
19  InitializeComponent();
20  Panels = panels;
21  _isSubconfig = isSubconfig;
22  }
23 
24  private void SetVIProperties_Load(object sender, EventArgs e)
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  private void PopulateTable()
37  {
38  for (int i = 0; i < Panels.Count; ++i)
39  {
40  //Strip path off vi name
41  String temp = Panels[i].FilePath;
42 
43  if (String.IsNullOrEmpty(Panels[i].OwningComponent) || _isSubconfig)
44  {
45  dataGridView1.Rows.Add(temp.Substring(temp.LastIndexOf("\\") + 1), Panels[i].StartRunning, Panels[i].ShowPanel, colDelayAfter.Items[Panels[i].DelayAfter], i);
46  }
47  }
48  }
49 
50  private void btnUp_Click(object sender, EventArgs e)
51  {
52  //Swap the labview panel order in the config
53  if (dataGridView1.Rows.Count > 0)
54  {
55  if (dataGridView1.CurrentRow.Index != -1 && dataGridView1.CurrentRow.Index != 0)
56  {
57  int row = dataGridView1.CurrentRow.Index;
58 
59  int vi = (int)dataGridView1.CurrentRow.Cells[4].Value;
60  int viAbove = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index -1].Cells[4].Value;
61 
62  //Record any changes
63  UpdateRowSettings(row, vi);
64  UpdateRowSettings(row - 1, viAbove);
65 
66  //Swap the rows
67  Seci.LabView.LabViewPanelInfo temp = Panels[viAbove];
68  Panels[viAbove] = Panels[vi];
69  Panels[vi] = temp;
70 
71  //Repopulate the table
72  dataGridView1.Rows.Clear();
73  PopulateTable();
74 
75  dataGridView1.CurrentCell = dataGridView1.Rows[row - 1].Cells[0];
76  }
77  }
78  }
79 
80  private void btnDown_Click(object sender, EventArgs e)
81  {
82  //Swap the labview panel order in the config
83  if (dataGridView1.Rows.Count > 0)
84  {
85  if (dataGridView1.CurrentRow.Index != -1 && dataGridView1.CurrentRow.Index != dataGridView1.Rows.Count - 1)
86  {
87  int row = dataGridView1.CurrentRow.Index;
88 
89  int vi = (int)dataGridView1.CurrentRow.Cells[4].Value;
90  int viBelow = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index + 1].Cells[4].Value;
91 
92  //Record any changes
93  UpdateRowSettings(row, vi);
94  UpdateRowSettings(row + 1, viBelow);
95 
96  //Swap the rows
97  Seci.LabView.LabViewPanelInfo temp = Panels[viBelow];
98  Panels[viBelow] = Panels[vi];
99  Panels[vi] = temp;
100 
101  //Repopulate the table
102  dataGridView1.Rows.Clear();
103  PopulateTable();
104 
105  dataGridView1.CurrentCell = dataGridView1.Rows[row + 1].Cells[0];
106  }
107  }
108  }
109 
110  private void btnOK_Click(object sender, EventArgs e)
111  {
112  for (int i = 0; i < dataGridView1.Rows.Count; ++i)
113  {
114  int viIndex = (int)dataGridView1.Rows[i].Cells[4].Value;
115  UpdateRowSettings(i, viIndex);
116  }
117 
118  DialogResult = DialogResult.OK;
119  Close();
120 
121  }
122 
123  private void UpdateRowSettings(int row, int vi)
124  {
125  Panels[vi].StartRunning = (Boolean)dataGridView1.Rows[row].Cells[1].Value;
126  if (String.IsNullOrEmpty(Panels[dataGridView1.CurrentCell.RowIndex].Group)) //Sanity check
127  {
128  Panels[vi].ShowPanel = (Boolean)dataGridView1.Rows[row].Cells[2].Value;
129  }
130  else
131  {
132  Panels[vi].ShowPanel = true;
133  }
134  Panels[vi].DelayAfter = Convert.ToInt16(dataGridView1.Rows[row].Cells[3].Value);
135  }
136 
137  private void btnCancel_Click(object sender, EventArgs e)
138  {
139  DialogResult = DialogResult.Cancel;
140  Close();
141  }
142 
143  private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
144  {
145  if (dataGridView1.CurrentCell.ColumnIndex == dataGridView1.Columns["colVisible"].Index)
146  {
147  if (!String.IsNullOrEmpty(Panels[dataGridView1.CurrentCell.RowIndex].Group) && !((bool)dataGridView1.CurrentCell.EditedFormattedValue))
148  {
149  MessageBox.Show("This VI is currently in a tab and cannot be hidden", "Invalid Action", MessageBoxButtons.OK, MessageBoxIcon.Information);
150  e.Cancel = true;
151  dataGridView1.CurrentCell.Value = true;
152  }
153  }
154  }
155  }
156 }
void btnDown_Click(object sender, EventArgs e)
void btnOK_Click(object sender, EventArgs e)
void btnUp_Click(object sender, EventArgs e)
SetVIProperties(Seci.SerialisableList< Seci.LabView.LabViewPanelInfo > panels, Boolean isSubconfig)
void btnCancel_Click(object sender, EventArgs e)
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
void SetVIProperties_Load(object sender, EventArgs e)
void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)