SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
BeamlineInformation.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 
17 namespace SeciControls
18 {
22  public partial class BeamlineInformation : UserControl
23  {
24  private DataTable _dt;
25 
27  {
28  InitializeComponent();
29  }
30 
31  private void UserControl_Loaded(object sender, RoutedEventArgs e)
32  {
33  _dt = new DataTable("BeamlineInfo");
34  _dt.Columns.Add("Name", typeof(string));
35  _dt.Columns.Add("Type", typeof(string));
36  _dt.Columns.Add("Units", typeof(string));
37  _dt.Columns.Add("Value", typeof(string));
38  }
39 
40  public void Update()
41  {
42  _dt.Clear();
43 
44  String[,] parameters = Seci.Standard.BeamlineParameters.GetParameters();
45 
46  if (parameters != null)
47  {
48  for (int i = 0; i < parameters.GetLength(0); ++i)
49  {
50  _dt.Rows.Add(parameters[i,0], parameters[i,1], parameters[i,2], parameters[i,3]);
51  }
52  }
53  dgSampleInfo.ItemsSource = _dt.DefaultView;
54 
55  //Workround to force datagrid to shrink if new data is shorter than previous.
56  for (int i = 0; i < dgSampleInfo.Columns.Count; ++i)
57  {
58  dgSampleInfo.Columns[i].Width = 0;
59  dgSampleInfo.Columns[i].Width = DataGridLength.SizeToCells;
60  }
61  }
62 
63  private void btnAddParameter_Click(object sender, RoutedEventArgs e)
64  {
66 
67  if (add.ShowDialog() == System.Windows.Forms.DialogResult.OK)
68  {
69 
70  }
71 
72  Update();
73  }
74 
75  private void btnRemoveParameter_Click(object sender, RoutedEventArgs e)
76  {
77  if (dgSampleInfo.SelectedIndex != -1)
78  {
79  Seci.Standard.BeamlineParameters.RemoveParameter(_dt.Rows[dgSampleInfo.SelectedIndex][0].ToString());
80  System.Threading.Thread.Sleep(500);
81  }
82  else
83  {
84  MessageBox.Show("Please select a property to remove.", "Select a Property", MessageBoxButton.OK, MessageBoxImage.Warning);
85  }
86 
87  Update();
88  }
89 
90  }
91 
92 }
void btnRemoveParameter_Click(object sender, RoutedEventArgs e)
Interaction logic for UserInformation.xaml
void btnAddParameter_Click(object sender, RoutedEventArgs e)
void UserControl_Loaded(object sender, RoutedEventArgs e)