SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
SelectSubConfig.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.Shapes;
13 
14 namespace SeciUserInterface.Dialogs.SubConfigs
15 {
19  public partial class SelectSubConfig : Window
20  {
21  private Seci.Definitions.Configuration _tempComponent = null;
22  public String ComponentName { get { return _tempComponent.ConfigName; } }
23 
24  public SelectSubConfig()
25  {
26  InitializeComponent();
27  }
28 
29  private void Window_Loaded(object sender, RoutedEventArgs e)
30  {
31  List<String> comps = Seci.Managers.ComponentMgr.GetNames();
32 
33  foreach(String comp in comps)
34  {
35  comSubConfigs.Items.Add(comp);
36  }
37  }
38 
39  private void btnSelect_Click(object sender, RoutedEventArgs e)
40  {
41  if (comSubConfigs.SelectedIndex != -1)
42  {
43  _tempComponent = Seci.Managers.ComponentMgr.Components[comSubConfigs.SelectedIndex];
44 
45  stkEditOptions.Visibility = System.Windows.Visibility.Visible;
46  stkSave.Visibility = System.Windows.Visibility.Visible;
47  btnSelect.IsEnabled = false;
48  btnSelect.IsDefault = false;
49  btnSave.IsDefault = true;
50  comSubConfigs.IsEnabled = false;
51  btnCancel1.Visibility = System.Windows.Visibility.Collapsed;
52  }
53  }
54 
55  private void btnCancel2_Click(object sender, RoutedEventArgs e)
56  {
57  DialogResult = false;
58  Close();
59  }
60 
61  private void btnSave_Click(object sender, RoutedEventArgs e)
62  {
63  Seci.Managers.ComponentMgr.SaveComponent(_tempComponent.ConfigName);
64  DialogResult = true;
65  Close();
66  }
67 
68  private void btnEditBlocks_Click(object sender, RoutedEventArgs e)
69  {
70  if (_tempComponent != null)
71  {
73  conf.CanEditSubBlocks = true;
74 
75  if (_tempComponent.Blocks != null)
76  {
77  conf.BlocksCopy = (Seci.BlockDictionary)_tempComponent.Blocks.Clone();
78  }
79 
80  if (conf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
81  {
82  _tempComponent.Blocks = conf.BlocksCopy;
83  }
84  }
85  }
86 
87  private void btnAddVIs_Click(object sender, RoutedEventArgs e)
88  {
89  if (_tempComponent != null)
90  {
91  VIs.AddVI add = new VIs.AddVI();
92  if (add.ShowDialog() == System.Windows.Forms.DialogResult.OK)
93  {
94  Seci.SerialisableList<Seci.LabView.LabViewPanelInfo> vis = _tempComponent.LVPanels;
95 
96  //Add and Load the VIs
97  for (int i = 0; i < add.VIsToAdd.Count; ++i)
98  {
99  Boolean okayToAdd = true;
100 
101  for (int j = 0; j < vis.Count; ++j)
102  {
103  if (vis[j].FilePath.ToLower() == add.VIsToAdd[i].ToLower())
104  {
105  okayToAdd = false;
106  break;
107  }
108  }
109 
110  if (okayToAdd)
111  {
112  Seci.LabView.LabViewPanelInfo pnl = new Seci.LabView.LabViewPanelInfo(add.VIsToAdd[i], true, false);
113  _tempComponent.LVPanels.Add(pnl);
114  }
115  }
116  }
117  }
118  }
119 
120  private void btnRemoveVIs_Click(object sender, RoutedEventArgs e)
121  {
122  if (_tempComponent != null)
123  {
124  VIs.RemoveVI remove = new VIs.RemoveVI(_tempComponent.LVPanels);
125  if (remove.ShowDialog() == System.Windows.Forms.DialogResult.OK)
126  {
127  if (remove.ToRemove != null)
128  {
129  //Remove the VIs and any blocks
130  for (int i = 0; i < remove.ToRemove.Count; ++i)
131  {
132  //Remove blocks
133  _tempComponent.Blocks.RemoveByVI(remove.ToRemove[i]);
134 
135  //Remove VIs
136  Seci.SerialisableList<Seci.LabView.LabViewPanelInfo> panels = _tempComponent.LVPanels;
137 
138  //Find out which objects correspond to the names to remove
139  for (int j = 0; j < panels.Count; ++j)
140  {
141  if (panels[j].FilePath == remove.ToRemove[i])
142  {
143  //Remove the VI
144  panels.RemoveAt(j);
145  break;
146  }
147  }
148  }
149  }
150  }
151  }
152  }
153 
154  private void btnConfigureVIs_Click(object sender, RoutedEventArgs e)
155  {
156  if (_tempComponent != null)
157  {
158  VIs.SetVIProperties props = new Dialogs.VIs.SetVIProperties(_tempComponent.LVPanels, true);
159  if (props.ShowDialog() == System.Windows.Forms.DialogResult.OK)
160  {
161  //Copy back
162  _tempComponent.LVPanels = props.Panels;
163  }
164  }
165  }
166 
167  private void btnEditTabs_Click(object sender, RoutedEventArgs e)
168  {
169  EditTabs edit = new EditTabs(_tempComponent);
170  edit.Owner = this;
171 
172  edit.ShowDialog();
173  }
174  }
175 }
Interaction logic for EditTabs.xaml
void btnSave_Click(object sender, RoutedEventArgs e)
void btnAddVIs_Click(object sender, RoutedEventArgs e)
This class contains all the information that defines the configuration at the SECI level and contains...
void btnEditTabs_Click(object sender, RoutedEventArgs e)
void Window_Loaded(object sender, RoutedEventArgs e)
void btnRemoveVIs_Click(object sender, RoutedEventArgs e)
Specialised version of the Dictionary class which can be converted to XML. Also has some additional s...
This class contains all the information about a LabVIEW VI that needs to be saved in the configuratio...
void btnEditBlocks_Click(object sender, RoutedEventArgs e)
void btnCancel2_Click(object sender, RoutedEventArgs e)
void btnSelect_Click(object sender, RoutedEventArgs e)
Interaction logic for SelectSubConfig.xaml
void btnConfigureVIs_Click(object sender, RoutedEventArgs e)