SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
UserInformation.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 using System.Data;
15 using System.Globalization;
16 using System.Reflection;
17 using System.ComponentModel;
18 using System.Diagnostics;
19 
20 namespace SeciControls
21 {
25  public partial class UserInformation : UserControl
26  {
27  private DataTable _dt;
28  BackgroundWorker _webpageLauncher = new BackgroundWorker();
29 
30  public event EventHandler OnEditUsersClicked;
31 
32  public UserInformation()
33  {
34  InitializeComponent();
35 
36  _webpageLauncher.DoWork += new DoWorkEventHandler(_webpageLauncher_DoWork);
37  }
38 
39  private void UserControl_Loaded(object sender, RoutedEventArgs e)
40  {
41  _dt = new DataTable("UserData");
42  _dt.Columns.Add("Name", typeof(string));
43  _dt.Columns.Add("Institute", typeof(string));
44  }
45 
46  public void Update()
47  {
48  try
49  {
50  _dt.Clear();
51 
52  txtRbNumber.Text = Seci.Standard.UserDetails.GetRbNumber();
53  String[,] users = Seci.Standard.UserDetails.GetUsers();
54 
55  if (users != null)
56  {
57  for (int i = 0; i < users.GetLength(0); ++i)
58  {
59  _dt.Rows.Add(users[i, 0], users[i, 1]);
60  }
61  }
62  dgUsers.ItemsSource = _dt.DefaultView;
63 
64  //Workround to force datagrid to shrink if new data is shorter than previous.
65  for (int i = 0; i < dgUsers.Columns.Count; ++i)
66  {
67  dgUsers.Columns[i].Width = 0;
68  dgUsers.Columns[i].Width = DataGridLength.SizeToCells;
69  }
70  }
71  catch
72  {
73  }
74  }
75 
76  private void btnEditUsers_Click(object sender, RoutedEventArgs e)
77  {
78  if (OnEditUsersClicked != null)
79  {
80  OnEditUsersClicked(sender, e);
81  }
82  }
83 
84  private void btnChangeRB_Click(object sender, RoutedEventArgs e)
85  {
86  try
87  {
88  RBFinder finder = new RBFinder();
89  finder.WindowStartupLocation = WindowStartupLocation.CenterScreen;
90  if (finder.ShowDialog() == true)
91  {
92  txtRbNumber.Text = "Updating...";
93  _dt.Clear();
94  try
95  {
96  Seci.Standard.UserDetails.SetRbNumber(finder.RB);
97  System.Threading.Thread.Sleep(1000);
98  Seci.Standard.UserDetails.SetUsers(finder.Users);
99  }
100  catch
101  {
102  return;
103  }
104 
105  System.Threading.Thread.Sleep(500);
106  Update();
107  }
108  }
109  catch (Exception err)
110  {
111 
112  }
113  }
114 
115  private void lnkSamplesheet_Click(object sender, RoutedEventArgs e)
116  {
117  if (!_webpageLauncher.IsBusy)
118  {
119  _webpageLauncher.RunWorkerAsync();
120  }
121  }
122 
123  void _webpageLauncher_DoWork(object sender, DoWorkEventArgs e)
124  {
125  //Launch default web browser
126  try
127  {
128  System.Diagnostics.Process.Start(Seci.Definitions.Status.SampleSheetWebpage);
129  }
130  catch
131  {
132  }
133  }
134 
135  private void lnkEra_Click(object sender, RoutedEventArgs e)
136  {
137  //Launch default web browser
138  try
139  {
140  System.Diagnostics.Process.Start(Seci.Definitions.Status.EraSheetWebpage);
141  }
142  catch
143  {
144  }
145  }
146  }
147 
148 }
Interaction logic for UserInformation.xaml
void UserControl_Loaded(object sender, RoutedEventArgs e)
void btnEditUsers_Click(object sender, RoutedEventArgs e)
void _webpageLauncher_DoWork(object sender, DoWorkEventArgs e)
Interaction logic for RBFinder.xaml
void btnChangeRB_Click(object sender, RoutedEventArgs e)
void lnkSamplesheet_Click(object sender, RoutedEventArgs e)
void lnkEra_Click(object sender, RoutedEventArgs e)