2 using System.ComponentModel;
6 using System.Windows.Forms;
7 using System.Collections.Generic;
10 namespace Sample_Environment_Control_Interface
12 public partial class SECI_GUI
22 if (newConf.ShowDialog() == DialogResult.OK)
24 GeneralSplashScreen.ShowSplashScreen(
"Please wait...");
28 if (newConf.IsComponent)
31 Seci.SeciInterface.Configuration_New(
true);
37 Seci.SeciInterface.Configuration_New(
false);
41 GeneralSplashScreen.CloseForm();
56 openFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.ConfigDir;
57 openFileDialog1.Filter =
"SECI Configuration|*.conf|SECI Component|*.comp";
61 GeneralSplashScreen.ShowSplashScreen(
"Opening Configuration...");
63 GeneralSplashScreen.CloseForm();
66 openFileDialog1.Dispose();
70 MessageBox.Show(
"Failed to open configuration/component!\nError message was: " + err.Message,
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
72 GeneralSplashScreen.CloseForm();
81 private void OpenConfig(String filename, Boolean checkVIs)
85 Boolean isConf = !filename.EndsWith(
".comp");
92 Seci.SeciInterface.Configuration_New(
true);
97 Seci.SeciInterface.Configuration_New(
false);
101 Seci.SeciInterface.Configuration_Open(filename);
116 statusStrip1.BringToFront();
120 _currentLayout.HideAllGroups();
123 catch (Exception err)
126 _errorForm.addSeciMessage(DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(),
"Open Configuration",
"Could not open configuration.");
131 throw new ArgumentException(err.Message);
136 System.Threading.Thread.Sleep(2000);
152 MessageBox.Show(
"Failed to load GUI settings - default settings used!",
"Could not load GUI settings!", MessageBoxButtons.OK, MessageBoxIcon.Error);
160 for (
int i = 0; i < _currentLayout.Graphs.Count; ++i)
162 _currentLayout.Graphs[i].EditClicked +=
new SECI_Controls.Graph.SECI_Graph.CustomEventsMenuHandler(
SECIgraph_EditClicked);
168 this.Controls.AddRange((SECI_Controls.Run_Information.Scaling_RunInfo[])
_currentLayout.
RunInfos.ToArray());
178 List<String> notloaded = Seci.SeciInterface.LV_GetListVIsNotLoaded();
180 if (notloaded != null)
183 for (
int i = 0; i < notloaded.Count; ++i)
186 if (MessageBox.Show(
"The VI " + notloaded[i].ToString() +
" could not be found. Would you like SECI to search for the VI?",
"VI Not Found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
188 String VI = notloaded[i].ToString();
189 String searchResult =
FileSearch(Seci.SeciInterface.SeciStatus.LabViewDir, VI.Substring(VI.LastIndexOf(
'\\') + 1));
191 if (searchResult != null)
194 if (MessageBox.Show(
"Found the VI: " + searchResult +
". Would you like this VI to be loaded as an alternative?",
"VI Found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
196 Seci.SeciInterface.Configuration_ChangeVIPath(notloaded[i].ToString(), searchResult);
198 _currentLayout.ChangeVIPath(notloaded[i].ToString(), searchResult);
203 Seci.SeciInterface.Configuration_RemoveLVPanel(notloaded[i].ToString());
205 _currentLayout.RemoveVIFromAllGroups(notloaded[i].ToString());
211 MessageBox.Show(
"Could not find an alternative VI.",
"VI Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
214 Seci.SeciInterface.Configuration_RemoveLVPanel(notloaded[i].ToString());
216 _currentLayout.RemoveVIFromAllGroups(notloaded[i].ToString());
222 Seci.SeciInterface.Configuration_RemoveLVPanel(notloaded[i].ToString());
224 _currentLayout.RemoveVIFromAllGroups(notloaded[i].ToString());
236 foreach (String f
in Directory.GetFiles(sDir, filename))
238 return sDir +
"\\" + filename;
242 foreach (
string d
in Directory.GetDirectories(sDir))
245 DirectoryInfo di =
new DirectoryInfo(d);
247 if (di.Attributes != FileAttributes.Hidden)
271 if (String.IsNullOrEmpty(Seci.SeciInterface.ConfigurationName))
279 Boolean okayToSave =
false;
281 if (Seci.SeciInterface.ConfigurationName.ToLower().EndsWith(
".conf"))
283 okayToSave = Seci.SeciInterface.Configuration_AllowedToSave(
true,
_manager);
285 else if (Seci.SeciInterface.ConfigurationName.ToLower().EndsWith(
".comp"))
287 okayToSave = Seci.SeciInterface.Configuration_AllowedToSave(
false,
_manager);
293 toolStripStatusLabel.Text =
"Saving...";
297 backgroundSave.RunWorkerAsync();
299 catch (Exception err)
306 MessageBox.Show(
"Sorry, you must be logged in with the manager account to overwrite this configuration!",
"Cannot Overwrite!", MessageBoxButtons.OK, MessageBoxIcon.Error);
315 if (Seci.SeciInterface.IsAComponent ==
false)
319 saveFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.ConfigDir;
320 saveFileDialog1.Filter =
"SECI Configuration|*.conf";
321 saveFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.ConfigDir;
327 saveFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.CompDir;
328 saveFileDialog1.Filter =
"SECI Component|*.comp";
329 saveFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.CompDir;
338 fileName = saveFileDialog1.FileName.Substring(saveFileDialog1.FileName.LastIndexOf(
"\\") + 1);
340 if (
saveFileDialog1.FileName.StartsWith(Seci.SeciInterface.SeciStatus.ConfigDir))
343 if (Seci.SeciInterface.Configuration_AllowedToSave(
true,
_manager))
345 String oldName = Seci.SeciInterface.ConfigurationName;
346 Seci.SeciInterface.ConfigurationName = fileName;
349 toolStripStatusLabel.Text =
"Saving...";
353 backgroundSave.RunWorkerAsync();
355 catch (Exception err)
357 Seci.SeciInterface.ConfigurationName = oldName;
363 MessageBox.Show(
"Sorry, you must be logged in with the manager account to overwrite this configuration!",
"Cannot Overwrite!", MessageBoxButtons.OK, MessageBoxIcon.Error);
368 MessageBox.Show(
"Configurations and components must be saved in their specified directories!",
"Trying to Save in wrong location", MessageBoxButtons.OK, MessageBoxIcon.Error);
378 GeneralSplashScreen.ShowSplashScreen(
"Closing Configuration...");
381 Seci.SeciInterface.Configuration_New(
false);
388 GeneralSplashScreen.CloseForm();
399 Seci.SeciInterface.Configuration_Close();
405 _lvErrorMessages.Clear();
407 toolStripErrorLabel.Visible =
false;
408 toolStripQuestionLabel.Visible =
false;
411 Seci.SeciInterface.LV_Initialise(
true);
427 Seci.SeciInterface.DAE_ShowVI();
432 Seci.SeciInterface.BeamLogger_ShowVI();
437 Seci.SeciInterface.LVQ_ShowVI();
443 if (
_changesMade || Seci.SeciInterface.Assoc_AnyModifications())
445 if (MessageBox.Show(
"There are unsaved changes to the current configuration - are you sure you wish to close it?",
"Unsaved Changes!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
487 System.Diagnostics.Process p =
new System.Diagnostics.Process();
488 p.StartInfo.FileName =
"iexplore.exe";
496 System.Diagnostics.Process p =
new System.Diagnostics.Process();
497 p.StartInfo.FileName =
"iexplore.exe";
512 if (addVI.ShowDialog() == DialogResult.OK)
515 backgroundAutosave.RunWorkerAsync();
518 catch (FileNotFoundException err)
521 _errorForm.addSeciMessage(DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(),
"Add VI", err.Message);
522 MessageBox.Show(
"Could not extract information from llb file! " + err.Message +
"!",
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
524 catch (Exception err)
527 _errorForm.addSeciMessage(DateTime.Now.Date.ToShortDateString(), DateTime.Now.ToShortTimeString(),
"Add VI",
"Could not add VI.");
528 MessageBox.Show(
"Could not add VI!",
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
537 if (removeVI.ShowDialog() == DialogResult.OK)
540 backgroundAutosave.RunWorkerAsync();
542 _currentLayout.CheckGroupsValid();
549 if (VIprop.ShowDialog() == DialogResult.OK)
552 backgroundAutosave.RunWorkerAsync();
561 Seci.SeciInterface.DAE_ShowVI();
562 showDAEVIToolStripMenuItem.Checked =
true;
566 Seci.SeciInterface.DAE_HideVI();
567 showDAEVIToolStripMenuItem.Checked =
false;
576 Seci.SeciInterface.LVQ_ShowVI();
577 showHideErrorPanelToolStripMenuItem.Checked =
true;
581 Seci.SeciInterface.LVQ_HideVI();
582 showHideErrorPanelToolStripMenuItem.Checked =
false;
591 Seci.SeciInterface.BeamLogger_ShowVI();
592 showHideBeamLoggerToolStripMenuItem.Checked =
true;
596 Seci.SeciInterface.BeamLogger_HideVI();
597 showHideBeamLoggerToolStripMenuItem.Checked =
false;
606 Seci.SeciInterface.DAEMonitor_ShowVI();
607 showHideDAEMonitorToolStripMenuItem.Checked =
true;
611 Seci.SeciInterface.DAEMonitor_HideVI();
612 showHideDAEMonitorToolStripMenuItem.Checked =
false;
620 Seci.SeciInterface.SampleParameters_ShowVI();
621 showHideSampleParametersToolStripMenuItem.Checked =
true;
625 Seci.SeciInterface.SampleParameters_HideVI();
626 showHideSampleParametersToolStripMenuItem.Checked =
false;
634 Seci.SeciInterface.BeamlineParameters_ShowVI();
635 showHideBeamlineParametersToolStripMenuItem.Checked =
true;
639 Seci.SeciInterface.BeamlineParameters_HideVI();
640 showHideBeamlineParametersToolStripMenuItem.Checked =
false;
648 Seci.SeciInterface.UserDetails_ShowVI();
649 showHideUserDetailsToolStripMenuItem.Checked =
true;
653 Seci.SeciInterface.UserDetails_HideVI();
654 showHideUserDetailsToolStripMenuItem.Checked =
false;
665 if (!Seci.SeciInterface.IsAComponent)
669 if (add.ShowDialog() == DialogResult.OK)
672 backgroundAutosave.RunWorkerAsync();
677 MessageBox.Show(
"Cannot add another component to a component! Components can only be added to configurations.",
"Cannot Add Component!", MessageBoxButtons.OK, MessageBoxIcon.Error);
685 if (!Seci.SeciInterface.IsAComponent && Seci.SeciInterface.Components_GetNames().Count > 0)
691 if (removeComp.ShowDialog() == DialogResult.OK)
694 backgroundAutosave.RunWorkerAsync();
697 _currentLayout.CheckGroupsValid();
704 MessageBox.Show(
"There are no components to remove!",
"No Components!", MessageBoxButtons.OK, MessageBoxIcon.Error);
714 if (!Seci.SeciInterface.IsAComponent && Seci.SeciInterface.Components_GetNames().Count > 0)
716 Dialogs.Config.MergeComponents merge =
new Dialogs.Config.MergeComponents();
718 if (merge.ShowDialog() == DialogResult.OK)
721 backgroundAutosave.RunWorkerAsync();
726 if (Seci.SeciInterface.IsAComponent)
728 MessageBox.Show(
"This function is only available for configurations, not components!",
"Not a Configuration!", MessageBoxButtons.OK, MessageBoxIcon.Error);
730 else if (Seci.SeciInterface.Components_GetNames().Count == 0)
732 MessageBox.Show(
"There are no components to merge!",
"No Components!", MessageBoxButtons.OK, MessageBoxIcon.Error);
741 if (order.ShowDialog() == DialogResult.OK)
744 backgroundAutosave.RunWorkerAsync();
755 if (confBlocks.ShowDialog() == DialogResult.OK)
758 backgroundAutosave.RunWorkerAsync();
770 #region "Associated Files"
776 if (addfiles.ShowDialog() == DialogResult.OK)
779 backgroundAutosave.RunWorkerAsync();
786 if (removefiles.ShowDialog() == DialogResult.OK)
789 backgroundAutosave.RunWorkerAsync();
801 if (add.ShowDialog() == DialogResult.OK)
804 backgroundAutosave.RunWorkerAsync();
812 if (
remove.ShowDialog() == DialogResult.OK)
815 backgroundAutosave.RunWorkerAsync();
821 #region "Configuration"
825 if (!Seci.SeciInterface.IsAComponent)
833 if (addConf.ShowDialog() == DialogResult.OK)
836 backgroundAutosave.RunWorkerAsync();
839 catch (Exception err)
848 MessageBox.Show(
"Cannot add configuration to a component!",
"Cannot Add Configuration!", MessageBoxButtons.OK, MessageBoxIcon.Error);
869 if (login.ShowDialog() == DialogResult.OK)
886 saveToolStripMenuItem.Enabled =
false;
887 saveAsToolStripMenuItem.Enabled =
false;
888 closeConfigurationToolStripMenuItem.Enabled =
false;
889 configurationToolStripMenuItem.Enabled =
false;
890 layoutToolStripMenuItem.Enabled =
false;
892 Seci.SeciInterface.OpenGenie_Show();
898 logInToolStripMenuItem.Enabled = !isManager;
899 logOutToolStripMenuItem.Enabled = isManager;
903 toolStripManagerLbl.Text =
"Logged in as Manager";
907 toolStripManagerLbl.Text =
"";
913 saveToolStripMenuItem.Enabled =
true;
914 saveAsToolStripMenuItem.Enabled =
true;
915 closeConfigurationToolStripMenuItem.Enabled =
true;
916 configurationToolStripMenuItem.Enabled =
true;
918 layoutToolStripMenuItem.Enabled = isConf;
919 componentsToolStripMenuItem.Enabled = isConf;
920 configurationsToolStripMenuItem.Enabled = isConf;
922 Seci.SeciInterface.OpenGenie_Show();
932 if (group.ShowDialog() == DialogResult.OK)
935 backgroundAutosave.RunWorkerAsync();
943 List<ToolStripMenuItem> menuitems =
new List<ToolStripMenuItem>();
945 for (
int i = 0; i < _currentLayout.Groups.GetLength(0); ++i)
947 menuitems.Add(
new ToolStripMenuItem(
_currentLayout.
Groups[i].
GroupName, null,
new System.EventHandler(
this.ShowGroup_Click), _currentLayout.Groups[i].GroupName));
950 menuitems.Add(
new ToolStripMenuItem(
"Hide All Pages", null,
new System.EventHandler(
this.ShowGroup_Click),
"Hide All Groups"));
952 if (menuitems.Count > 1)
955 selectPageButton1.Visible =
true;
956 selectPageButton1.DropDown.Items.Clear();
957 selectPageButton1.DropDown.Items.AddRange(menuitems.ToArray());
961 selectPageButton1.Visible =
false;
968 if (((ToolStripMenuItem)sender).ToString() ==
"Hide All Pages")
970 _currentLayout.HideAllGroups();
974 _currentLayout.HideAllGroups();
975 _currentLayout.ShowGroup(((ToolStripMenuItem)sender).Name);
981 SECI_Controls.Graph.AddEditGraph add =
new SECI_Controls.Graph.AddEditGraph(Seci.SeciInterface.Blocks_GetAllBlocksAsCollection());
983 if (add.ShowDialog() == DialogResult.OK)
985 SECI_Controls.Graph.SECI_Graph newgraph =
new SECI_Controls.Graph.SECI_Graph();
987 newgraph.Graph = add.Graph;
989 newgraph.EditClicked +=
new SECI_Controls.Graph.SECI_Graph.CustomEventsMenuHandler(
SECIgraph_EditClicked);
991 this.Controls.Add(newgraph);
992 this.Controls[this.Controls.Count - 1].BringToFront();
993 statusStrip1.BringToFront();
994 _currentLayout.Graphs.Add(newgraph);
996 backgroundAutosave.RunWorkerAsync();
1004 if (setup.ShowDialog() == DialogResult.OK)
1007 for (
int i = 0; i < CurrentLayout.RunInfos.Count; ++i)
1009 this.Controls.Remove(CurrentLayout.RunInfos[i]);
1012 CurrentLayout.RunInfos = setup.current;
1016 for (
int i = 0; i < CurrentLayout.RunInfos.Count; ++i)
1020 CurrentLayout.RunInfos[i].Location =
new Point(400 + 10 * count, 400 + 10 * count);
1024 this.Controls.Add(CurrentLayout.RunInfos[i]);
1025 this.Controls[this.Controls.Count - 1].BringToFront();
1026 statusStrip1.BringToFront();
1030 backgroundAutosave.RunWorkerAsync();
1038 if (setup.ShowDialog() == DialogResult.OK)
1041 for (
int i = 0; i < CurrentLayout.BlockViewers.Count; ++i)
1043 this.Controls.Remove(CurrentLayout.BlockViewers[i]);
1046 CurrentLayout.BlockViewers = setup.current;
1050 for (
int i = 0; i < CurrentLayout.BlockViewers.Count; ++i)
1054 CurrentLayout.BlockViewers[i].Location =
new Point(400 + 10 * count, 400 + 10 * count);
1058 this.Controls.Add(CurrentLayout.BlockViewers[i]);
1059 this.Controls[this.Controls.Count - 1].BringToFront();
1060 statusStrip1.BringToFront();
1063 backgroundAutosave.RunWorkerAsync();
1069 SECI_Controls.Graph.AddEditGraph edit =
new SECI_Controls.Graph.AddEditGraph(Seci.SeciInterface.Blocks_GetAllBlocksAsCollection());
1070 edit.Graph = sender.Graph;
1072 if (edit.ShowDialog() == DialogResult.OK)
1074 sender.Graph = edit.Graph;
1075 sender.ClearAndRecreate();
1077 backgroundAutosave.RunWorkerAsync();
1084 SECI_Controls.Graph.DeleteGraph del =
new SECI_Controls.Graph.DeleteGraph();
1087 if (del.ShowDialog() == DialogResult.OK)
1089 this.Controls.Remove(_currentLayout.Graphs[del.DeleteIndex]);
1090 _currentLayout.Graphs.RemoveAt(del.DeleteIndex);
1092 backgroundAutosave.RunWorkerAsync();
1100 for (
int i = 0; i < _currentLayout.Graphs.Count; ++i)
1102 this.Controls.Remove(_currentLayout.Graphs[i]);
1108 for (
int i = 0; i < _currentLayout.RunInfos.Count; ++i)
1110 this.Controls.Remove(_currentLayout.RunInfos[i]);
1116 for (
int i = 0; i < _currentLayout.BlockViewers.Count; ++i)
1118 this.Controls.Remove(_currentLayout.BlockViewers[i]);
void setLoadOrderToolStripMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showHideBeamlineParametersToolStripMenuItem
void SECIgraph_EditClicked(SECI_Controls.Graph.SECI_Graph sender)
void showDAEVIToolStripMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showHideUserDetailsToolStripMenuItem
void addProgMenuItem_Click(object sender, EventArgs e)
void setVIPropertiesMenuItem_Click(object sender, EventArgs e)
Seci.SerialisableList< SECI_Controls.Run_Information.Scaling_BlockViewer > BlockViewers
Seci.SerialisableList< SECI_Controls.Graph.SECI_Graph > Graphs
System.Windows.Forms.ToolStripMenuItem showHideSampleParametersToolStripMenuItem
String FileSearch(String sDir, String filename)
void blockViewersSetupToolStripMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showHideDAEMonitorToolStripMenuItem
void removeProgrammeToolStripMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showHideErrorPanelToolStripMenuItem
void OpenGuiLayout(String filename)
void ShowGroup_Click(object sender, EventArgs e)
Seci.SerialisableList< SECI_Controls.Run_Information.Scaling_RunInfo > RunInfos
void newToolStripMenuItem_Click(object sender, EventArgs e)
void reportAProblemToolStripMenuItem_Click(object sender, EventArgs e)
void editGroupsToolStripMenuItem_Click(object sender, EventArgs e)
void contentsToolStripMenuItem_Click(object sender, EventArgs e)
void HandleVIsNotLoaded()
void mergeComponentMenuItem_Click(object sender, EventArgs e)
Seci.SerialisableList< Seci.LabView.MessageInfo > _lvErrorMessages
void showHideUserDetailsToolStripMenuItem_Click(object sender, EventArgs e)
void showHideBeamLoggerToolStripMenuItem_Click(object sender, EventArgs e)
void showHideBeamlineParametersToolStripMenuItem_Click(object sender, EventArgs e)
void setupGuiForConfiguration(Boolean isConf)
void OpenConfig(String filename, Boolean checkVIs)
System.Windows.Forms.SaveFileDialog saveFileDialog1
void addComponentMenuItem_Click(object sender, EventArgs e)
void mCRNewsMenuItem_Click(object sender, EventArgs e)
void WriteError(String source, Exception e)
void showSECIMessagesMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showHideBeamLoggerToolStripMenuItem
void setupGuiForSeciStartup()
void removeVIMenuItem_Click(object sender, EventArgs e)
void closeConfigurationToolStripMenuItem_Click(object sender, EventArgs e)
void showHideDAEMonitorToolStripMenuItem_Click(object sender, EventArgs e)
void runControlEditorToolStripMenuItem_Click(object sender, EventArgs e)
static GUILayout _currentLayout
void removeFilesMenuItem_Click(object sender, EventArgs e)
void addVIMenuItem_Click(object sender, EventArgs e)
System.Windows.Forms.ToolStripMenuItem showDAEVIToolStripMenuItem
void addConfigurationMenuItem_Click(object sender, EventArgs e)
void showHideErrorPanelToolStripMenuItem_Click(object sender, EventArgs e)
void addFilesMenuItem_Click(object sender, EventArgs e)
static GUILayout CurrentLayout
void aboutToolStripMenuItem_Click(object sender, EventArgs e)
void openToolStripMenuItem_Click(object sender, EventArgs e)
static void Resume_Timers()
Boolean okayToCloseConfig()
Dialogs.Help.HelpForm help
void removeComponentMenuItem_Click(object sender, EventArgs e)
void deleteGraphToolStripMenuItem_Click(object sender, EventArgs e)
void setupGuiBasedOnAccount(bool isManager)
void runInformationSetupToolStripMenuItem_Click(object sender, EventArgs e)
static void Pause_Timers()
void logOutToolStripMenuItem_Click(object sender, EventArgs e)
void logInToolStripMenuItem_Click(object sender, EventArgs e)
void exitToolStripMenuItem_Click(object sender, EventArgs e)
void help_FormClosed(object sender, FormClosedEventArgs e)
System.Windows.Forms.OpenFileDialog openFileDialog1
void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
void showHideSampleParametersToolStripMenuItem_Click(object sender, EventArgs e)
void saveToolStripMenuItem_Click(object sender, EventArgs e)
void addGraphToolStripMenuItem_Click(object sender, EventArgs e)
static String BugzillaUrl
void configureBlocksToolStripMenuItem_Click(object sender, EventArgs e)
void SetStandardVIsVisibility()