SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
ExecutableMgr.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using Seci.Definitions;
5 
6 namespace Seci.Managers
7 {
11  public static class ExecutableMgr
12  {
16  private static SerialisableList<Executable> _executables = new SerialisableList<Executable>();
17 
18  internal static SerialisableList<Executable> Executables { get { return _executables; } }
19 
20  #region Public Methods
21 
27  public static Boolean AddExecutable(String fileName)
28  {
29  if (IsDuplicate(fileName))
30  {
31  return false;
32  }
33  else
34  {
35  _executables.Add(new Executable(fileName));
36  return true;
37  }
38  }
39 
45  public static Boolean AddExecutable(Executable exe)
46  {
47  if (IsDuplicate(exe.FilePath))
48  {
49  return false;
50  }
51  else
52  {
53  exe.Load();
54  exe.Move();
55  _executables.Add(exe);
56  return true;
57  }
58  }
59 
65  public static Boolean RemoveExecutable(String fileName)
66  {
67  if (_executables != null)
68  {
69  for (int i = 0; i < _executables.Count; ++i)
70  {
71  if (_executables[i].FilePath.ToLower() == fileName.ToLower())
72  {
73 
74  _executables[i].Dispose();
75  _executables.RemoveAt(i);
76 
77  return true;
78  }
79  }
80  }
81 
82  return false;
83  }
84 
90  public static Boolean IsDuplicate(String fileName)
91  {
92  List<String> exes = GetListOfExes(true);
93 
94  return exes.Contains(fileName);
95  }
96 
103  public static List<String> GetListOfExes(Boolean includeComps)
104  {
105  List<String> exes = new List<String>();
106 
107  if (_executables != null)
108  {
109  for (int i = 0; i < _executables.Count; ++i)
110  {
111  if (includeComps || String.IsNullOrEmpty(_executables[i].OwningComponent))
112  {
113  exes.Add(_executables[i].FilePath);
114  }
115  }
116  }
117 
118  return exes;
119  }
120 
125  public static List<String> GetListOfComponentExes()
126  {
127  List<String> exes = new List<String>();
128 
129  if (_executables != null)
130  {
131  for (int i = 0; i < _executables.Count; ++i)
132  {
133  if (!String.IsNullOrEmpty(_executables[i].OwningComponent))
134  {
135  exes.Add(_executables[i].FilePath);
136  }
137  }
138  }
139 
140  return exes;
141  }
142 
148  public static Boolean Show(String fileName)
149  {
150  if (_executables != null)
151  {
152  for (int i = 0; i < _executables.Count; ++i)
153  {
154  if (_executables[i].FilePath.ToLower() == fileName.ToLower())
155  {
156  _executables[i].Show();
157  return true;
158  }
159  }
160  }
161 
162  return false;
163  }
164 
170  public static Boolean Hide(String fileName)
171  {
172  if (_executables != null)
173  {
174  for (int i = 0; i < _executables.Count; ++i)
175  {
176  if (_executables[i].FilePath.ToLower() == fileName.ToLower())
177  {
178  _executables[i].Hide();
179  return true;
180  }
181  }
182  }
183 
184  return false;
185  }
186 
192  public static String GetFilePath(String name)
193  {
194  if (_executables != null)
195  {
196  for (int i = 0; i < _executables.Count; ++i)
197  {
198  if (_executables[i].Name.ToLower() == name.ToLower())
199  {
200  return _executables[i].FilePath;
201  }
202  }
203  }
204 
205  return null;
206  }
207 
208  #endregion
209 
213  internal static void CloseAll()
214  {
215  for (int i = 0; i < _executables.Count; ++i)
216  {
217  _executables[i].Dispose();
218  }
219  _executables.Clear();
220  }
221 
222  }
223 }
This class is used for wrapping standard executables that are included as part of a configuration...
Definition: Executable.cs:15
The manager class for all things executable related
static String GetFilePath(String name)
Retrieve the full filepath based on the name of the program.
static Boolean Hide(String fileName)
Hide the program.
static Boolean AddExecutable(Executable exe)
Add a non LabVIEW programme to the configuration.
static Boolean Show(String fileName)
Display the program.
static Boolean AddExecutable(String fileName)
Add a non LabVIEW programme to the configuration.
static Boolean IsDuplicate(String fileName)
Checks that the program is not already part of the configuration.
static Boolean RemoveExecutable(String fileName)
Remove a non LabVIEW programme from the configuration.
static List< String > GetListOfExes(Boolean includeComps)
Gets a list of all the executables. Including any associated files in the components is optional...
static List< String > GetListOfComponentExes()
Gets a list of the executables in components.