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.Navigation;
13 using System.Windows.Shapes;
15 namespace SeciControls
22 private Dictionary<String, ViHostWrapper>
_hostLookup =
new Dictionary<String, ViHostWrapper>();
29 InitializeComponent();
43 TabItem newTab =
new TabItem();
44 newTab.Header = tabname;
45 newTab.Content = newHost;
47 ScrollingTabControl.Items.Add(newTab);
49 _hostLookup.Add(tabname, newHost);
56 public Boolean
AddTab(String tabname)
64 TabItem newTab =
new TabItem();
66 newTab.Header = tabname;
67 newTab.Content = newHost;
75 ScrollingTabControl.Items.Insert(index, newTab);
79 throw new Exception(
"Cannot get index of ScrollingTabControl");
84 ScrollingTabControl.Items.Add(newTab);
87 _hostLookup.Add(tabname, newHost);
94 TabItem temp =
GetTab(tabname);
98 _hostLookup.Remove(tabname);
99 ScrollingTabControl.Items.Remove(temp);
107 throw new Exception(
"Name already used");
110 TabItem temp =
GetTab(current);
111 temp.Header = newname;
114 _hostLookup.Remove(current);
115 _hostLookup.Add(newname, tokeep);
120 return _hostLookup.ContainsKey(tabname);
125 foreach (Object tab
in ScrollingTabControl.Items)
127 TabItem temp = (TabItem)tab;
128 if (temp.Header.ToString() == tabname)
138 for (
int i = 0; i < ScrollingTabControl.Items.Count; ++i)
140 TabItem temp = (TabItem)ScrollingTabControl.Items[i];
141 if (temp.Header.ToString() == tabname)
154 if (item1 != -1 && item2 != -1)
156 TabItem temp = (TabItem)ScrollingTabControl.Items[item1];
157 ScrollingTabControl.Items.RemoveAt(item1);
158 ScrollingTabControl.Items.Insert(item2, temp);
164 List<String> names =
new List<string>();
166 for (
int i = 0; i < ScrollingTabControl.Items.Count; ++i)
168 TabItem temp = (TabItem)ScrollingTabControl.Items[i];
170 if (includeEmpty ||
_hostLookup[temp.Header.ToString()].GetViNames().Count > 0)
172 names.Add(temp.Header.ToString());
186 foreach (String vi
in GetTabVis(tabname))
188 if (vi.ToLower() == viname.ToLower())
199 List<String> keys = _hostLookup.Keys.ToList<String>();
201 for (
int i = keys.Count - 1; i >= 0; --i)
210 List<String> keys = _hostLookup.Keys.ToList<String>();
212 foreach (String key
in keys)
220 if (ScrollingTabControl.Items != null && !
string.IsNullOrEmpty(tabname))
222 foreach (TabItem tab
in ScrollingTabControl.Items)
224 if (tab.Header.ToString() == tabname)
226 tab.Visibility = Visibility.Collapsed;
235 if (ScrollingTabControl.Items != null && !
string.IsNullOrEmpty(tabname))
237 foreach (TabItem tab
in ScrollingTabControl.Items)
239 if (tab.Header.ToString() == tabname)
241 tab.Visibility = Visibility.Visible;
250 if (ScrollingTabControl.Items != null && !
string.IsNullOrEmpty(tabname))
252 foreach (TabItem tab
in ScrollingTabControl.Items)
254 if (tab.Header.ToString() == tabname)
256 ScrollingTabControl.SelectedItem = tab;
265 ScrollingTabControl.SelectedIndex = index;
270 if (ScrollingTabControl.Items != null)
272 for (
int i = 0; i < ScrollingTabControl.Items.Count; ++i)
274 TabItem tab = ScrollingTabControl.Items[i] as TabItem;
276 if (tab != null && tab.Visibility == Visibility.Visible)
287 public void SetTabOrder(Seci.SerialisableList<Seci.Definitions.Tab> list)
293 for (
int i = 0; i < list.Count; ++i)
298 TabItem temp = (TabItem)ScrollingTabControl.Items[index];
299 ScrollingTabControl.Items.RemoveAt(index);
300 ScrollingTabControl.Items.Insert(i, temp);
315 TabControl cntrl = sender as TabControl;
318 if (cntrl.SelectedIndex != -1)
320 tabname = cntrl.Items[cntrl.SelectedIndex].ToString();
321 tabname = tabname.Substring(0, tabname.IndexOf(
" Content")).Substring(tabname.IndexOf(
"Header:") + 7);
325 if (
_prevTab !=
"" && tabname !=
"")
335 List<String> keys = _hostLookup.Keys.ToList<String>();
337 foreach (String k
in keys)
347 public void AddVi(String tabname, String filename)
352 public void AddVi(String tabname, String filename,
int x,
int y)
357 public void RemoveVi(String tabname, String filename)
364 foreach (String tabname
in _hostLookup.Keys.ToList<String>())
366 if (
_hostLookup[tabname].GetViNames().Contains(filename))
375 List<String> names =
new List<string>();
376 List<String> keys = _hostLookup.Keys.ToList<String>();
378 foreach (String key
in keys)
Boolean AddDummyTab(String tabname)
Dictionary< String, ViHostWrapper > _hostLookup
void HideTab(string tabname)
void SwapTabs(String tab1, String tab2)
void StartTimers(int interval)
void RemoveVi(String filename)
void ScrollingTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
int GetTabIndex(String tabname)
Interaction logic for ViHostWrapper.xaml
void AddVi(String tabname, String filename)
void SetTabOrder(Seci.SerialisableList< Seci.Definitions.Tab > list)
Boolean DoesTabContainsVi(String tabname, String viname)
List< String > GetTabVis(String tabname)
void SelectTab(int index)
List< String > GetTabNames(Boolean includeEmpty)
Boolean AddTab(String tabname)
void RenameTab(String current, String newname)
Boolean TabNameValid(string tabname)
TabItem GetTab(String tabname)
void UnhideTab(string tabname)
void RemoveVi(String tabname, String filename)
void SelectTab(string tabname)
Interaction logic for ViTabControl.xaml
void RemoveTab(String tabname)
void AddVi(String tabname, String filename, int x, int y)
List< String > GetAllVisInTabs()