2 using System.Collections.Generic;
6 using System.Windows.Controls;
7 using System.Windows.Data;
8 using System.Windows.Documents;
9 using System.Windows.Input;
10 using System.Windows.Media;
11 using System.Windows.Media.Imaging;
12 using System.Windows.Shapes;
14 namespace SeciUserInterface.Dialogs.SubConfigs
21 String _beamlogger =
"Beam-Logger";
25 public EditTabs(Seci.Definitions.Configuration config)
27 InitializeComponent();
38 treeTabs.Items.Clear();
42 for (
int i = 0; i < _tabs.Count; ++i)
44 TreeViewItem item =
new TreeViewItem();
45 item.Header = _tabs[i].Name;
46 treeTabs.Items.Add(item);
49 var vis = _conf.LVPanels;
51 for (
int i = 0; i < vis.Count; ++i)
53 foreach (TreeViewItem t
in treeTabs.Items)
55 if (vis[i].Group != null)
57 if (vis[i].Group.ToLower() == t.Header.ToString().ToLower())
59 TreeViewItem item =
new TreeViewItem();
60 item.Header = vis[i].FilePath;
70 TreeViewItem item = treeTabs.Items[index1] as TreeViewItem;
74 treeTabs.Items.RemoveAt(index1);
75 treeTabs.Items.Insert(index1 - 1, item);
76 item.IsSelected =
true;
80 treeTabs.Items.RemoveAt(index1);
81 treeTabs.Items.Insert(index1 + 1, item);
82 item.IsSelected =
true;
95 var temp = _tabs[index2];
96 _tabs.RemoveAt(index2);
97 _tabs.Insert(index1, temp);
102 if (treeTabs.SelectedItem != null)
104 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
106 for (
int i = 0; i < _tabs.Count; ++i)
108 if (item.Header.ToString().ToLower() == _tabs[i].Name.ToLower())
124 if (treeTabs.SelectedItem != null)
126 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
128 for (
int i = 0; i < _tabs.Count; ++i)
130 if (item.Header.ToString().ToLower() == _tabs[i].Name.ToLower())
132 if (i < _tabs.Count - 1)
148 if (add.ShowDialog() == System.Windows.Forms.DialogResult.OK)
157 if (treeTabs.SelectedItem != null)
159 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
161 if (item.Header.ToString().ToLower() == _beamlogger.ToLower())
163 MessageBox.Show(
"This tab cannot be deleted as it is a default tab",
"Cannot Delete - SECI", MessageBoxButton.OK, MessageBoxImage.Error);
168 for (
int i = 0; i < _tabs.Count; ++i)
170 if (item.Header.ToString().ToLower() == _tabs[i].Name.ToLower())
172 if (item.Items.Count > 0)
174 var vis = _conf.LVPanels;
175 for (
int j = 0; j < vis.Count; ++j)
177 if (vis[j].Group != null && vis[j].Group.ToLower() == _tabs[i].Name.ToLower())
184 treeTabs.Items.Remove(treeTabs.SelectedItem);
196 if (treeTabs.SelectedItem != null)
198 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
200 if (item.Header.ToString().ToLower() == _beamlogger.ToLower())
202 MessageBox.Show(
"This tab cannot be renamed as it is a default tab",
"Cannot Delete - SECI", MessageBoxButton.OK, MessageBoxImage.Error);
207 String oldName = item.Header.ToString();
208 edit.TabName = oldName;
210 if (edit.ShowDialog() == System.Windows.Forms.DialogResult.OK)
213 for (
int i = 0; i < _tabs.Count; ++i)
215 if (item.Header.ToString().ToLower() == _tabs[i].Name.ToLower())
217 _tabs[i].Name = edit.TabName;
222 var vis = _conf.LVPanels;
223 for (
int j = 0; j < vis.Count; ++j)
225 if (vis[j].Group != null && vis[j].Group == oldName)
227 vis[j].Group = edit.TabName;
238 if (treeTabs.SelectedItem != null)
240 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
242 if (item.Header.ToString().ToLower() == _beamlogger.ToLower())
244 MessageBox.Show(
"This tab cannot be modified as it is a default tab",
"Cannot Delete - SECI", MessageBoxButton.OK, MessageBoxImage.Error);
248 var vis = _conf.LVPanels;
249 List<String> available =
new List<String>();
250 for (
int i = 0; i < vis.Count; ++i)
252 if (vis[i].Group == null)
254 available.Add(vis[i].FilePath);
259 add.AvailableVis = available;
261 if (add.ShowDialog() == System.Windows.Forms.DialogResult.OK)
263 foreach (String viToAdd
in add.VisToAdd)
265 vis = _conf.LVPanels;
267 for (
int i = 0; i < vis.Count; ++i)
269 if (vis[i].FilePath.ToLower() == viToAdd.ToLower())
271 vis[i].Group = item.Header.ToString();
283 if (treeTabs.SelectedItem != null)
285 TreeViewItem item = treeTabs.SelectedItem as TreeViewItem;
287 var vis = _conf.LVPanels;
288 for (
int i = 0; i < vis.Count; ++i)
290 if (item.Header.ToString().ToLower() == vis[i].FilePath.ToLower())
Interaction logic for EditTabs.xaml
void swapTabs(int index1, int index2)
Seci.SerialisableList< Seci.Definitions.Tab > _tabs
void btnRemoveVi_Click(object sender, RoutedEventArgs e)
void btnOk_Click(object sender, RoutedEventArgs e)
void btnRenameTab_Click(object sender, RoutedEventArgs e)
void btnRemoveTab_Click(object sender, RoutedEventArgs e)
This class contains all the information that defines the configuration at the SECI level and contains...
void swapTree(int index1, bool up)
void btnAddVi_Click(object sender, RoutedEventArgs e)
void btnUp_Click(object sender, RoutedEventArgs e)
Seci.Definitions.Configuration _conf
void Window_Loaded(object sender, RoutedEventArgs e)
void btnDown_Click(object sender, RoutedEventArgs e)
EditTabs(Seci.Definitions.Configuration config)
void btnAddTab_Click(object sender, RoutedEventArgs e)