SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
NavBar.xaml.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows;
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;
14 
15 namespace SeciControls
16 {
20  public partial class NavBar : UserControl
21  {
23  private Boolean _daeVisibleForUser = true;
24  private Boolean _visVisibleForUser = true;
25  private Boolean _userCanEditVISettings = true;
26  private Boolean _twoGeniesAvailable = false;
27  private Boolean _graphsAvailable = false;
28  private Boolean _journelViewerVisible = false;
29  private Boolean _settingsVisible = false;
30  private Boolean _lostTimeVisible = true;
31 
32  public Boolean DaeVisibleForUser { get { return _daeVisibleForUser; } set { _daeVisibleForUser = value; } }
33  public Boolean VisVisibleForUser { get { return _visVisibleForUser; } set { _visVisibleForUser = value; } }
34  public Boolean UserCanEditVISettings { get { return _userCanEditVISettings; } set { _userCanEditVISettings = value; } }
35  public Boolean TwoGeniesAvailable { get { return _twoGeniesAvailable; } set { _twoGeniesAvailable = value; } }
36  public Boolean GraphsAvailable { get { return _graphsAvailable; } set { _graphsAvailable = value; } }
37  public Boolean JournelViewerVisible { get { return _journelViewerVisible; } set { _journelViewerVisible = value; } }
38  public Boolean SettingsVisible { get { return _settingsVisible; } set { _settingsVisible = value; } }
39  public Boolean LostTimeVisible { get { return _lostTimeVisible; } set { _lostTimeVisible = value; } }
40 
41  //User Details tab events
42  public event EventHandler OnExperimentDetailsClicked;
43 
44  //Labview tab events - for forwarding the events on that control
45  public event EventHandler OnVIsClicked;
46  public event EventHandler OnAddVIClicked;
47  public event EventHandler OnRemoveVIClicked;
48  public event EventHandler OnConfigureVIClicked;
49  public event EventHandler OnEditTabsClicked;
50  public event EventHandler OnConfigureBlocksClicked;
51  public event EventHandler OnDisplayBlocksClicked;
52 
53  //Open Genie tab events
54  public event EventHandler OnOpenGenieClicked;
55 
56  //Graph tab events
57  public event EventHandler OnGraphsClicked;
58 
59  //Dae tab events
60  public event EventHandler OnDaeClicked;
61 
62  //Settings tab events
63  public event EventHandler OnSettingsClicked;
64 
65  //Advanced tab events
66  public event EventHandler OnAdvancedClicked;
67 
68  //Journal viewer events
69  public event EventHandler OnJournalViewerClicked;
70 
71  //System Messages tab events
72  public event EventHandler OnSystemMessagesClicked;
73 
74  //Beam Status events
75  public event EventHandler OnBeamStatusClicked;
76 
77  //Isis Messages tab events
78  public event EventHandler OnIsisMessagesClicked;
79 
80  //Report a problem tab events
81  public event EventHandler OnReportProblemClicked;
82 
83  //Lost time and maintenance events
84  public event EventHandler OnLostTimeClicked;
85 
86  //Help tab events
87  public event EventHandler OnHelpClicked;
88 
89  public NavBar()
90  {
91  InitializeComponent();
92 
93  btnLabview.OnVIsClicked += new EventHandler(btnLabview_OnVIsClicked);
94  btnLabview.OnAddVIClicked += new EventHandler(btnLabview_OnAddVIClicked);
95  btnLabview.OnConfigureBlocksClicked += new EventHandler(btnLabview_OnConfigureBlocksClicked);
96  btnLabview.OnConfigureVIClicked += new EventHandler(btnLabview_OnConfigureVIClicked);
97  btnLabview.OnDisplayBlocksClicked += new EventHandler(btnLabview_OnDisplayBlocksClicked);
98  btnLabview.OnEditTabsClicked += new EventHandler(btnLabview_OnEditTabsClicked);
99  btnLabview.OnRemoveVIClicked += new EventHandler(btnLabview_OnRemoveVIClicked);
100 
101  }
102 
103  #region IsBigFontsProperty Dependency Property
104 
105  public static readonly DependencyProperty IsBigFontsProperty = DependencyProperty.RegisterAttached("IsBigFonts", typeof(Boolean),
106  typeof(NavBar), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits));
107 
108  public static void SetIsBigFonts(UIElement element, Boolean value)
109  {
110  element.SetValue(IsBigFontsProperty, value);
111  }
112 
113  public static Boolean GetIsBigFonts(UIElement element)
114  {
115  return (Boolean)element.GetValue(IsBigFontsProperty);
116  }
117 
118  #endregion
119 
120  #region User Details
121 
122  private void btnUserDetails_Click(object sender, RoutedEventArgs e)
123  {
124  setIndicator(sender);
125 
126  if (OnExperimentDetailsClicked != null)
127  {
128  OnExperimentDetailsClicked(sender, e);
129  }
130  }
131 
132  #endregion
133 
134  #region LabVIEW Tab
135 
136  void btnLabview_OnVIsClicked(object sender, EventArgs e)
137  {
138  setIndicator(sender);
139 
140  if (OnVIsClicked != null)
141  {
142  OnVIsClicked(sender, e);
143  }
144  }
145 
146  private void btnLabview_OnAddVIClicked(object sender, EventArgs e)
147  {
148  if (OnAddVIClicked != null)
149  {
150  OnAddVIClicked(sender, e);
151  }
152  }
153 
154  private void btnLabview_OnRemoveVIClicked(object sender, EventArgs e)
155  {
156  if (OnRemoveVIClicked != null)
157  {
158  OnRemoveVIClicked(sender, e);
159  }
160  }
161 
162  private void btnLabview_OnConfigureVIClicked(object sender, EventArgs e)
163  {
164  if (OnConfigureVIClicked != null)
165  {
166  OnConfigureVIClicked(sender, e);
167  }
168  }
169 
170  private void btnLabview_OnEditTabsClicked(object sender, EventArgs e)
171  {
172  if (OnEditTabsClicked != null)
173  {
174  OnEditTabsClicked(sender, e);
175  }
176  }
177 
178  private void btnLabview_OnConfigureBlocksClicked(object sender, EventArgs e)
179  {
180  if (OnConfigureBlocksClicked != null)
181  {
182  OnConfigureBlocksClicked(sender, e);
183  }
184  }
185 
186  private void btnLabview_OnDisplayBlocksClicked(object sender, EventArgs e)
187  {
188  if (OnDisplayBlocksClicked != null)
189  {
190  OnDisplayBlocksClicked(sender, e);
191  }
192  }
193 
194  #endregion
195 
196  #region Open Genie Tab
197 
198  private void btnOpenGenie_Click(object sender, RoutedEventArgs e)
199  {
200  setIndicator(sender);
201 
202  if (OnOpenGenieClicked != null)
203  {
204  OnOpenGenieClicked(sender, e);
205  }
206  }
207 
208  #endregion
209 
210  #region Dae Tab
211 
212  private void btnDae_Click(object sender, RoutedEventArgs e)
213  {
214  setIndicator(sender);
215 
216  if (OnDaeClicked != null)
217  {
218  OnDaeClicked(sender, e);
219  }
220  }
221 
222  #endregion
223 
224  #region Graph Tab
225 
226  private void btnGraph_Click(object sender, RoutedEventArgs e)
227  {
228  setIndicator(sender);
229 
230  if (OnGraphsClicked != null)
231  {
232  OnGraphsClicked(sender, e);
233  }
234  }
235 
236  #endregion
237 
238  #region Settings Tab
239 
240  private void btnSettings_Click(object sender, RoutedEventArgs e)
241  {
242  setIndicator(sender);
243 
244  if (OnSettingsClicked != null)
245  {
246  OnSettingsClicked(sender, e);
247  }
248  }
249 
250  #endregion
251 
252  #region Advanced Tab
253 
254  private void btnAdvanced_Click(object sender, RoutedEventArgs e)
255  {
256  setIndicator(sender);
257 
258  if (OnAdvancedClicked != null)
259  {
260  OnAdvancedClicked(sender, e);
261  }
262  }
263 
264  #endregion
265 
266  #region Journal Viewer Tab
267 
268  private void btnJournal_Click(object sender, RoutedEventArgs e)
269  {
270  setIndicator(sender);
271 
272  if (OnJournalViewerClicked != null)
273  {
274  OnJournalViewerClicked(sender, e);
275  }
276  }
277 
278  #endregion
279 
280  #region System Messages Tab
281 
282  private void btnSystem_Click(object sender, RoutedEventArgs e)
283  {
284  setIndicator(sender);
285 
286  if (OnSystemMessagesClicked != null)
287  {
288  OnSystemMessagesClicked(sender, e);
289  }
290  }
291 
292  #endregion
293 
294  #region Beam Status Tab
295 
296  private void btnBeam_Click(object sender, RoutedEventArgs e)
297  {
298  setIndicator(sender);
299 
300  if (OnBeamStatusClicked != null)
301  {
302  OnBeamStatusClicked(sender, e);
303  }
304  }
305 
306  #endregion
307 
308  #region ISIS Messages Tab
309 
310  private void btnISIS_Click(object sender, RoutedEventArgs e)
311  {
312  setIndicator(sender);
313 
314  if (OnIsisMessagesClicked != null)
315  {
316  OnIsisMessagesClicked(sender, e);
317  }
318  }
319 
320  #endregion
321 
322  #region Lost Time & Maintenace Tab
323 
324  private void btnLostTime_Click(object sender, RoutedEventArgs e)
325  {
326  setIndicator(sender);
327 
328  if (OnLostTimeClicked != null)
329  {
330  OnLostTimeClicked(sender, e);
331  }
332  }
333 
334  #endregion
335 
336  #region Report Tab
337 
338  private void btnReport_Click(object sender, RoutedEventArgs e)
339  {
340  setIndicator(sender);
341 
342  if (OnReportProblemClicked != null)
343  {
344  OnReportProblemClicked(sender, e);
345  }
346  }
347 
348  #endregion
349 
350  #region Help Tab
351 
352  private void btnHelp_Click(object sender, RoutedEventArgs e)
353  {
354  setIndicator(sender);
355 
356  if (OnHelpClicked != null)
357  {
358  OnHelpClicked(sender, e);
359  }
360  }
361 
362  #endregion
363 
364  private void setIndicator(object sender)
365  {
366  if (_lastSelected != null)
367  {
368  _lastSelected.IsSelected = false;
369  }
370 
371  NavBarButton btnSender = sender as NavBarButton;
372  btnSender.IsSelected = true;
373 
374  _lastSelected = btnSender;
375  }
376 
377  public void SetTabsVisibility(Boolean manager)
378  {
379  if (manager)
380  {
381  btnAdvanced.Visibility = Visibility.Visible;
382  }
383  else
384  {
385  btnAdvanced.Visibility = Visibility.Collapsed;
386  }
387 
388  if (_daeVisibleForUser || manager)
389  {
390  btnDae.Visibility = Visibility.Visible;
391  }
392  else
393  {
394  btnDae.Visibility = Visibility.Collapsed;
395  }
396 
397  if (_visVisibleForUser || manager)
398  {
399  btnLabview.Visibility = Visibility.Visible;
400  btnLabview.SetExpansionToDefault();
401  }
402  else
403  {
404  btnLabview.SetExpansionToDefault();
405  btnLabview.Visibility = Visibility.Collapsed;
406  }
407 
408  btnLabview.SetLinkVisability(_userCanEditVISettings || manager);
409 
410  if (_graphsAvailable)
411  {
412  btnGraphs.Visibility = Visibility.Visible;
413  }
414  else
415  {
416  btnGraphs.Visibility = Visibility.Collapsed;
417  }
418 
420  {
421  btnJournal.Visibility = Visibility.Visible;
422  }
423  else
424  {
425  btnJournal.Visibility = Visibility.Collapsed;
426  }
427 
428  if (_settingsVisible)
429  {
430  btnSettings.Visibility = Visibility.Visible;
431  }
432  else
433  {
434  btnSettings.Visibility = Visibility.Collapsed;
435  }
436 
437  if (_lostTimeVisible)
438  {
439  btnLostTime.Visibility = Visibility.Visible;
440  }
441  else
442  {
443  btnLostTime.Visibility = Visibility.Collapsed;
444  }
445  }
446 
447  public void DeselectSelectedItem()
448  {
449  if (_lastSelected != null)
450  {
451  _lastSelected.IsSelected = false;
452  }
453  }
454 
455  public void SetErrorCounter(int numErrors, int numQuestions)
456  {
457  if (numQuestions > 0)
458  {
459  txtLvQuestions.Text = "Number of LabVIEW Questions: " + numQuestions;
460  txtLvQuestions.Visibility = Visibility.Visible;
461  btnSystem.ShowWarning = true;
462  }
463  else
464  {
465  txtLvQuestions.Visibility = Visibility.Collapsed;
466  btnSystem.ShowWarning = false;
467  }
468 
469  if (numErrors > 0)
470  {
471  txtLvErrors.Text = "Number of LabVIEW Errors: " + numErrors;
472  txtLvErrors.Visibility = Visibility.Visible;
473  btnSystem.ShowWarning = false;
474  btnSystem.ShowError = true;
475  }
476  else
477  {
478  txtLvErrors.Visibility = Visibility.Collapsed;
479  btnSystem.ShowError = false;
480  }
481  }
482 
483  public void SetButtonOrderAndNames(List<KeyValuePair<String, String>> order)
484  {
485  //Remove buttons first
486  stkOrderable.Children.Clear();
487 
488  foreach (KeyValuePair<String, String> pair in order)
489  {
490  String realname = pair.Key;
491  String newname = pair.Value;
492 
493  if (realname == "Experiment Details")
494  {
495  if (newname != null)
496  {
497  btnExperimentDetails.Content = newname;
498  }
499  stkOrderable.Children.Add(btnExperimentDetails);
500  }
501  else if (realname == "LabVIEW VIs")
502  {
503  if (newname != null)
504  {
505  btnLabview.SetText(newname);
506  }
507  stkOrderable.Children.Add(btnLabview);
508  }
509  else if (realname == "Open Genie (Scripting)")
510  {
511  if (newname != null)
512  {
513  btnOpenGenie.Content = newname;
514  }
515  stkOrderable.Children.Add(btnOpenGenie);
516  }
517  else if (realname == "Graphs")
518  {
519  if (newname != null)
520  {
521  btnGraphs.Content = newname;
522  }
523  stkOrderable.Children.Add(btnGraphs);
524  }
525  else if (realname == "Settings")
526  {
527  if (newname != null)
528  {
529  btnSettings.Content = newname;
530  }
531  stkOrderable.Children.Add(btnSettings);
532  }
533  else if (realname == "DAE")
534  {
535  if (newname != null)
536  {
537  btnDae.Content = newname;
538  }
539  stkOrderable.Children.Add(btnDae);
540  }
541  }
542  }
543 
544  public List<KeyValuePair<String, String>> GetButtonOrderAndNames()
545  {
546  List<KeyValuePair<String, String>> order = new List<KeyValuePair<String, String>>();
547 
548  foreach (var btn in stkOrderable.Children)
549  {
550  NavBarButton navbtn = btn as NavBarButton;
551  LabViewNavButton labbtn = btn as LabViewNavButton;
552  if (navbtn != null)
553  {
554  order.Add(new KeyValuePair<string, string>(navbtn.DefaultName, navbtn.Content.ToString()));
555  }
556  else if (labbtn != null)
557  {
558  order.Add(new KeyValuePair<string, string>(labbtn.DefaultName, labbtn.Content.ToString()));
559  }
560  }
561 
562  return order;
563  }
564 
565  public void HideScriptingTab()
566  {
567  btnOpenGenie.Visibility = Visibility.Collapsed;
568  }
569 
570 
571  }
572 }
EventHandler OnGraphsClicked
Definition: NavBar.xaml.cs:57
Boolean JournelViewerVisible
Definition: NavBar.xaml.cs:37
void btnSystem_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:282
void btnGraph_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:226
static void SetIsBigFonts(UIElement element, Boolean value)
Definition: NavBar.xaml.cs:108
void btnLabview_OnDisplayBlocksClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:186
void btnLabview_OnConfigureVIClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:162
EventHandler OnDaeClicked
Definition: NavBar.xaml.cs:60
EventHandler OnHelpClicked
Definition: NavBar.xaml.cs:87
EventHandler OnDisplayBlocksClicked
Definition: NavBar.xaml.cs:51
void btnUserDetails_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:122
Boolean LostTimeVisible
Definition: NavBar.xaml.cs:39
EventHandler OnSettingsClicked
Definition: NavBar.xaml.cs:63
void btnISIS_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:310
void btnJournal_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:268
void btnHelp_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:352
void btnLabview_OnConfigureBlocksClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:178
EventHandler OnLostTimeClicked
Definition: NavBar.xaml.cs:84
void btnDae_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:212
Boolean _visVisibleForUser
Definition: NavBar.xaml.cs:24
void SetTabsVisibility(Boolean manager)
Definition: NavBar.xaml.cs:377
EventHandler OnReportProblemClicked
Definition: NavBar.xaml.cs:81
EventHandler OnConfigureBlocksClicked
Definition: NavBar.xaml.cs:50
NavBarButton _lastSelected
Definition: NavBar.xaml.cs:22
EventHandler OnAdvancedClicked
Definition: NavBar.xaml.cs:66
Boolean _userCanEditVISettings
Definition: NavBar.xaml.cs:25
Boolean _twoGeniesAvailable
Definition: NavBar.xaml.cs:26
void setIndicator(object sender)
Definition: NavBar.xaml.cs:364
List< KeyValuePair< String, String > > GetButtonOrderAndNames()
Definition: NavBar.xaml.cs:544
Boolean _daeVisibleForUser
Definition: NavBar.xaml.cs:23
void SetErrorCounter(int numErrors, int numQuestions)
Definition: NavBar.xaml.cs:455
void SetButtonOrderAndNames(List< KeyValuePair< String, String >> order)
Definition: NavBar.xaml.cs:483
void btnOpenGenie_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:198
void btnLabview_OnVIsClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:136
Boolean GraphsAvailable
Definition: NavBar.xaml.cs:36
void btnLabview_OnEditTabsClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:170
EventHandler OnBeamStatusClicked
Definition: NavBar.xaml.cs:75
void btnReport_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:338
Boolean _settingsVisible
Definition: NavBar.xaml.cs:29
Interaction logic for NavBar.xaml
Definition: NavBar.xaml.cs:20
EventHandler OnConfigureVIClicked
Definition: NavBar.xaml.cs:48
EventHandler OnExperimentDetailsClicked
Definition: NavBar.xaml.cs:42
Boolean UserCanEditVISettings
Definition: NavBar.xaml.cs:34
Boolean _graphsAvailable
Definition: NavBar.xaml.cs:27
void DeselectSelectedItem()
Definition: NavBar.xaml.cs:447
void btnBeam_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:296
static Boolean GetIsBigFonts(UIElement element)
Definition: NavBar.xaml.cs:113
void btnSettings_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:240
EventHandler OnVIsClicked
Definition: NavBar.xaml.cs:45
void btnLostTime_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:324
EventHandler OnRemoveVIClicked
Definition: NavBar.xaml.cs:47
Boolean SettingsVisible
Definition: NavBar.xaml.cs:38
EventHandler OnJournalViewerClicked
Definition: NavBar.xaml.cs:69
EventHandler OnIsisMessagesClicked
Definition: NavBar.xaml.cs:78
EventHandler OnOpenGenieClicked
Definition: NavBar.xaml.cs:54
Boolean _journelViewerVisible
Definition: NavBar.xaml.cs:28
EventHandler OnSystemMessagesClicked
Definition: NavBar.xaml.cs:72
void btnLabview_OnAddVIClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:146
EventHandler OnEditTabsClicked
Definition: NavBar.xaml.cs:49
void btnLabview_OnRemoveVIClicked(object sender, EventArgs e)
Definition: NavBar.xaml.cs:154
Boolean VisVisibleForUser
Definition: NavBar.xaml.cs:33
EventHandler OnAddVIClicked
Definition: NavBar.xaml.cs:46
static readonly DependencyProperty IsBigFontsProperty
Definition: NavBar.xaml.cs:105
Interaction logic for LabViewNavButton.xaml
void btnAdvanced_Click(object sender, RoutedEventArgs e)
Definition: NavBar.xaml.cs:254
Boolean TwoGeniesAvailable
Definition: NavBar.xaml.cs:35
Boolean _lostTimeVisible
Definition: NavBar.xaml.cs:30
Boolean DaeVisibleForUser
Definition: NavBar.xaml.cs:32