2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Windows.Forms;
10 namespace SeciUserInterface.Dialogs.Tabs
18 private bool _changesMade =
false;
20 public EditTabs(ref SeciControls.ViTabControl tab, List<String> nonEditTabs, List<String> secretTabs, Seci.SerialisableList<Seci.Definitions.Tab> tabs)
22 InitializeComponent();
24 _secretTabs = secretTabs;
25 _nonEditTabs = nonEditTabs;
36 lstTabs.Items.Clear();
39 List<String> names = _tabControl.GetTabNames(
true);
42 foreach (String tab
in _secretTabs)
48 foreach (Seci.Definitions.Tab tab in _tabs)
50 if (!tab.VisibleForUser)
52 if (names.Contains(tab.Name))
54 names.Remove(tab.Name);
59 lstTabs.Items.AddRange(names.ToArray());
66 if (add.ShowDialog() == DialogResult.OK)
68 _tabControl.AddTab(add.TabName);
71 _tabControl.StartTimers(Seci.Definitions.Status.ViHostRefreshRate);
79 if (lstTabs.SelectedIndex != -1)
81 if (_nonEditTabs.Contains(lstTabs.SelectedItem.ToString()))
83 MessageBox.Show(
"This tab cannot be deleted.");
87 if (lstVIs.Items.Count > 0)
89 if (!canTabBeEdited(lstTabs.SelectedItem.ToString()))
94 for (
int i = lstVIs.Items.Count - 1; i >= 0; --i)
96 removeVi(lstTabs.SelectedItem.ToString(), lstVIs.Items[i].ToString());
100 _tabControl.RemoveTab(lstTabs.SelectedItem.ToString());
101 for(
int i =0; i < _tabs.Count; ++i)
103 if (_tabs[i].Name == lstTabs.SelectedItem.ToString())
120 List<String> vis = _tabControl.GetTabVis(tab);
122 foreach (Seci.LabView.LabViewPanelInfo panel in panels)
124 if (vis.Contains(panel.FilePath) && !String.IsNullOrEmpty(panel.OwningComponent))
126 MessageBox.Show(
"This tab cannot be modified.",
"Tab cannot be modified!", MessageBoxButtons.OK, MessageBoxIcon.Error);
135 if (lstTabs.SelectedIndex != -1)
137 if (_nonEditTabs.Contains(lstTabs.SelectedItem.ToString()))
139 MessageBox.Show(
"This tab cannot be renamed.");
143 if (!canTabBeEdited(lstTabs.SelectedItem.ToString()))
149 String oldName = lstTabs.SelectedItem.ToString();
150 edit.TabName = oldName;
152 if (edit.ShowDialog() == DialogResult.OK)
156 _tabControl.RenameTab(oldName, edit.TabName);
157 for (
int i = 0; i < _tabs.Count; ++i)
159 if (_tabs[i].Name == oldName)
161 _tabs[i].Name = edit.TabName;
168 MessageBox.Show(
"Name already in use; please, try another",
"Duplicate Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
174 for (
int i = 0; i < panels.Count; ++i)
176 if (panels[i].Group != null && panels[i].Group == oldName)
178 panels[i].Group = edit.TabName;
190 DialogResult = DialogResult.OK;
191 Seci.Managers.ConfigurationMgr.SetTabs(_tabs);
195 DialogResult = DialogResult.Cancel;
208 lstVIs.Items.Clear();
210 if (lstTabs.SelectedIndex != -1)
212 List<String> names = _tabControl.GetTabVis(lstTabs.SelectedItem.ToString());
216 lstVIs.Items.AddRange(names.ToArray());
223 if (lstTabs.SelectedIndex != -1)
225 if (_nonEditTabs.Contains(lstTabs.SelectedItem.ToString()))
227 MessageBox.Show(
"This tab cannot be altered.");
230 else if (!canTabBeEdited(lstTabs.SelectedItem.ToString()))
237 List<String> available =
new List<String>();
238 List<String> visInTabs = _tabControl.GetAllVisInTabs();
240 for (
int i=0; i< vis.Count; ++i)
242 if (!vis[i].ShowPanel || visInTabs.Contains(vis[i].FilePath) || !String.IsNullOrEmpty(vis[i].OwningComponent))
248 available.Add(vis[i].FilePath);
253 add.AvailableVis = available;
255 if (add.ShowDialog() == DialogResult.OK)
257 foreach (String viToAdd
in add.
VisToAdd)
259 _tabControl.AddVi(lstTabs.SelectedItem.ToString(), viToAdd);
263 for (
int i = 0; i < panels.Count; ++i)
265 if (panels[i].FilePath.ToLower() == viToAdd.ToLower())
267 panels[i].Group = lstTabs.SelectedItem.ToString();
281 if (lstTabs.SelectedIndex != -1 && lstVIs.SelectedIndex != -1)
283 if (_nonEditTabs.Contains(lstTabs.SelectedItem.ToString()))
285 MessageBox.Show(
"This tab cannot be altered.");
288 else if (!canTabBeEdited(lstTabs.SelectedItem.ToString()))
293 removeVi(lstTabs.SelectedItem.ToString(), lstVIs.SelectedItem.ToString());
300 private void removeVi(String tabname, String viname)
302 _tabControl.RemoveVi(tabname,viname);
306 for (
int i = 0; i < panels.Count; ++i)
308 if (panels[i].FilePath.ToLower() == viname.ToLower())
310 panels[i].Group =
"";
318 if (lstTabs.SelectedIndex > 0)
320 int oldIndex = lstTabs.SelectedIndex;
321 _tabControl.SwapTabs(lstTabs.SelectedItem.ToString(), lstTabs.Items[lstTabs.SelectedIndex - 1].ToString());
324 Seci.Managers.ConfigurationMgr.SwapTabs(lstTabs.SelectedItem.ToString(), lstTabs.Items[lstTabs.SelectedIndex - 1].ToString());
327 lstTabs.SelectedIndex = --oldIndex;
334 if (lstTabs.SelectedIndex < lstTabs.Items.Count -1)
336 int oldIndex = lstTabs.SelectedIndex;
337 _tabControl.SwapTabs(lstTabs.SelectedItem.ToString(), lstTabs.Items[lstTabs.SelectedIndex + 1].ToString());
340 Seci.Managers.ConfigurationMgr.SwapTabs(lstTabs.SelectedItem.ToString(), lstTabs.Items[lstTabs.SelectedIndex + 1].ToString());
343 lstTabs.SelectedIndex = ++oldIndex;
void btnRename_Click(object sender, EventArgs e)
void btnAdd_Click(object sender, EventArgs e)
List< String > _nonEditTabs
void removeVi(String tabname, String viname)
void btnDelete_Click(object sender, EventArgs e)
void EditTabs_Load(object sender, EventArgs e)
List< String > _secretTabs
EditTabs(ref SeciControls.ViTabControl tab, List< String > nonEditTabs, List< String > secretTabs, Seci.SerialisableList< Seci.Definitions.Tab > tabs)
void btnAddVi_Click(object sender, EventArgs e)
void btnRemoveVi_Click(object sender, EventArgs e)
SeciControls.ViTabControl _tabControl
void lstTabs_SelectedIndexChanged(object sender, EventArgs e)
Seci.SerialisableList< Seci.Definitions.Tab > _tabs
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
void btnExit_Click(object sender, EventArgs e)
Interaction logic for ViTabControl.xaml
void btnDown_Click(object sender, EventArgs e)
Boolean canTabBeEdited(String tab)
void btnUp_Click(object sender, EventArgs e)