using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Xml; using System.IO; using Microsoft.Win32; using System.Net; using System.Diagnostics; using System.Threading; using System.Collections.Specialized; using System.Web; namespace FCC_Uber_MDX_Configurator { public partial class MainMDXConfigForm : Form { #region Globals public ListViewItem _LVI_FusionBrainRoot; public ListViewItem _LVI_DigitalOutputRoot; public ListViewItem _LVI_AnalogueInputRoot; public ListViewItem _LVI_LoggingRoot; public ListViewItem _LVI_TimersRoot; public ListViewItem _LVI_VariablesRoot; public ListViewItem _LVI_FunctionsRoot; public ListViewItem _LVI_FontsRoot; public ListViewItem _LVI_Graphics_BackgroundRoot; public ListViewItem _LVI_Graphics_DisplayButtonRoot; public ListViewItem _LVI_Graphics_MultiImageRoot; public ListViewItem _LVI_Graphics_StaticImageRoot; public ListViewItem _LVI_Graphics_RotateImageRoot; public ListViewItem _LVI_Graphics_TextLabelsRoot; public ListViewItem _LVI_Graphics_GraphsRoot; public string _LVI_CurrentType = "root"; public ListViewItem[] _LVI_AllInAList; public List _Global_List_TSB; public FileSystemWatcher AllFunctionsDirectoryWatcher; public FileSystemWatcher AllFontsDirectoryWatcher; public int CurrentGraphicPage = -1; public string MYBUFFA = ""; public string MYBUFFA_OLD = ""; public string temp_OPENFILEONSTARTUP = null; #endregion #region Initialization public MainMDXConfigForm(string filename2Open) { MainMDXConfigFormInitializationCommon(); if (filename2Open != null) { temp_OPENFILEONSTARTUP = filename2Open; this.Shown += new EventHandler(MainMDXConfigForm_Shown); } } void MainMDXConfigForm_Shown(object sender, EventArgs e) { this.Refresh(); this.Update(); if (temp_OPENFILEONSTARTUP == "WIZARD") { NINJA_WIZARD_OPEN(); } else { OpenConfigurationFile(true, temp_OPENFILEONSTARTUP); } temp_OPENFILEONSTARTUP = null; } private void MainMDXConfigFormInitializationCommon() { InitializeComponent(); UpdateRegistry(); ClearEverything(); InitializeLogicToolstrip(); InitializeGraphics(); ReadInHelpInfo(); SetupLists(); InitializeFunctionWatcher(); ReloadAllFunctions(); ReloadAllFonts(); UpdateTextualAndList(); } private void UpdateRegistry() { RegistryKey registryAppLocation = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Fusion Control Centre\MDX Configurator"); string[] _currentInstallPaths = registryAppLocation.GetValueNames(); bool _isOthers = false; bool _thisIsAlreadyAdded = false; int max_level = 1; string _valueName = "INSTALL_PATH"; if(_currentInstallPaths.Length > 0) { foreach(string _installPathTest in _currentInstallPaths) { if(_installPathTest.StartsWith("INSTALL_PATH_")) { int _tryParseINT = -1; if(int.TryParse(_installPathTest.Substring("INSTALL_PATH_".Length), out _tryParseINT)) { object _testPath = registryAppLocation.GetValue(_installPathTest); if (_testPath.ToString().ToLower() == Application.ExecutablePath.ToLower()) { max_level = _tryParseINT; _thisIsAlreadyAdded = true; } else { string _execPath = registryAppLocation.GetValue(_installPathTest).ToString(); if (!File.Exists(_execPath)) { registryAppLocation.DeleteValue(_installPathTest); } if (!_thisIsAlreadyAdded) { if (_tryParseINT >= max_level) { max_level = _tryParseINT + 1; } } } } } } } registryAppLocation.SetValue(_valueName + "_" + max_level.ToString(), (string)Application.ExecutablePath); return; } private void InitializeGraphics() { if (SPLIT_DESIGNER.Panel2.Width - 5 > 5 && SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5 > 5) { PICTBOX_GRAPHICS.MinimumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.MaximumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.Dock = DockStyle.Bottom; SPLIT_DESIGNER.Panel2.Update(); } } public void InitializeFunctionWatcher() { if (!Directory.Exists(GlobalStaticClass.FUNCTION_DIRECTORY)) { Directory.CreateDirectory(GlobalStaticClass.FUNCTION_DIRECTORY); } if (!Directory.Exists(GlobalStaticClass.FONT_DIRECTORY)) { Directory.CreateDirectory(GlobalStaticClass.FONT_DIRECTORY); } AllFunctionsDirectoryWatcher = new FileSystemWatcher(GlobalStaticClass.FUNCTION_DIRECTORY); AllFunctionsDirectoryWatcher.IncludeSubdirectories = true; AllFunctionsDirectoryWatcher.Filter = "*.xml"; AllFunctionsDirectoryWatcher.Created += new FileSystemEventHandler(AllFunctionsDirectoryWatcher_ChangedOrCreated); AllFunctionsDirectoryWatcher.Changed += new FileSystemEventHandler(AllFunctionsDirectoryWatcher_ChangedOrCreated); AllFunctionsDirectoryWatcher.Deleted += new FileSystemEventHandler(AllFunctionsDirectoryWatcher_ChangedOrCreated); AllFunctionsDirectoryWatcher.EnableRaisingEvents = true; AllFontsDirectoryWatcher = new FileSystemWatcher(GlobalStaticClass.FONT_DIRECTORY); AllFontsDirectoryWatcher.IncludeSubdirectories = true; AllFontsDirectoryWatcher.Filter = "*.xml"; AllFontsDirectoryWatcher.Created += new FileSystemEventHandler(AllFontsDirectoryWatcher_ChangedOrCreated); AllFontsDirectoryWatcher.Changed += new FileSystemEventHandler(AllFontsDirectoryWatcher_ChangedOrCreated); AllFontsDirectoryWatcher.Deleted += new FileSystemEventHandler(AllFontsDirectoryWatcher_ChangedOrCreated); AllFontsDirectoryWatcher.EnableRaisingEvents = true; } public void InitializeLogicToolstrip() { //Depreciaited } private void ReadInHelpInfo() { if (!File.Exists("Help.xml")) { (new ErrorForm("Help XML is missing", "The file \"Help.xml\" is missing. You will be unable to use the help buttons. Please redownload this program.")).ShowDialog(); return; } try { string HelpXMLString = ""; FileStream HelpFS = new FileStream("Help.xml", FileMode.Open, FileAccess.Read); StreamReader HelpSR = new StreamReader(HelpFS); HelpXMLString = HelpSR.ReadToEnd(); HelpSR.Close(); HelpFS.Close(); XmlDocument HelpXML = new XmlDocument(); try { HelpXML.LoadXml(HelpXMLString); } catch (XmlException) { (new ErrorForm("Help XML is corrupt", "There was an error reading the \"Help.xml\" file into the program. This is an indication that the file is corrupt. Please redownload this program")).ShowDialog(); return; } XmlNode HelpXMLRootNode = HelpXML.SelectSingleNode("help_root"); XmlNodeList HelpXMLChildren = HelpXMLRootNode.SelectNodes("help"); foreach (XmlNode _Node in HelpXMLChildren) { try { GlobalStaticClass.HelpTopicClass _tempHTC = new GlobalStaticClass.HelpTopicClass(_Node.Attributes.GetNamedItem("FormID").Value, _Node.Attributes.GetNamedItem("TopicID").Value, _Node.Attributes.GetNamedItem("Title").Value, _Node.Attributes.GetNamedItem("Description").Value); foreach (XmlNode _LinkNode in _Node.ChildNodes) { _tempHTC.AddLinkIndex(new GlobalStaticClass.HelpTopicLinkStruct(_LinkNode.Attributes.GetNamedItem("FormID").Value, _LinkNode.Attributes.GetNamedItem("TopicID").Value)); } } catch (Exception) { continue; } } } catch (Exception e) { (new ErrorForm("Unexpected Error", "There was an unexpected error reading in the help file...\r\n" + e.ToString())).ShowDialog(); return; } } private void SetupLists() { _LVI_FusionBrainRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Fusion Brain"); _LVI_DigitalOutputRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Digital Outputs"); _LVI_AnalogueInputRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Analogue Inputs"); _LVI_LoggingRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Logging"); _LVI_TimersRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Timers"); _LVI_VariablesRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Variables"); _LVI_FunctionsRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Functions"); _LVI_FontsRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Fonts"); _LVI_Graphics_BackgroundRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Background Images"); _LVI_Graphics_DisplayButtonRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Display Buttons"); _LVI_Graphics_MultiImageRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Multi Images"); _LVI_Graphics_RotateImageRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Rotate Images"); _LVI_Graphics_StaticImageRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Static Images"); _LVI_Graphics_TextLabelsRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Text Labels"); _LVI_Graphics_GraphsRoot = LISTVIEW_AllXMLNodes.FindItemWithText("Graphs"); _LVI_AllInAList = new ListViewItem[] { _LVI_FusionBrainRoot, _LVI_DigitalOutputRoot, _LVI_AnalogueInputRoot, _LVI_LoggingRoot, _LVI_TimersRoot, _LVI_FontsRoot, _LVI_FunctionsRoot, _LVI_VariablesRoot, _LVI_Graphics_BackgroundRoot, _LVI_Graphics_DisplayButtonRoot, _LVI_Graphics_MultiImageRoot, _LVI_Graphics_RotateImageRoot, _LVI_Graphics_StaticImageRoot, _LVI_Graphics_TextLabelsRoot, _LVI_Graphics_GraphsRoot}; } #endregion #region Graphical Design Icon Clicked private void TSB_ConfigGraphics_Click(object sender, EventArgs e) { ChangeRightMostPanelToGraphicsMode(); } #endregion #region Logical Design Icon Clicked private void TSP_ConfigLogic_Click(object sender, EventArgs e) { ChangeRightMostPanelToLogicMode(); } #endregion #region Change Right-Most Panel to Graphics Mode public void ChangeRightMostPanelToGraphicsMode() { TS_GraphicsToolBar.Visible = true; TS_LogicToolBar.Visible = false; TABCONTROL_EACHIF.Visible = false; TABCONTROL_EACHIF.Dock = DockStyle.Bottom; PICTBOX_GRAPHICS.Visible = true; if (SPLIT_DESIGNER.Panel2.Width - 5 > 5 && SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5 > 5) { PICTBOX_GRAPHICS.MinimumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.MaximumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.Dock = DockStyle.Bottom; SPLIT_DESIGNER.Panel2.Update(); } SPLIT_DESIGNER.Panel2.Update(); } #endregion #region Change Right-Most Panel to Logic Mode public void ChangeRightMostPanelToLogicMode() { TS_GraphicsToolBar.Visible = false; TS_LogicToolBar.Visible = true; TABCONTROL_EACHIF.Visible = true; PICTBOX_GRAPHICS.Visible = false; if (SPLIT_DESIGNER.Panel2.Width - 5 > 5 && SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5 > 5) { TABCONTROL_EACHIF.MinimumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5); TABCONTROL_EACHIF.MaximumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5); TABCONTROL_EACHIF.Dock = DockStyle.Bottom; SPLIT_DESIGNER.Panel2.Update(); } } #endregion #region Update Textual and List Areas with Everything public void UpdateTextualAndList(string goToAfter) { UpdateTextualAndList(); switch (goToAfter) { case "fusion brain": if (GlobalStaticClass._Global_List_Brains_ListItems.Count > 0) { LISTVIEW_AllXMLNodes_DoubleClick((object)_LVI_FusionBrainRoot, null); } break; case "digital outputs": if (GlobalStaticClass._Global_List_DigitalOutputs_ListItems.Count > 0) { LISTVIEW_AllXMLNodes_DoubleClick((object)_LVI_DigitalOutputRoot, null); } break; case "analogue inputs": if (GlobalStaticClass._Global_List_AnalogueInputs_ListItems.Count > 0) { LISTVIEW_AllXMLNodes_DoubleClick((object)_LVI_AnalogueInputRoot, null); } break; case "logging": if (GlobalStaticClass._Global_List_Logs_ListItems.Count > 0) { LISTVIEW_AllXMLNodes_DoubleClick((object)_LVI_LoggingRoot, null); } break; case "variables": if (GlobalStaticClass._Global_List_Variables_ListItems.Count > 0) { LISTVIEW_AllXMLNodes_DoubleClick((object)_LVI_VariablesRoot, null); } break; case "functions": { } break; default: return; } } public string UpdateTextualAndList() { try { return UpdateTextualAndList(false); } catch (InvalidOperationException) { return ""; } } public string UpdateTextualAndList(bool isSaving) { string _XML = ""; XmlDocument _XML_Document; int _all = EVERYTHING(); Bitmap _busyImage = global::FCC_Uber_MDX_Configurator.Properties.Resources.RefreshIcon; if (isSaving) { _busyImage = global::FCC_Uber_MDX_Configurator.Properties.Resources.SaveIcon; } BusyDoingCrapForm _BUSYFORM = new BusyDoingCrapForm(_busyImage, _all); _BUSYFORM.Show(); _BUSYFORM.TopMost = true; this.Cursor = Cursors.WaitCursor; if (_LVI_FusionBrainRoot == null || _LVI_DigitalOutputRoot == null || _LVI_AnalogueInputRoot == null || _LVI_LoggingRoot == null || _LVI_TimersRoot == null || _LVI_Graphics_BackgroundRoot == null || _LVI_Graphics_DisplayButtonRoot == null || _LVI_Graphics_MultiImageRoot == null || _LVI_Graphics_RotateImageRoot == null || _LVI_Graphics_StaticImageRoot == null || _LVI_Graphics_TextLabelsRoot == null || _LVI_Graphics_GraphsRoot == null) { (new ErrorForm("List View Error", "One of the Nodes has not been found. If you can reproduce this error, please email me at FusionControlCentre@gmail.com")).ShowDialog(); GetRidOfBusyForm(_BUSYFORM); return null; } #region Get XML Prepared { GlobalStaticClass._GlobalPropertiesClass._LastModifiedDate = DateTime.Now; #region Starting Region //Starting _XML += "\r\n"; if (GlobalStaticClass._GlobalPropertiesClass._author == "") { GlobalStaticClass._GlobalPropertiesClass._author = "Me"; } _XML += "\r\n"; #endregion #region Require Region //Require _XML += "\r\n "; { #region Functions _XML += "\r\n \r\n"; GlobalStaticClass.Functions_LocalizeAllFunctions_PopulateList(); foreach (string _function in GlobalStaticClass.Functions_ToSaveLocally_Names) { _BUSYFORM.UpdateBar(); _XML += " \r\n"; _BUSYFORM.UpdateBar(); } _XML += " \r\n"; #endregion #region Fonts _XML += "\r\n \r\n"; GlobalStaticClass.Fonts_LocalizeAllFonts_PopulateList(); // foreach (GlobalStaticClass.Font_ToSaveStruct _font in GlobalStaticClass.Fonts_ToSaveLocally_Names) { foreach (GlobalStaticClass.PseudoFusionFont _PseudoFont in GlobalStaticClass._Global_List_Graphics_Fonts) { if (_PseudoFont.font_path_XML.ToLower() == _font._xml.ToLower()) { _BUSYFORM.UpdateBar(); _XML += " \r\n"; _BUSYFORM.UpdateBar(); break; } } } _XML += " \r\n"; #endregion } _XML += " \r\n"; #endregion #region Speech //Require _XML += "\r\n "; { _XML += "\r\n \r\n"; foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_system) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } _XML += " \r\n"; _XML += "\r\n \r\n"; _XML += " \r\n"; foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output_turn_on) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output_turn_off) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_analogue_input_read) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } foreach (string _speechItem in GlobalStaticClass.Speech_StaticSetupClass.generic_analogue_input) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem + "\r\n"; _BUSYFORM.UpdateBar(); } _XML += " \r\n"; _XML += " \r\n"; _XML += "\r\n \r\n"; _XML += " \r\n"; foreach (GlobalStaticClass.Speech_StaticSetupClass.customDefinition _speechItem in GlobalStaticClass.Speech_StaticSetupClass.custom_definition_digital_outputs) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem.spokenName + "\r\n"; _BUSYFORM.UpdateBar(); } foreach (GlobalStaticClass.Speech_StaticSetupClass.customDefinition _speechItem in GlobalStaticClass.Speech_StaticSetupClass.custom_definition_variables) { _BUSYFORM.UpdateBar(); _XML += " " + _speechItem.spokenName + "\r\n"; _BUSYFORM.UpdateBar(); } _XML += " \r\n"; _XML += " \r\n"; _XML += "\r\n \r\n"; _XML += " \r\n"; foreach (GlobalStaticClass.Speech_StaticSetupClass.customQuery _speechItem in GlobalStaticClass.Speech_StaticSetupClass.custom_query_list) { _BUSYFORM.UpdateBar(); _XML += " \r\n"; _XML += " \r\n"; _XML += " \r\n"; foreach (string _speechSubItem in _speechItem.builder_beginnings) { _XML += " \r\n"; } _XML += " \r\n"; _XML += " \r\n"; foreach (string _speechSubItem in _speechItem.builder_middles) { _XML += " \r\n"; } _XML += " \r\n"; _XML += " \r\n"; foreach (string _speechSubItem in _speechItem.builder_endings) { _XML += " \r\n"; } _XML += " \r\n"; _XML += " \r\n"; _XML += " \r\n"; foreach (GlobalStaticClass.Speech_Response _speechSubItem in _speechItem.possible_responses) { _XML += " \r\n"; } _XML += " \r\n"; _XML += " \r\n"; _BUSYFORM.UpdateBar(); } _XML += " \r\n"; _XML += " \r\n"; } _XML += " \r\n"; #endregion #region General Region _XML += "\r\n "; { #region Debugging if (GlobalStaticClass.Debug_MasterEnable) { _XML += "\r\n \r\n"; _XML += " \r\n"; if (GlobalStaticClass.Debug_VariableWindow) { _XML += " \r\n"; } if (GlobalStaticClass.Debug_IfThenWindow) { _XML += " \r\n"; } if (GlobalStaticClass.Debug_SpeechWindow) { _XML += " \r\n"; } foreach (string _virtualID in GlobalStaticClass.Debug_VirtualBrainList) { _XML += " \r\n"; } _XML += " \r\n"; _XML += " \r\n"; } #endregion #region Remote // _XML += "\r\n \r\n"; string remote_status_string = "disabled"; if (GlobalStaticClass.RemoteControlProperties.enabled) { remote_status_string = "enabled"; } _XML += " \r\n"; _XML += " \r\n"; #endregion #region COM /* */ _XML += "\r\n \r\n"; string com_status_string = "disabled"; if (GlobalStaticClass.COM_Master_Enable) { com_status_string = "enabled"; } _XML += " \r\n"; _XML += " \r\n"; foreach (GlobalStaticClass.COM_Command_Class _comInt in GlobalStaticClass.COM_List_of_Commands) { _XML += " \r\n"; foreach (GlobalStaticClass.Vote_VoteClass _voteClass in _comInt.do_statements) { _XML += " " + "\r\n"; } _XML += " \r\n"; } _XML += " "; _XML += " \r\n"; foreach (GlobalStaticClass.COM_Execution_Object_Class _comExec in GlobalStaticClass.COM_List_of_Executable_Commands) { // _XML += " \r\n"; foreach (GlobalStaticClass.COM_Execution_Object_Class.COM_Execution_Object_Command_IDs_Class _command in _comExec.COM_Commands) { // _XML += " \r\n"; foreach (GlobalStaticClass.COM_Execution_Object_Class.COM_External_Executable_Parameter_Class _p in _command.external_Command_Parameters) { // _XML += " \r\n"; } _XML += " \r\n"; } _XML += " \r\n"; } _XML += " "; _XML += " \r\n"; _XML += " \r\n"; #endregion } _XML += " \r\n"; #endregion #region Graphics Region //Graphics _XML += "\r\n "; { #region Clear ListViewItem Lists GlobalStaticClass._Global_List_Graphics_BackgroundImage_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_StaticImage_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_DisplayButton_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_MultiImage_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_TextLabels_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_Graph_ListItems.Clear(); GlobalStaticClass._Global_List_Graphics_VariableLocationImage_ListItems.Clear(); #endregion #region Global Graphics Setting _XML += "\r\n \r\n"; _XML += " "; _XML += "\r\n \r\n"; #endregion #region Graphics Background Images _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_BackgroundImage _background in GlobalStaticClass._Global_List_Graphics_BackgroundImage) { _BUSYFORM.UpdateBar(); _XML += "\r\n "; GlobalStaticClass._Global_List_Graphics_BackgroundImage_ListItems.Add(new ListViewItem(_background._page.ToString(), "BackgroundImageIcon.png")); } _XML += "\r\n \r\n"; #endregion #region Graphics Static Images _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_StaticImage _static in GlobalStaticClass._Global_List_Graphics_StaticImage) { _BUSYFORM.UpdateBar(); if (_static._pages.Count == 0) { continue; } _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; for (int staticimagepage_i = 1; staticimagepage_i < _static._pages.Count; staticimagepage_i++) { _XML += "\r\n "; } GlobalStaticClass._Global_List_Graphics_StaticImage_ListItems.Add(new ListViewItem(_static._name, "ImageIcon.png")); _XML += "\r\n "; } _XML += "\r\n \r\n"; #endregion #region Graphics Variable Location Images _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_VariableLocationImage _varLoc in GlobalStaticClass._Global_List_Graphics_VariableLocationImage) { _BUSYFORM.UpdateBar(); if (_varLoc._pages.Count == 0) { continue; } _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; for (int _varLocimagepage_i = 1; _varLocimagepage_i < _varLoc._pages.Count; _varLocimagepage_i++) { _XML += "\r\n "; } GlobalStaticClass._Global_List_Graphics_VariableLocationImage_ListItems.Add(new ListViewItem(_varLoc._name, "VariableLocationImageIcon.png")); _XML += "\r\n "; } _XML += "\r\n \r\n"; #endregion #region Graphics Variable Location Images _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_Graph _graph in GlobalStaticClass._Global_List_Graphics_Graphs) { _BUSYFORM.UpdateBar(); if (_graph._pages.Count == 0) { continue; } _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; } _XML += "\r\n "; for (int _graphimagepage_i = 1; _graphimagepage_i < _graph._pages.Count; _graphimagepage_i++) { _XML += "\r\n "; } GlobalStaticClass._Global_List_Graphics_Graph_ListItems.Add(new ListViewItem(_graph._name, "GraphIcon.png")); _XML += "\r\n "; } _XML += "\r\n \r\n"; #endregion #region Graphics Display Button _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_DisplayButton _displaybutton in GlobalStaticClass._Global_List_Graphics_DisplayButton) { _BUSYFORM.UpdateBar(); if (_displaybutton._pages.Count == 0 || _displaybutton._MyVote == null || _displaybutton._image_Primary == null || !File.Exists(_displaybutton._path_Primary) || _displaybutton._image_Secondary == null || !File.Exists(_displaybutton._path_Secondary) || _displaybutton._image_Disabled == null || !File.Exists(_displaybutton._path_Disabled) || _displaybutton._image_Pushed == null || !File.Exists(_displaybutton._path_Pushed)) { continue; } _XML += "\r\n "; GlobalStaticClass._Global_List_Graphics_DisplayButton_ListItems.Add(new ListViewItem(_displaybutton._name, "DisplayButtonIcon.png")); } _XML += "\r\n \r\n"; #endregion #region Graphics Multi-Image _XML += "\r\n "; foreach (GlobalStaticClass.FusionImage_MultiImage _multiImage in GlobalStaticClass._Global_List_Graphics_MultiImage) { _BUSYFORM.UpdateBar(); if (_multiImage._pages.Count == 0 || _multiImage._ImageList.Count == 0) { continue; } _XML += "\r\n "; _XML += "\r\n "; for (int multiimagepage_i = 1; multiimagepage_i < _multiImage._pages.Count; multiimagepage_i++) { _XML += "\r\n "; } foreach (GlobalStaticClass.FusionImage_MultiImage.MultiImageProperties _multiImageProperties in _multiImage._ImageList) { //_BUSYFORM.UpdateBar(); if (!File.Exists(_multiImageProperties._path)) { continue; } _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; } _XML += "\r\n "; GlobalStaticClass._Global_List_Graphics_MultiImage_ListItems.Add(new ListViewItem(_multiImage._name, "MultiImageIcon.png")); } _XML += "\r\n \r\n"; #endregion #region Graphics Text Labels _XML += "\r\n "; foreach (GlobalStaticClass.FusionFont_TextLabel _textLabel in GlobalStaticClass._Global_List_Graphics_TextLabels) { _BUSYFORM.UpdateBar(); if (_textLabel._pages.Count == 0) { continue; } _XML += "\r\n "; _XML += "\r\n "; _XML += "\r\n "; for (int textlabelpage_i = 1; textlabelpage_i < _textLabel._pages.Count; textlabelpage_i++) { _XML += "\r\n "; } _XML += "\r\n "; GlobalStaticClass._Global_List_Graphics_TextLabels_ListItems.Add(new ListViewItem(_textLabel._name, "FontIcon.png")); } _XML += "\r\n \r\n"; #endregion } _XML += " \r\n"; #endregion #region IO Region //IO _XML += "\r\n "; { #region Fusion Brains _XML += "\r\n \r\n"; GlobalStaticClass._Global_List_Brains_ListItems.Clear(); foreach (GlobalStaticClass._GlobalBrainClass _brain in GlobalStaticClass._Global_List_Brains) { _BUSYFORM.UpdateBar(); _XML += " " + _brain._VIDPID.Replace("&", "&") + "\r\n"; GlobalStaticClass._Global_List_Brains_ListItems.Add(new ListViewItem(_brain._humanName, "BrainIcon.png")); } _XML += " \r\n"; #endregion #region Timers _XML += "\r\n \r\n"; _XML += " \r\n"; _XML += " \r\n"; _XML += " \r\n"; _XML += " \r\n"; _XML += " \r\n"; #endregion #region IO Channels #region Digital Outputs _XML += "\r\n \r\n"; GlobalStaticClass._Global_List_DigitalOutputs_ListItems.Clear(); foreach (GlobalStaticClass._GlobalDigitalOutputClass _DO in GlobalStaticClass._Global_List_DigitalOutputs) { _BUSYFORM.UpdateBar(); _XML += " \r\n" + " \r\n" + " \r\n"; GlobalStaticClass._Global_List_DigitalOutputs_ListItems.Add(new ListViewItem(_DO.id, "OutputIcon.png")); } _XML += " \r\n"; #endregion #region Analogue Inputs _XML += "\r\n \r\n"; GlobalStaticClass._Global_List_AnalogueInputs_ListItems.Clear(); foreach (GlobalStaticClass._GlobalAnalogueInputClass _AI in GlobalStaticClass._Global_List_AnalogueInputs) { _BUSYFORM.UpdateBar(); _XML += " \r\n" + " \r\n" + " \r\n"; GlobalStaticClass._Global_List_AnalogueInputs_ListItems.Add(new ListViewItem(_AI.id, "InputIcon.png")); } _XML += " \r\n"; #endregion #endregion } _XML += " \r\n"; #endregion #region Logic Region //Logic _XML += "\r\n "; { #region Logging Setup _XML += "\r\n \r\n"; _XML += " \r\n"; GlobalStaticClass._Global_List_Logs_ListItems.Clear(); foreach (GlobalStaticClass._GlobalLogClass _log in GlobalStaticClass._Global_List_Logs) { _BUSYFORM.UpdateBar(); _XML += " \r\n \r\n \r\n \r\n"; GlobalStaticClass._Global_List_Logs_ListItems.Add(new ListViewItem(_log._id, "LoggingIcon.png")); } _XML += " \r\n"; _XML += " \r\n"; #endregion #region Variable Declarations _XML += "\r\n \r\n"; _XML += " \r\n"; GlobalStaticClass._Global_List_Variables_ListItems.Clear(); foreach (GlobalStaticClass._GlobalVariableClass _var in GlobalStaticClass._Global_List_Variables) { _BUSYFORM.UpdateBar(); _XML += " " + _var._value.ToString() + "\r\n"; GlobalStaticClass._Global_List_Variables_ListItems.Add(new ListViewItem(_var._id, "VariableIcon.png")); } _XML += " \r\n"; _XML += " \r\n"; #endregion #region Logic Statements _XML += "\r\n \r\n"; _XML += " \r\n"; foreach (GlobalStaticClass._GlobalFunctionsClass _logic in GlobalStaticClass._Global_List_Functions) { _BUSYFORM.UpdateBar(); foreach (LogicModules.Module _tempFuncModule in _logic._function._Modules) { if (_tempFuncModule.id == "OUTPUT") { string _tempReturnedFunctionString = " " + CustomFunctionForm.XML_IterateFunctionModules(_tempFuncModule.Input_Nodes[0].LinkTo.Link_Module, "", 3); if (_logic._function._ThenList.Count > 0) { _tempReturnedFunctionString += "\r\n "; foreach (GlobalStaticClass.Vote_VoteClass _voteClass in _logic._function._ThenList) { _tempReturnedFunctionString += "\r\n " + ""; } _tempReturnedFunctionString += "\r\n "; } if (_logic._function._AntiThenList.Count > 0) { _tempReturnedFunctionString += "\r\n "; foreach (GlobalStaticClass.Vote_VoteClass _voteClass in _logic._function._AntiThenList) { _tempReturnedFunctionString += "\r\n " + ""; } _tempReturnedFunctionString += "\r\n "; } _tempReturnedFunctionString += "\r\n "; _XML += _tempReturnedFunctionString + "\r\n"; break; } } } _XML += " \r\n"; _XML += " \r\n"; #endregion } _XML += " \r\n"; #endregion #region Ending Region //Ending _XML += ""; #endregion } #endregion #region Verify XML Data try { _XML_Document = new XmlDocument(); //string newXML = _XML.Replace("<", "&lt;"); _XML_Document.LoadXml(_XML); } catch (Exception e) { (new ErrorForm("XML Parse Error", "Error parsing object data to XML. If you can duplicate this error, please contact us at FusionControlCentre@gmail.com")).ShowDialog(); GetRidOfBusyForm(_BUSYFORM); return null; } #endregion #region Update Text Area this.TXT_AllXMLCode.Clear(); this.TXT_AllXMLCode.Text = _XML; this.TXT_AllXMLCode.Update(); #endregion #region Update List View Area { LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.AddRange(_LVI_AllInAList); LISTVIEW_AllXMLNodes.Update(); } #endregion MYBUFFA = _XML; GetRidOfBusyForm(_BUSYFORM); return _XML; } private void GetRidOfBusyForm(BusyDoingCrapForm _form) { _form.Close(); this.Cursor = Cursors.Arrow; return; } #endregion #region Global Graphics Properties Icon Clicked private void TSB_GRAPHICSPROPERTIES_Click(object sender, EventArgs e) { GlobalGraphicPropertiesForm _tempGlobalGraphicsPropertiesForm = new GlobalGraphicPropertiesForm(); switch(_tempGlobalGraphicsPropertiesForm.ShowDialog()) { case DialogResult.OK: { Console.WriteLine("OK"); UpdateTextualAndList(); } break; case DialogResult.Cancel: default: { Console.WriteLine("Cancel"); } break; } } #endregion #region Global Properties Icon Clicked private void TSB_Properties_Click(object sender, EventArgs e) { GlobalPropertiesForm _tempGlobalPropertiesForm = new GlobalPropertiesForm(); switch (_tempGlobalPropertiesForm.ShowDialog()) { case DialogResult.OK: { Console.WriteLine("OK"); UpdateTextualAndList(); } break; case DialogResult.Cancel: default: { Console.WriteLine("Cancel"); } break; } } #endregion #region Add Brain Icon Clicked private void TSB_AddBrain_Click(object sender, EventArgs e) { BrainForm _tempBrainForm = new BrainForm(); if (_tempBrainForm.ShowDialog(this) == DialogResult.OK) { //Add it to the main list List _tempReturn = _tempBrainForm.GetTheBrainInformation(); if (_tempReturn == null) { return; } if (_tempReturn.Count == 3) { bool isUnique = true; foreach (GlobalStaticClass._GlobalBrainClass _searchBrainClass in GlobalStaticClass._Global_List_Brains) { if (_searchBrainClass._humanName.ToLower() == _tempReturn[0] || _searchBrainClass._VIDPID.ToLower() == _tempReturn[1]) { isUnique = false; (new ErrorForm("Invalid Fusion Brain", "This is a duplicate of another already added Fusion Brain")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._GlobalBrainClass _tempNewBrain = new GlobalStaticClass._GlobalBrainClass(_tempReturn[0], _tempReturn[1], int.Parse(_tempReturn[2])); } } UpdateTextualAndList(); } } #endregion #region Add Digital Output Icon is Clicked private void TSB_DigitalOutput_Click(object sender, EventArgs e) { if (GlobalStaticClass._Global_List_Brains.Count == 0) { //There are no Brains Setup (new ErrorForm("No Connected Brains", "You cannot add a Digital Output before you add a Fusion Brain instance to your configuration")).ShowDialog(); return; } AddDigitialOutputForm _tempAddDOForm = new AddDigitialOutputForm(); if (_tempAddDOForm.ShowDialog() == DialogResult.OK) { //Add Digital Output List _tempReturned = _tempAddDOForm.GetDigitalOutputData(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 4) { bool isUnique = true; foreach (GlobalStaticClass._GlobalDigitalOutputClass _searchDigitalOutputClass in GlobalStaticClass._Global_List_DigitalOutputs) { if (_searchDigitalOutputClass.id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Digital Output", "This is a duplicate of another already added Digital Output")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._GlobalDigitalOutputClass _tempNewDO = new GlobalStaticClass._GlobalDigitalOutputClass((string)_tempReturned[2], (int)_tempReturned[1], (string)_tempReturned[0], (string)_tempReturned[3]); } UpdateTextualAndList(); } } _tempAddDOForm.Dispose(); } #endregion #region Setup Timers private void TSB_Timers_Click(object sender, EventArgs e) { (new TimerSetupForm()).ShowDialog(); UpdateTextualAndList(); } #endregion #region Add Analogue Input Icon is Clicked private void TSB_AddAnalogue_Click(object sender, EventArgs e) { if (GlobalStaticClass._Global_List_Brains.Count == 0) { //There are no Brains Setup (new ErrorForm("No Connected Brains", "You cannot add an Analogue Input before you add a Fusion Brain instance to your configuration")).ShowDialog(); return; } AddAnalogueInputForm _tempAddAIForm = new AddAnalogueInputForm(); if (_tempAddAIForm.ShowDialog() == DialogResult.OK) { //Add Analogue Input List _tempReturned = _tempAddAIForm.GetAnalogueInputDataBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 5) { bool isUnique = true; foreach (GlobalStaticClass._GlobalAnalogueInputClass _searchAnalogueInputClass in GlobalStaticClass._Global_List_AnalogueInputs) { if (_searchAnalogueInputClass.id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Analogue Input", "This is a duplicate of another already added Analogue Input")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._GlobalAnalogueInputClass _tempNewAI = new GlobalStaticClass._GlobalAnalogueInputClass((string)_tempReturned[1], (int)_tempReturned[2], (string)_tempReturned[0], (string)_tempReturned[3], (int)_tempReturned[4]); } UpdateTextualAndList(); } } _tempAddAIForm.Dispose(); } #endregion #region Fusion Font Icon is Clicked private void TSB_FusionFont_Click(object sender, EventArgs e) { AllFontsDirectoryWatcher.EnableRaisingEvents = false; (new AddFontForm()).ShowDialog(); AllFontsDirectoryWatcher.EnableRaisingEvents = true; ReloadAllFonts(); } #endregion #region Logging Icon is Clicked private void TSB_Logging_Click(object sender, EventArgs e) { if (GlobalStaticClass._Global_List_Brains.Count == 0) { //There are no Brains Setup (new ErrorForm("No Connected Brains", "You cannot add a Logging Instance before you add a Fusion Brain instance to your configuration")).ShowDialog(); return; } if (GlobalStaticClass._Global_List_DigitalOutputs.Count == 0 && GlobalStaticClass._Global_List_AnalogueInputs.Count == 0 && GlobalStaticClass._Global_List_Variables.Count == 0) { (new ErrorForm("No Items to Monitor", "You cannot add a Logging instance before you add an item to your configuration that can be logged (Digital Output, Analogue Input, Variable)")).ShowDialog(); return; } AddLoggingForm _tempAddLoggingForm = new AddLoggingForm(); if (_tempAddLoggingForm.ShowDialog() == DialogResult.OK) { //Add Logging Instance List _tempReturned = _tempAddLoggingForm.GetTheLogDataBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 10) { bool isUnique = true; foreach (GlobalStaticClass._GlobalLogClass _searchLogClasses in GlobalStaticClass._Global_List_Logs) { if (_searchLogClasses._id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Logging Instance", "This is a duplicate of another already added Logging Instance")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._GlobalLogClass _tempNewLog = new GlobalStaticClass._GlobalLogClass((string)_tempReturned[0], (string)_tempReturned[1], (string)_tempReturned[2], (string)_tempReturned[3], (string)_tempReturned[4], (string)_tempReturned[5], (string)_tempReturned[6], (int)_tempReturned[7], (string)_tempReturned[8], (string)_tempReturned[9]); } UpdateTextualAndList(); } } _tempAddLoggingForm.Dispose(); } #endregion #region GetEverything public static int EVERYTHING() { int _r = 0; _r += GlobalStaticClass._Global_List_Graphics_PageList.Count; _r += (GlobalStaticClass._Global_List_Graphics_DisplayButton.Count * 4); _r += (GlobalStaticClass._Global_List_Graphics_StaticImage.Count); foreach (GlobalStaticClass.FusionImage_MultiImage _m in GlobalStaticClass._Global_List_Graphics_MultiImage) { _r += _m._ImageList.Count; } _r += GlobalStaticClass._Global_List_AllModuleBounds.Count; _r += GlobalStaticClass._Global_List_Graphics_BackgroundImage.Count; _r += GlobalStaticClass._Global_List_Brains.Count; _r += GlobalStaticClass._Global_List_DigitalOutputs.Count; _r += GlobalStaticClass._Global_List_AnalogueInputs.Count; _r += GlobalStaticClass._Global_List_Variables.Count; _r += GlobalStaticClass._Global_List_Logs.Count; _r += GlobalStaticClass._Global_List_Functions.Count; return _r; } #endregion #region Save Configuration File private void TSB_Save_Click(object sender, EventArgs e) { SaveConfigurationFile(); } public bool SaveConfigurationFile() { if (SaveConfigDialog.ShowDialog() == DialogResult.OK) { string _XML = UpdateTextualAndList(true); MYBUFFA_OLD = _XML; if (_XML == null) { (new ErrorForm("Parse Error", "Unable to Parse the XML output file. Aborting Save Operation...")).ShowDialog(); return false; } try { FileStream _tempFileStream = new FileStream(SaveConfigDialog.FileName, FileMode.Create, FileAccess.ReadWrite); StreamWriter _tempXMLWriter = new StreamWriter(_tempFileStream); _tempXMLWriter.Write(_XML); _tempXMLWriter.Close(); _tempFileStream.Close(); } catch (Exception except_e) { (new ErrorForm("Unable to Save", except_e.ToString())).ShowDialog(); return false; } string savepath = SaveConfigDialog.FileName; savepath = savepath.Substring(0, savepath.LastIndexOf('\\')); if (!GlobalStaticClass.Graphics_LocalizeAllImages(savepath)) { (new ErrorForm("Unable to Save some images", "There was an error saving 1 or more images. This may mean some of the image files were moved ")).ShowDialog(); return false; } if (!GlobalStaticClass.Functions_LocalizeAllFunctions(savepath)) { (new ErrorForm("Unable to Save some functions", "There was an error saving 1 or more functions. This may mean some of the function files were moved ")).ShowDialog(); return false; } if (!GlobalStaticClass.Fonts_LocalizeAllFonts(savepath)) { (new ErrorForm("Unable to Save some fonts", "There was an error saving 1 or more fonts. This may mean some of the font files were moved ")).ShowDialog(); return false; } (new FinishedSavingForm()).Show(); return true; } else { return false; } } #endregion #region List View Double Click Event private void LISTVIEW_AllXMLNodes_DoubleClick(object sender, EventArgs e) { if (LISTVIEW_AllXMLNodes.SelectedItems[0] == null) { return; } Console.WriteLine(LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString()); switch (LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToLower()) { #region Fusion Brain Instance case "fusion brain": { if (GlobalStaticClass._Global_List_Brains_ListItems.Count == 0) { (new ErrorForm("No Fusion Brains", "There are no Fusion Brains added. Please add a Fusion Brain instance.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Brains_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "fusion brain"; } break; #endregion #region Digital Output Instances case "digital outputs": { if (GlobalStaticClass._Global_List_DigitalOutputs_ListItems.Count == 0) { (new ErrorForm("No Digital Outputs", "There are no Digital Outputs added. Please add a Digital Outputs instance.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_DigitalOutputs_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "digital outputs"; } break; #endregion #region Analogue Input Instances case "analogue inputs": { if (GlobalStaticClass._Global_List_AnalogueInputs_ListItems.Count == 0) { (new ErrorForm("No Analogue Inputs", "There are no Analogue Inputs added. Please add an Analogue Input instance.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_AnalogueInputs_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "analogue inputs"; } break; #endregion #region Logging Instances case "logging": { if (GlobalStaticClass._Global_List_Logs_ListItems.Count == 0) { (new ErrorForm("No Logging Inputs", "There are no Logs added. Please add a Logging instance.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Logs_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "logging"; } break; #endregion #region Timers case "timers": { (new TimerSetupForm()).ShowDialog(); UpdateTextualAndList(); } break; #endregion #region Variable Instances case "variables": { if (GlobalStaticClass._Global_List_Variables_ListItems.Count == 0) { (new ErrorForm("No Variable Declarations", "There are no Variables added. Please add a Variable object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Variables_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "variables"; } break; #endregion #region Background Image Instances case "background images": { if (GlobalStaticClass._Global_List_Graphics_BackgroundImage.Count == 0) { (new ErrorForm("No Background Image Declarations", "There are no Background Images added. Please add a Background Image object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_BackgroundImage_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "background images"; } break; #endregion #region Display Button Instances case "display buttons": { if (GlobalStaticClass._Global_List_Graphics_DisplayButton.Count == 0) { (new ErrorForm("No Dispay Button Declarations", "There are no Display Buttons added. Please add a Display Button object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_DisplayButton_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "display buttons"; } break; #endregion #region Multi Image Instances case "multi images": { if (GlobalStaticClass._Global_List_Graphics_MultiImage.Count == 0) { (new ErrorForm("No Multi Image Declarations", "There are no Multi Images added. Please add a Multi Image object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_MultiImage_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "multi images"; } break; #endregion #region Static Image Instances case "static images": { if (GlobalStaticClass._Global_List_Graphics_StaticImage.Count == 0) { (new ErrorForm("No Static Image Declararations", "There are no Static Images added. Please add a Static Image object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_StaticImage_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "static images"; } break; #endregion #region Static Image Instances case "rotate images": { } break; #endregion #region Functions case "functions": { if (LogicModules._Global_FunctionsList.Count == 0) { (new ErrorForm("No Function Declarations", "There are no Functions added. Please add a Function object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Functions_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "functions"; } break; #endregion #region Fonts case "fonts": { if (GlobalStaticClass._Global_List_Graphics_Fonts.Count == 0) { (new ErrorForm("No Font Declarations", "There are no Fonts added. Please add a Font object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_Fonts_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "fonts"; } break; #endregion #region Text Labels case "text labels": { if (GlobalStaticClass._Global_List_Graphics_TextLabels.Count == 0) { (new ErrorForm("No Text Label Declarations", "There are no Text Labels added. Please add a Text Label object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_TextLabels_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "text labels"; } break; #endregion #region Graphs case "graphs": { if (GlobalStaticClass._Global_List_Graphics_Graphs.Count == 0) { (new ErrorForm("No Graph Declarations", "There are no Graphs added. Please add a Graph object.")).ShowDialog(); return; } LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.Add(GlobalStaticClass.ListViewItem_GoUpALevel); LISTVIEW_AllXMLNodes.Items.AddRange(GlobalStaticClass._Global_List_Graphics_Graph_ListItems.ToArray()); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "graphs"; } break; #endregion #region GO UP TO ROOT case "go up": { LISTVIEW_AllXMLNodes.Items.Clear(); LISTVIEW_AllXMLNodes.Items.AddRange(_LVI_AllInAList); LISTVIEW_AllXMLNodes.Update(); _LVI_CurrentType = "root"; } break; #endregion default: { Console.WriteLine("Current Type: " + _LVI_CurrentType); switch (_LVI_CurrentType) { #region Edit Fusion Brain Instance case "fusion brain": { for (int i = 0; i < GlobalStaticClass._Global_List_Brains.Count; i++) { if (GlobalStaticClass._Global_List_Brains[i]._humanName.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { BrainForm _tempBrainForm = new BrainForm(GlobalStaticClass._Global_List_Brains[i]._humanName, GlobalStaticClass._Global_List_Brains[i]._VIDPID, GlobalStaticClass._Global_List_Brains[i]._Version); if (_tempBrainForm.ShowDialog() == DialogResult.OK) { List _tempReturnedInfo = _tempBrainForm.GetTheBrainInformation(); if (_tempReturnedInfo == null) { return; } if (_tempReturnedInfo.Count == 2) { bool isUnique = true; for (int j = 0; j < GlobalStaticClass._Global_List_Brains.Count; j++) { if (i == j) { continue; } if (GlobalStaticClass._Global_List_Brains[j]._humanName.ToLower() == _tempReturnedInfo[0] || GlobalStaticClass._Global_List_Brains[j]._VIDPID.ToLower() == _tempReturnedInfo[1]) { isUnique = false; (new ErrorForm("Invalid Fusion Brain", "This is a duplicate of another already added Fusion Brain")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._Global_List_Brains[i]._humanName = _tempReturnedInfo[0]; GlobalStaticClass._Global_List_Brains[i]._VIDPID = _tempReturnedInfo[1]; } } UpdateTextualAndList(); } return; } } } return; #endregion #region Edit Digital Output Instance case "digital outputs": { for (int i = 0; i < GlobalStaticClass._Global_List_DigitalOutputs.Count; i++) { if (GlobalStaticClass._Global_List_DigitalOutputs[i].id.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddDigitialOutputForm _tempDOForm = new AddDigitialOutputForm(GlobalStaticClass._Global_List_DigitalOutputs[i].id, GlobalStaticClass._Global_List_DigitalOutputs[i].BrainID, GlobalStaticClass._Global_List_DigitalOutputs[i].Port, GlobalStaticClass._Global_List_DigitalOutputs[i].DefaultStateAsString()); if (_tempDOForm.ShowDialog() == DialogResult.OK) { List _tempReturned = _tempDOForm.GetDigitalOutputData(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 4) { bool isUnique = true; for (int j = 0; j < GlobalStaticClass._Global_List_DigitalOutputs.Count; j++) { if (i == j) { continue; } if (GlobalStaticClass._Global_List_DigitalOutputs[j].id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Digital Output", "This is a duplicate of another already added Digital Output")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._Global_List_DigitalOutputs[i].id = (string)_tempReturned[0]; GlobalStaticClass._Global_List_DigitalOutputs[i].Port = (int)_tempReturned[1]; GlobalStaticClass._Global_List_DigitalOutputs[i].BrainID = (string)_tempReturned[2]; GlobalStaticClass._Global_List_DigitalOutputs[i]._defaultState = GlobalStaticClass._Global_List_DigitalOutputs[i].DefaultStateAsBool((string)_tempReturned[3]); } UpdateTextualAndList(); } } return; } } } return; #endregion #region Edit Analogue Input Instance case "analogue inputs": { for (int i = 0; i < GlobalStaticClass._Global_List_AnalogueInputs.Count; i++) { if (GlobalStaticClass._Global_List_AnalogueInputs[i].id.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddAnalogueInputForm _tempAIForm = new AddAnalogueInputForm(GlobalStaticClass._Global_List_AnalogueInputs[i].id, GlobalStaticClass._Global_List_AnalogueInputs[i].BrainID, GlobalStaticClass._Global_List_AnalogueInputs[i].Port, GlobalStaticClass._Global_List_AnalogueInputs[i].AutoAverageAsString(), GlobalStaticClass._Global_List_AnalogueInputs[i]._historyKeeping); if (_tempAIForm.ShowDialog() == DialogResult.OK) { List _tempReturned = _tempAIForm.GetAnalogueInputDataBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 5) { bool isUnique = true; for (int j = 0; j < GlobalStaticClass._Global_List_AnalogueInputs.Count; j++) { if (i == j) { continue; } if (GlobalStaticClass._Global_List_AnalogueInputs[j].id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Analogue Input", "This is a duplicate of another already added Analogue Input")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._Global_List_AnalogueInputs[i].id = (string)_tempReturned[0]; GlobalStaticClass._Global_List_AnalogueInputs[i].Port = (int)_tempReturned[2]; GlobalStaticClass._Global_List_AnalogueInputs[i].BrainID = (string)_tempReturned[1]; GlobalStaticClass._Global_List_AnalogueInputs[i]._autoAverage = GlobalStaticClass._Global_List_AnalogueInputs[i].AutoAverageFromStringToBool((string)_tempReturned[3]); GlobalStaticClass._Global_List_AnalogueInputs[i]._historyKeeping = (int)_tempReturned[4]; } UpdateTextualAndList(); } } return; } } } return; #endregion #region Edit Logging Instance case "logging": { for (int i = 0; i < GlobalStaticClass._Global_List_Logs.Count; i++) { if (GlobalStaticClass._Global_List_Logs[i]._id.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddLoggingForm _tempLogForm = new AddLoggingForm(GlobalStaticClass._Global_List_Logs[i]._id, GlobalStaticClass._Global_List_Logs[i]._monitor_type, GlobalStaticClass._Global_List_Logs[i]._monitor_id, GlobalStaticClass._Global_List_Logs[i]._record_timer, GlobalStaticClass._Global_List_Logs[i]._record_object, GlobalStaticClass._Global_List_Logs[i].DefaultStateFromBoolToString(), GlobalStaticClass._Global_List_Logs[i].HoldOpenFromBoolToString(), GlobalStaticClass._Global_List_Logs[i]._store_before_dump.ToString(), GlobalStaticClass._Global_List_Logs[i]._data_name, GlobalStaticClass._Global_List_Logs[i]._file_name); if (_tempLogForm.ShowDialog() == DialogResult.OK) { List _tempReturned = _tempLogForm.GetTheLogDataBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 10) { bool isUnique = true; for (int j = 0; j < GlobalStaticClass._Global_List_Logs.Count; j++) { if (i == j) { continue; } if (GlobalStaticClass._Global_List_Logs[j]._id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Logging Instance", "This is a duplicate of another already added Logging Instance")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._Global_List_Logs[i]._id = (string)_tempReturned[0]; GlobalStaticClass._Global_List_Logs[i]._monitor_type = (string)_tempReturned[1]; GlobalStaticClass._Global_List_Logs[i]._monitor_id = (string)_tempReturned[2]; GlobalStaticClass._Global_List_Logs[i]._record_timer = (string)_tempReturned[3]; GlobalStaticClass._Global_List_Logs[i]._record_object = (string)_tempReturned[4]; GlobalStaticClass._Global_List_Logs[i]._default_state = GlobalStaticClass._Global_List_Logs[i].DefaultStateFromStringToBool((string)_tempReturned[5]); GlobalStaticClass._Global_List_Logs[i]._hold_stream_open = GlobalStaticClass._Global_List_Logs[i].HoldOpenFromStringToBool((string)_tempReturned[6]); GlobalStaticClass._Global_List_Logs[i]._data_name = (string)_tempReturned[8]; GlobalStaticClass._Global_List_Logs[i]._file_name = (string)_tempReturned[9]; GlobalStaticClass._Global_List_Logs[i]._store_before_dump = (int)_tempReturned[7]; } UpdateTextualAndList(); } } return; } } } return; #endregion #region Edit Variable Instance case "variables": { for (int i = 0; i < GlobalStaticClass._Global_List_Variables.Count; i++) { if (GlobalStaticClass._Global_List_Variables[i]._id.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddVariableForm _tempVarForm = new AddVariableForm(GlobalStaticClass._Global_List_Variables[i]._id, GlobalStaticClass._Global_List_Variables[i]._value); if (_tempVarForm.ShowDialog() == DialogResult.OK) { List _tempReturned = _tempVarForm.GetVariableInfoBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 2) { bool isUnique = true; for (int j = 0; j < GlobalStaticClass._Global_List_Variables.Count; j++) { if (i == j) { continue; } if (GlobalStaticClass._Global_List_Variables[j]._id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Variable Object", "This is a duplicate of another already added Object Instance")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._Global_List_Variables[i]._id = (string)_tempReturned[0]; GlobalStaticClass._Global_List_Variables[i]._value = (object)_tempReturned[1]; } UpdateTextualAndList(); } } return; } } } return; #endregion #region Edit Function Instance case "functions": { for (int i = 0; i < LogicModules._Global_FunctionsList.Count; i++) { if (LogicModules._Global_FunctionsList[i]._id.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AllFunctionsDirectoryWatcher.EnableRaisingEvents = false; (new CustomFunctionForm(LogicModules._Global_FunctionsList[i])).ShowDialog(); AllFunctionsDirectoryWatcher.EnableRaisingEvents = true; ReloadAllFunctions(); return; } } } return; #endregion #region Edit Font Instance case "fonts": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_Fonts.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_Fonts[i].font_name.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AllFontsDirectoryWatcher.EnableRaisingEvents = false; (new AddFontForm(GlobalStaticClass._Global_List_Graphics_Fonts[i])).ShowDialog(); AllFontsDirectoryWatcher.EnableRaisingEvents = true; ReloadAllFonts(); return; } } } return; #endregion #region Edit Text Label Instance case "text labels": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_TextLabels.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_TextLabels[i]._name.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddTextLabelForm _addTLF = new AddTextLabelForm(GlobalStaticClass._Global_List_Graphics_TextLabels[i]); if (_addTLF.ShowDialog() == DialogResult.OK) { bool isUnique = true; foreach (GlobalStaticClass.FusionFont_TextLabel _txt in GlobalStaticClass._Global_List_Graphics_TextLabels) { if (_txt != GlobalStaticClass._Global_List_Graphics_TextLabels[i] && _txt._name.ToLower() == _addTLF.CurrentTextLabel._name.ToLower()) { isUnique = false; break; } } if (!isUnique) { (new ErrorForm("Invalid Text Label Name", "The name of the text label instance is already in use. It must be unique.")).ShowDialog(); return; } GlobalStaticClass._Global_List_Graphics_TextLabels.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_TextLabels.Add(_addTLF.CurrentTextLabel); foreach (int j in _addTLF.CurrentTextLabel._pages) { Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); UpdateTextualAndList(); } return; } } } return; #endregion #region Edit Background Images case "background images": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_BackgroundImage.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_BackgroundImage[i]._page.ToString() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddBackgroundImageForm _tempForm = new AddBackgroundImageForm(GlobalStaticClass._Global_List_Graphics_BackgroundImage[i]); if (_tempForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_BackgroundImage.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_BackgroundImage.Add(_tempForm.CurrentBackgroundImage); GlobalStaticClass.GraphicsSort(); int j = _tempForm.CurrentBackgroundImage._page; Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } UpdateTextualAndList(); return; } } } return; #endregion #region Edit Display Buttons case "display buttons": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_DisplayButton.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_DisplayButton[i]._name.ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddDisplayButtonForm _tempForm = new AddDisplayButtonForm(GlobalStaticClass._Global_List_Graphics_DisplayButton[i]); if (_tempForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_DisplayButton.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_DisplayButton.Add(_tempForm.CurrentDisplayButton); GlobalStaticClass.GraphicsSort(); foreach (int j in _tempForm.CurrentDisplayButton._pages) { Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } UpdateTextualAndList(); return; } } } return; #endregion #region Edit Multi Images case "multi images": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_MultiImage.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_MultiImage[i]._name.ToString().ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddMultiImageForm _tempForm = new AddMultiImageForm(GlobalStaticClass._Global_List_Graphics_MultiImage[i]); if (_tempForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_MultiImage.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_MultiImage.Add(_tempForm.CurrentMultiImage); GlobalStaticClass.GraphicsSort(); foreach (int j in _tempForm.CurrentMultiImage._pages) { Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } UpdateTextualAndList(); return; } } } return; #endregion #region Edit Rotate Images case "rotate images": { } return; #endregion #region Edit Static Images case "static images": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_StaticImage.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_StaticImage[i]._name.ToString().ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddStaticImageForm _tempForm = new AddStaticImageForm(GlobalStaticClass._Global_List_Graphics_StaticImage[i]); if (_tempForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_StaticImage.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_StaticImage.Add(_tempForm.CurrentStaticImage); GlobalStaticClass.GraphicsSort(); foreach (int j in _tempForm.CurrentStaticImage._pages) { Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } UpdateTextualAndList(); return; } } } return; #endregion #region Edit Static Images case "graphs": { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_Graphs.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_Graphs[i]._name.ToString().ToLower() == LISTVIEW_AllXMLNodes.SelectedItems[0].Text.ToString().ToLower()) { AddGraphForm _tempForm = new AddGraphForm(GlobalStaticClass._Global_List_Graphics_Graphs[i]); if (_tempForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_Graphs.RemoveAt(i); GlobalStaticClass._Global_List_Graphics_Graphs.Add(_tempForm.CurrentGraph); GlobalStaticClass.GraphicsSort(); foreach (int j in _tempForm.CurrentGraph._pages) { Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, j, null); foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == j) { GlobalStaticClass._Global_List_Graphics_PageList.Remove(_page); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, j)); break; } } } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } UpdateTextualAndList(); return; } } } return; #endregion default: return; } } } } #endregion #region Add a Variable private void TSB_Variable_Click(object sender, EventArgs e) { AddVariableForm _tempVarForm = new AddVariableForm(); if (_tempVarForm.ShowDialog() == DialogResult.OK) { List _tempReturned = _tempVarForm.GetVariableInfoBack(); if (_tempReturned == null) { return; } if (_tempReturned.Count == 2) { bool isUnique = true; foreach (GlobalStaticClass._GlobalVariableClass _searchVariableClasses in GlobalStaticClass._Global_List_Variables) { if (_searchVariableClasses._id.ToLower() == ((string)_tempReturned[0]).ToLower()) { isUnique = false; (new ErrorForm("Invalid Variable Instance", "This is a duplicate of another already added Variable Object")).ShowDialog(); return; } } if (isUnique) { GlobalStaticClass._GlobalVariableClass _tempNewVariable = new GlobalStaticClass._GlobalVariableClass((string)_tempReturned[0], (object)_tempReturned[1]); } UpdateTextualAndList(); } } return; } #endregion #region Delete by Drag N' Drop private void TS_MAINTOP_DragDrop(object sender, DragEventArgs e) { Console.WriteLine("entering"); this.Cursor = System.Windows.Forms.Cursors.Arrow; ListViewItem temp_LVI = (ListViewItem) e.Data.GetData(DataFormats.Serializable); Point temp_Cursor = new Point(e.X - this.Location.X, e.Y - this.Location.Y); ToolStripItem temp_TSI = TS_MAINTOP.GetItemAt(temp_Cursor); if(temp_LVI == null || temp_TSI == null) { return; } if (TSB_Delete == temp_TSI) { if (temp_LVI == GlobalStaticClass.ListViewItem_GoUpALevel) { return; } if ((new ConfirmDeleteForm(temp_LVI.Text)).ShowDialog() == DialogResult.Cancel) { return; } switch (_LVI_CurrentType) { case "fusion brain": { for (int i = 0; i < GlobalStaticClass._Global_List_Brains.Count; i++) { if (GlobalStaticClass._Global_List_Brains[i]._humanName == temp_LVI.Text) { GlobalStaticClass._Global_List_Brains.Remove(GlobalStaticClass._Global_List_Brains[i]); UpdateTextualAndList(_LVI_CurrentType); return; } } } return; case "digital outputs": { for (int i = 0; i < GlobalStaticClass._Global_List_DigitalOutputs.Count; i++) { if (GlobalStaticClass._Global_List_DigitalOutputs[i].id == temp_LVI.Text) { GlobalStaticClass._Global_List_DigitalOutputs.Remove(GlobalStaticClass._Global_List_DigitalOutputs[i]); UpdateTextualAndList(_LVI_CurrentType); return; } } } return; case "analogue inputs": { for (int i = 0; i < GlobalStaticClass._Global_List_AnalogueInputs.Count; i++) { if (GlobalStaticClass._Global_List_AnalogueInputs[i].id == temp_LVI.Text) { GlobalStaticClass._Global_List_AnalogueInputs.Remove(GlobalStaticClass._Global_List_AnalogueInputs[i]); UpdateTextualAndList(_LVI_CurrentType); return; } } } return; case "logging": { for (int i = 0; i < GlobalStaticClass._Global_List_Logs.Count; i++) { if (GlobalStaticClass._Global_List_Logs[i]._id == temp_LVI.Text) { GlobalStaticClass._Global_List_Logs.Remove(GlobalStaticClass._Global_List_Logs[i]); UpdateTextualAndList(_LVI_CurrentType); return; } } } return; case "variables": { for (int i = 0; i < GlobalStaticClass._Global_List_Variables.Count; i++) { if (GlobalStaticClass._Global_List_Variables[i]._id == temp_LVI.Text) { GlobalStaticClass._Global_List_Variables.Remove(GlobalStaticClass._Global_List_Variables[i]); UpdateTextualAndList(_LVI_CurrentType); return; } } } return; default: return; } } } private void LISTVIEW_AllXMLNodes_ItemDrag(object sender, ItemDragEventArgs e) { switch (_LVI_CurrentType) { case "fusion brain": case "digital outputs": case "analogue inputs": case "logging": case "variables": LISTVIEW_AllXMLNodes.DoDragDrop(((ListView)sender).SelectedItems[0], DragDropEffects.Move); break; case "root": return; default: break; } } private void TS_MAINTOP_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.None; if (e.Data.GetDataPresent(DataFormats.Serializable)) { object temp_o = e.Data.GetData(DataFormats.Serializable); if (temp_o.GetType() == typeof(ListViewItem)) { e.Effect = DragDropEffects.Move; } } } #endregion #region Main Form Closing private void MainMDXConfigForm_FormClosing(object sender, FormClosingEventArgs e) { string _new = "", _old = ""; if (MYBUFFA_OLD != null && MYBUFFA_OLD.Contains(" last_modified=\"")) { _new = MYBUFFA.Substring(0, MYBUFFA.IndexOf(" last_modified=\"")) + MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); _old = MYBUFFA_OLD.Substring(0, MYBUFFA_OLD.IndexOf(" last_modified=\"")) + MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); } if (_new != _old || _old == "") { DialogResult DR = (new ConfirmDialogForm("Save Before Close?", "Save Before Close", "Would you like to save your current configuration before exiting?")).ShowDialog(); if (DR == DialogResult.OK) { if (!SaveConfigurationFile()) { e.Cancel = true; } } else if (DR == DialogResult.Abort) { } else { e.Cancel = true; } } } #endregion #region Function Icon Clicked private void TSB_Function_Click(object sender, EventArgs e) { AllFunctionsDirectoryWatcher.EnableRaisingEvents = false; (new CustomFunctionForm()).ShowDialog(); AllFunctionsDirectoryWatcher.EnableRaisingEvents = true; ReloadAllFunctions(); } #endregion #region Reload Already Made Functions void AllFunctionsDirectoryWatcher_ChangedOrCreated(object sender, FileSystemEventArgs e) { ReloadAllFunctions(); } public void ReloadAllFunctions() { LogicModules.ReadInAllFunctions(); GlobalStaticClass._Global_List_Functions_ListItems.Clear(); foreach (LogicModules.PsuedoFunctionMDX _psuedo in LogicModules._Global_FunctionsList) { GlobalStaticClass._Global_List_Functions_ListItems.Add(new ListViewItem(_psuedo._id, "FunctionIcon.png")); } UpdateTextualAndList(); } #endregion #region Reload Already Made Fonts void AllFontsDirectoryWatcher_ChangedOrCreated(object sender, FileSystemEventArgs e) { ReloadAllFonts(); } public void ReloadAllFonts() { GlobalStaticClass.Fonts_LoadAllFontFiles(); GlobalStaticClass._Global_List_Graphics_Fonts_ListItems.Clear(); foreach (GlobalStaticClass.PseudoFusionFont _psuedo in GlobalStaticClass._Global_List_Graphics_Fonts) { GlobalStaticClass._Global_List_Graphics_Fonts_ListItems.Add(new ListViewItem(_psuedo.font_name, "FontIcon.png")); } UpdateTextualAndList(); } #endregion #region Logic Button Clicked private void TSB_LogicAdd_Click(object sender, EventArgs e) { CustomFunctionForm _tempCFF = new CustomFunctionForm(true); _tempCFF.ShowDialog(); DialogResult _DR = _tempCFF.DialogResult; if (_DR == DialogResult.OK) { Logic_SetupNewRootNode(_tempCFF._CurrentFunction, _tempCFF.Draw2Bitmap); } } #endregion #region Setup New Root Node public void Logic_SetupNewRootNode(LogicModules.FunctionMDX _tempReadInFunction, Bitmap _tempReadInImage) { Logic_SetupNewRootNode(_tempReadInFunction, _tempReadInImage, true); } public void Logic_SetupNewRootNode(LogicModules.FunctionMDX _tempReadInFunction, Bitmap _tempReadInImage, bool UpdateAfterwards) { foreach (GlobalStaticClass._GlobalFunctionsClass _glFC in GlobalStaticClass._Global_List_Functions) { if (_glFC._function._FunctionID.ToLower() == _tempReadInFunction._FunctionID.ToLower()) { DialogResult _DR_temp = (new ConfirmDialogForm("Overwrite If Then Statement", "Overwrite Current Statement?", "There is already an If/Then statement added with this name [" + _tempReadInFunction._FunctionID + "]. Would you like to overwrite it?")).ShowDialog(); if (_DR_temp == DialogResult.OK) { GlobalStaticClass._Global_List_Functions.Remove(_glFC); foreach (TabPage _tab in TABCONTROL_EACHIF.TabPages) { if (_tab.Text.ToLower() == _tempReadInFunction._FunctionID.ToLower()) { TABCONTROL_EACHIF.TabPages.Remove(_tab); } } break; } else if (_DR_temp == DialogResult.Cancel) { return; } else { return; } } } int min_x = _tempReadInImage.Width, min_y = _tempReadInImage.Height, max_x = 0, max_y = 0; foreach (LogicModules.Module _modSearch in _tempReadInFunction._Modules) { if (_modSearch.ModuleBounds.Left < min_x) { min_x = _modSearch.ModuleBounds.Left; } if (_modSearch.ModuleBounds.Right > max_x) { max_x = _modSearch.ModuleBounds.Right; } if (_modSearch.ModuleBounds.Top < min_y) { min_y = _modSearch.ModuleBounds.Top; } if (_modSearch.ModuleBounds.Bottom > max_y) { max_y = _modSearch.ModuleBounds.Bottom; } } min_x -= 15; if (min_x < 0) { min_x = 0; } min_y -= 15; if (min_y < 0) { min_y = 0; } max_x += 15; if (max_x > _tempReadInImage.Width) { max_x = _tempReadInImage.Width; } max_y += 15; if (max_y > _tempReadInImage.Height) { max_y = _tempReadInImage.Height; } Bitmap _tempScaledBitmap = new Bitmap(max_x - min_x, max_y - min_y); Graphics _graphics = Graphics.FromImage(_tempScaledBitmap); _graphics.DrawImage(_tempReadInImage, 0, 0, new Rectangle(min_x, min_y, max_x - min_x, max_y - min_y), GraphicsUnit.Pixel); _tempReadInImage = _tempScaledBitmap; GlobalStaticClass._GlobalFunctionsClass _tempGFC = new GlobalStaticClass._GlobalFunctionsClass(_tempReadInFunction, _tempReadInImage); _tempGFC._MyTabPage.DoubleClick += new EventHandler(TABCONTROL_EACHIF_DoubleClick); _tempGFC._function_PictureBox.Location = new Point(12, 12); _tempGFC._function_PictureBox.Size = new Size(TABCONTROL_EACHIF.Width - 12 - 12 - 6, (TABCONTROL_EACHIF.Height / 2) - 12 - 6); _tempGFC._thenList_ListBox.Location = new Point(12, (TABCONTROL_EACHIF.Height / 2) + 6); _tempGFC._thenList_ListBox.Size = new Size(TABCONTROL_EACHIF.Width - 12 - 12 - 6, TABCONTROL_EACHIF.Height - 12 - _tempGFC._thenList_ListBox.Font.Height); _tempGFC.PopulateThenDoList(); TABCONTROL_EACHIF.TabPages.Add(_tempGFC._MyTabPage); TABCONTROL_EACHIF.Update(); if (UpdateAfterwards) { UpdateTextualAndList(); } } #endregion #region Resize Tab Control Dock to Fit Parent Area private void SPLIT_DESIGNER_Panel2_SizeChanged(object sender, EventArgs e) { if (TS_LogicToolBar.Visible == true) { if (SPLIT_DESIGNER.Panel2.Width - 5 > 5 && SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5 > 5) { TABCONTROL_EACHIF.MinimumSize = new Size(SPLIT_DESIGNER.Panel2.Width, SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5); TABCONTROL_EACHIF.MaximumSize = new Size(SPLIT_DESIGNER.Panel2.Width, SPLIT_DESIGNER.Panel2.Height - TS_LogicToolBar.Height - 5); TABCONTROL_EACHIF.Dock = DockStyle.Bottom; if (TABCONTROL_EACHIF.TabCount > 0) { if (TABCONTROL_EACHIF.SelectedTab != null) { foreach (GlobalStaticClass._GlobalFunctionsClass _tempGFC in GlobalStaticClass._Global_List_Functions) { if (_tempGFC._MyTabPage == TABCONTROL_EACHIF.SelectedTab) { _tempGFC._function_PictureBox.Location = new Point(12, 12); _tempGFC._function_PictureBox.Size = new Size(TABCONTROL_EACHIF.Width - 12 - 12 - 6, (TABCONTROL_EACHIF.Height / 2) - 12 - 6); _tempGFC._thenList_ListBox.Location = new Point(12, (TABCONTROL_EACHIF.Height / 2) + 6); _tempGFC._thenList_ListBox.Size = new Size(TABCONTROL_EACHIF.Width - 12 - 12 - 6, TABCONTROL_EACHIF.Height - 12 - _tempGFC._thenList_ListBox.Font.Height); break; } } } } SPLIT_DESIGNER.Panel2.Update(); } } else if(TS_GraphicsToolBar.Visible == true) { if (SPLIT_DESIGNER.Panel2.Width - 5 > 5 && SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5 > 5) { PICTBOX_GRAPHICS.MinimumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.MaximumSize = new Size(SPLIT_DESIGNER.Panel2.Width - 5, SPLIT_DESIGNER.Panel2.Height - TS_GraphicsToolBar.Height - 5); PICTBOX_GRAPHICS.Dock = DockStyle.Bottom; SPLIT_DESIGNER.Panel2.Update(); } } } #endregion #region Double Click Tab Area to Edit Root Functions private void TABCONTROL_EACHIF_DoubleClick(object sender, EventArgs e) { Logic_EditLogicStatement(); } #endregion #region Delete Logic Statement private void TSB_LogicDelete_Click(object sender, EventArgs e) { Logic_DeleteLogicStatement(); } public void Logic_DeleteLogicStatement() { if (TABCONTROL_EACHIF.SelectedTab != null) { foreach (GlobalStaticClass._GlobalFunctionsClass _tempGlobalFuncClass in GlobalStaticClass._Global_List_Functions) { if (_tempGlobalFuncClass._function._FunctionID.ToLower() == TABCONTROL_EACHIF.SelectedTab.Text.ToLower()) { if ((new ConfirmDeleteForm(_tempGlobalFuncClass._function._FunctionID)).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Functions.Remove(_tempGlobalFuncClass); foreach (TabPage _tab in TABCONTROL_EACHIF.TabPages) { if (_tab.Text.ToLower() == _tempGlobalFuncClass._function._FunctionID.ToLower()) { TABCONTROL_EACHIF.TabPages.Remove(_tab); return; } } } } } } } #endregion #region Edit Logic Statement private void TSB_LogicEdit_Click(object sender, EventArgs e) { Logic_EditLogicStatement(); } public void Logic_EditLogicStatement() { if (TABCONTROL_EACHIF.SelectedTab != null) { foreach (GlobalStaticClass._GlobalFunctionsClass _tempGlobalFuncClass in GlobalStaticClass._Global_List_Functions) { if (_tempGlobalFuncClass._function._FunctionID.ToLower() == TABCONTROL_EACHIF.SelectedTab.Text.ToLower()) { string oldName = _tempGlobalFuncClass._function._FunctionID; CustomFunctionForm _tempCFF = new CustomFunctionForm(_tempGlobalFuncClass); DialogResult DR = _tempCFF.ShowDialog(); if (DR == DialogResult.OK) { GlobalStaticClass._Global_List_Functions.Remove(_tempGlobalFuncClass); foreach (TabPage _tab in TABCONTROL_EACHIF.TabPages) { if (_tab.Text.ToLower() == oldName.ToLower()) { TABCONTROL_EACHIF.TabPages.Remove(_tab); } } Logic_SetupNewRootNode(_tempCFF._CurrentFunction, _tempCFF.Draw2Bitmap); TABCONTROL_EACHIF.SelectedIndex = TABCONTROL_EACHIF.TabPages.Count - 1; } return; } } } } #endregion #region Update Graphics Area private void UpdateGraphicsPageAreaAndEnableOrDisableButtons() { TSL_PAGEOFPAGE.Text = ((int)(CurrentGraphicPage + 1)).ToString() + "/" + GlobalStaticClass._Global_List_Graphics_PageList.Count.ToString(); bool OtherGraphicButtonsEnableState = (GlobalStaticClass._Global_List_Graphics_PageList.Count > 0); TSB_GRAPHIC_DELETE.Enabled = OtherGraphicButtonsEnableState; TSB_GRAPHICEDITOR.Enabled = OtherGraphicButtonsEnableState; TSB_PreviousPage.Enabled = OtherGraphicButtonsEnableState; TSB_NextPage.Enabled = OtherGraphicButtonsEnableState; if (CurrentGraphicPage >= 0) { bool wasFound = false; foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == CurrentGraphicPage) { wasFound = true; Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, _page.Page, null); _page.PreviewImage = _tempBitmap; PICTBOX_GRAPHICS.BackgroundImage = _page.PreviewImage; } } if(!wasFound) { PICTBOX_GRAPHICS.BackgroundImage = new Bitmap(PICTBOX_GRAPHICS.Width, PICTBOX_GRAPHICS.Height); } } else { PICTBOX_GRAPHICS.BackgroundImage = new Bitmap(PICTBOX_GRAPHICS.Width, PICTBOX_GRAPHICS.Height); } PICTBOX_GRAPHICS.Update(); } #endregion #region Graphics - Add Page private void TSB_GRAPHIC_ADDPAGE_Click(object sender, EventArgs e) { if (GlobalStaticClass._Global_List_Graphics_PageList.Count == 0) { CurrentGraphicPage = 0; } GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(global::FCC_Uber_MDX_Configurator.Properties.Resources.NoPhotoImage, GlobalStaticClass._Global_List_Graphics_PageList.Count)); UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } #endregion #region Graphics - Edit private void TSB_GRAPHICEDITOR_Click(object sender, EventArgs e) { GraphicLayoutEditorForm _tempGLEF = new GraphicLayoutEditorForm(CurrentGraphicPage); if (_tempGLEF.ShowDialog() == DialogResult.OK) { bool wasFound = false; foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page == CurrentGraphicPage) { wasFound = true; _page.PreviewImage = (Bitmap)_tempGLEF.MAIN_PANEL_Bitmap.Clone(); break; } } if (!wasFound) { } UpdateGraphicsPageAreaAndEnableOrDisableButtons(); UpdateTextualAndList(); } } #endregion #region Graphics - Delete private void TSB_GRAPHIC_DELETE_Click(object sender, EventArgs e) { if ((new ConfirmDeleteForm("Current page (" + ((int)(CurrentGraphicPage + 1)).ToString() + ")")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_PageList.RemoveAt(CurrentGraphicPage); List _back_RemoveList = new List(); foreach (GlobalStaticClass.FusionImage_BackgroundImage _back in GlobalStaticClass._Global_List_Graphics_BackgroundImage) { if (_back._page == CurrentGraphicPage) { _back_RemoveList.Add(_back); } else if (_back._page > CurrentGraphicPage) { _back._page--; } } foreach (GlobalStaticClass.FusionImage_BackgroundImage _backRemove in _back_RemoveList) { GlobalStaticClass._Global_List_Graphics_BackgroundImage.Remove(_backRemove); } List _static_RemoveList = new List(); foreach (GlobalStaticClass.FusionImage_StaticImage _static in GlobalStaticClass._Global_List_Graphics_StaticImage) { for (int i = 0; i < _static._pages.Count; i++) { if (_static._pages[i] == CurrentGraphicPage) { _static._pages.RemoveAt(i); i--; } else if (_static._pages[i] > CurrentGraphicPage) { _static._pages[i]--; } } if (_static._pages.Count == 0) { _static_RemoveList.Add(_static); } } foreach (GlobalStaticClass.FusionImage_StaticImage _staticRemove in _static_RemoveList) { GlobalStaticClass._Global_List_Graphics_StaticImage.Remove(_staticRemove); } List _disp_RemoveList = new List(); foreach (GlobalStaticClass.FusionImage_DisplayButton _disp in GlobalStaticClass._Global_List_Graphics_DisplayButton) { for (int i = 0; i < _disp._pages.Count; i++) { if (_disp._pages[i] == CurrentGraphicPage) { _disp._pages.RemoveAt(i); i--; } else if (_disp._pages[i] > CurrentGraphicPage) { _disp._pages[i]--; } } if (_disp._pages.Count == 0) { _disp_RemoveList.Add(_disp); } } foreach (GlobalStaticClass.FusionImage_DisplayButton _disp in _disp_RemoveList) { GlobalStaticClass._Global_List_Graphics_DisplayButton.Remove(_disp); } foreach (GlobalStaticClass.GraphicsPage _page in GlobalStaticClass._Global_List_Graphics_PageList) { if (_page.Page > CurrentGraphicPage) { _page.Page--; } } if (GlobalStaticClass._Global_List_Graphics_PageList.Count == 0) { CurrentGraphicPage = -1; } else { if (CurrentGraphicPage >= GlobalStaticClass._Global_List_Graphics_PageList.Count) { CurrentGraphicPage = GlobalStaticClass._Global_List_Graphics_PageList.Count - 1; } } GlobalStaticClass.GraphicsSort(); UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } } #endregion #region Graphics - Previous Page private void TSB_PreviousPage_Click(object sender, EventArgs e) { if (CurrentGraphicPage > 0) { CurrentGraphicPage--; UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } } #endregion #region Graphics - Next Page private void TSB_NextPage_Click(object sender, EventArgs e) { if (CurrentGraphicPage < GlobalStaticClass._Global_List_Graphics_PageList.Count - 1) { CurrentGraphicPage++; UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } } #endregion #region Open File Click private void TSB_OpenFile_Click(object sender, EventArgs e) { string _new = "", _old = ""; if (MYBUFFA_OLD != "" && MYBUFFA_OLD.Contains(" last_modified=\"")) { _new = MYBUFFA.Substring(0, MYBUFFA.IndexOf(" last_modified=\"")) + MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); _old = MYBUFFA_OLD.Substring(0, MYBUFFA_OLD.IndexOf(" last_modified=\"")) + MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); } if (_new != _old) { switch ((new ConfirmDialogForm("Save Work", "Save Current Configuration?", "Would you like to save the current configuration file?")).ShowDialog()) { case DialogResult.OK: SaveConfigurationFile(); break; case DialogResult.Cancel: return; } } OpenConfigurationFile(false, null); } #endregion #region Clear All Variables to Default Values public void ClearEverything() { _LVI_CurrentType = "root"; CurrentGraphicPage = -1; TABCONTROL_EACHIF.TabPages.Clear(); MYBUFFA = ""; MYBUFFA_OLD = ""; ClearEverythingStatic(); } public static void ClearEverythingStatic() { GlobalStaticClass._GlobalPropertiesClass._author = ""; GlobalStaticClass._GlobalPropertiesClass._CreatedDate = DateTime.Now; GlobalStaticClass._GlobalPropertiesClass._LastModifiedDate = DateTime.Now; GlobalStaticClass._GlobalPropertiesClass._versionRequired = "3.0.0.0"; GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth = 800; GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight = 600; GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtWidth = 800; GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtHeight = 600; GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.Sizable; GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToSystemTray = true; GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInSystemTray = false; GlobalStaticClass._Global_List_Graphics_PageList = new List(); GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images = new List(); GlobalStaticClass._Global_List_AllModuleBounds = new List(); GlobalStaticClass._Global_List_Graphics_BackgroundImage = new List(); GlobalStaticClass._Global_List_Graphics_BackgroundImage_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_StaticImage = new List(); GlobalStaticClass._Global_List_Graphics_StaticImage_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_DisplayButton = new List(); GlobalStaticClass._Global_List_Graphics_DisplayButton_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_MultiImage = new List(); GlobalStaticClass._Global_List_Graphics_MultiImage_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_TextLabels = new List(); GlobalStaticClass._Global_List_Graphics_TextLabels_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_VariableLocationImage = new List(); GlobalStaticClass._Global_List_Graphics_VariableLocationImage_ListItems = new List(); GlobalStaticClass._Global_List_Graphics_Graphs = new List(); GlobalStaticClass._Global_List_Graphics_Graph_ListItems = new List(); GlobalStaticClass._GlobalTimerClass._timer_Output = 100; GlobalStaticClass._GlobalTimerClass._timer_Input = 75; GlobalStaticClass._GlobalTimerClass._timer_Logic = 50; GlobalStaticClass._GlobalTimerClass._timer_GUI = 50; GlobalStaticClass._Global_List_Brains = new List(); GlobalStaticClass._Global_List_Brains_ListItems = new List(); GlobalStaticClass._Global_List_DigitalOutputs = new List(); GlobalStaticClass._Global_List_DigitalOutputs_ListItems = new List(); GlobalStaticClass._Global_List_AnalogueInputs = new List(); GlobalStaticClass._Global_List_AnalogueInputs_ListItems = new List(); GlobalStaticClass._Global_List_Variables = new List(); GlobalStaticClass._Global_List_Variables_ListItems = new List(); GlobalStaticClass._Global_List_Logs = new List(); GlobalStaticClass._Global_List_Logs_ListItems = new List(); GlobalStaticClass._Global_List_Functions = new List(); GlobalStaticClass._Global_List_AllModuleBounds = new List(); GlobalStaticClass._Global_List_Functions = new List(); GlobalStaticClass._Global_List_Functions_ListItems = new List(); GlobalStaticClass._Global_List_Functions_TSMenuItems = new List(); GlobalStaticClass.RemoteControlProperties.enabled = false; GlobalStaticClass.RemoteControlProperties.port = 4242; GlobalStaticClass.RemoteControlProperties.userName = "default"; GlobalStaticClass.Debug_MasterEnable = false; GlobalStaticClass.Debug_IfThenWindow = false; GlobalStaticClass.Debug_SpeechWindow = false; GlobalStaticClass.Debug_VariableWindow = false; GlobalStaticClass.Debug_VirtualBrainList = new List(); } #endregion #region Open Configuration File public bool OpenConfigurationFile(bool suppressDialog, string file2open) { System.Threading.Thread _BUSYTHREAD; try { string xmlString = ""; string openDirectory = ""; string openPath = ""; List AllErrors = new List(); List AllPsuedoBindings = new List(); bool noErrors = true; BusyDoingCrapForm _BUSYFORM = new BusyDoingCrapForm(global::FCC_Uber_MDX_Configurator.Properties.Resources.OpenIcon, -1); #region Open Actual File and Stream in Contents if (suppressDialog || OpenConfigDialog.ShowDialog() == DialogResult.OK) { ClearEverything(); if (suppressDialog) { openPath = file2open; if (!File.Exists(file2open)) { (new ErrorForm("File not Found", "The requested file was not found, and cannot be opened: \r\n" + file2open)).ShowDialog(); return false; } } else { openPath = OpenConfigDialog.FileName; } openDirectory = openPath.Substring(0, openPath.LastIndexOf('\\')) + "\\"; if (File.Exists(openPath)) { try { FileStream _fs1 = new FileStream(openPath, FileMode.Open, FileAccess.Read); StreamReader _sr1 = new StreamReader(_fs1); xmlString = _sr1.ReadToEnd(); _sr1.Close(); _fs1.Close(); } catch (Exception e2) { (new ErrorForm("Unexpected Error", "There was an error opening the configuration file\r\n" + e2.ToString())).ShowDialog(); return false; } } else { (new ErrorForm("File Not Found", "Cannot open configuartion file as it was not found")).ShowDialog(); return false; } } if (xmlString == "") { (new ErrorForm("File Empty", "The configuration file is empty. Aborting Open function.")).ShowDialog(); return false; } #endregion try { _BUSYFORM.Show(); _BUSYFORM.TopMost = true; this.Cursor = Cursors.WaitCursor; #region Load XML from string to XML Nodes and Evaluate Root Node XmlDocument _doc = new XmlDocument(); try { _doc.LoadXml(xmlString); } catch (XmlException xml_error1) { (new ErrorForm("XML Parse Error", "There was an error parsing the string contents of the file to understandable XML.\r\n" + xml_error1.ToString())).ShowDialog(); GetRidOfBusyForm(_BUSYFORM); return false; } catch (Exception xml_error2) { (new ErrorForm("XML Parse Error", "There was an error parsing the string contents of the file to understandable XML.\r\n" + xml_error2.ToString())).ShowDialog(); GetRidOfBusyForm(_BUSYFORM); return false; } XmlNode _root = _doc.SelectSingleNode("FusionControlCentreConfiguration"); foreach (XmlAttribute _rootAttribute in _root.Attributes) { _BUSYFORM.UpdateBar(); switch (_rootAttribute.Name.ToLower()) { case "version": { GlobalStaticClass._GlobalPropertiesClass._versionRequired = _rootAttribute.Value; break; } case "author": { GlobalStaticClass._GlobalPropertiesClass._author = _rootAttribute.Value; break; } case "date_created": { if (!DateTime.TryParse(_rootAttribute.Value, out GlobalStaticClass._GlobalPropertiesClass._CreatedDate)) { if (_rootAttribute.Value.Contains(" at ")) { try { string _tempDT = _rootAttribute.Value.Substring(0, _rootAttribute.Value.IndexOf(" at ")) + " " + _rootAttribute.Value.Substring(_rootAttribute.Value.IndexOf(" at ") + " at ".Length); if (!DateTime.TryParse(_tempDT, out GlobalStaticClass._GlobalPropertiesClass._CreatedDate)) { AllErrors.Add("Unable to parse the date the configuration file was created"); } } catch (Exception e) { AllErrors.Add("Unhandled error in Create Time: " + e.ToString()); } } } break; } case "last_modified": { if (!DateTime.TryParse(_rootAttribute.Value, out GlobalStaticClass._GlobalPropertiesClass._LastModifiedDate)) { if (_rootAttribute.Value.Contains(" at ")) { try { string _tempDT = _rootAttribute.Value.Substring(0, _rootAttribute.Value.IndexOf(" at ")) + " " + _rootAttribute.Value.Substring(_rootAttribute.Value.IndexOf(" at ") + " at ".Length); if (!DateTime.TryParse(_tempDT, out GlobalStaticClass._GlobalPropertiesClass._LastModifiedDate)) { AllErrors.Add("Unable to parse the date the configuration file was last modified"); } } catch (Exception e) { AllErrors.Add("Unhandled error in Last Modified Time: " + e.ToString()); } } } break; } } } if (GlobalStaticClass._GlobalPropertiesClass._author == "") { GlobalStaticClass._GlobalPropertiesClass._author = "Me"; } #endregion #region Read in and Evaluate Configuration Nodes foreach (XmlNode subTopConfigNode in _root) { _BUSYFORM.UpdateBar(); #region Required Other Files if (subTopConfigNode.Name.ToLower() == "require") { //Other files to read in XmlNodeList RequiredFunctionsNode = subTopConfigNode.ChildNodes; foreach (XmlNode isRequiredNode in RequiredFunctionsNode) { _BUSYFORM.UpdateBar(); #region External Function if (isRequiredNode.Name.ToLower() == "function") { //External Function XmlAttributeCollection extFunctionAttributes = isRequiredNode.Attributes; string readInFunction = ""; string readInFunctionName = ""; for (int func_i = 0; func_i < extFunctionAttributes.Count; func_i++) { if (extFunctionAttributes[func_i].Name.ToLower() == "file") { string file2read = extFunctionAttributes[func_i].Value; string[] file2read_onlyDaFileName_Array = (file2read.Split(new char[] { '\\' })); string file2read_onlyDaFileName = file2read_onlyDaFileName_Array[file2read_onlyDaFileName_Array.Length - 1]; if (File.Exists(openDirectory + file2read + ".xml")) { bool copiedOK = true; if (File.Exists(GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read_onlyDaFileName + ".xml")) { try { //FileInfo _fi_Configs = new FileInfo(GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read + ".xml"); //FileInfo _fi_Reference = new FileInfo(openDirectory + file2read + ".xml"); bool nEstPasMeme = GlobalStaticClass.FileCompare(GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read_onlyDaFileName + ".xml", openDirectory + file2read + ".xml"); if (!nEstPasMeme) { if ((new ConfirmDialogForm("Confirm Overwrite?", "Confirm File Overwrite", "The function " + file2read + " referenced by the configuration file differs from the Configurator's copy of this function. " + "Overwrite the Configurator's file with this different file?")).ShowDialog() == DialogResult.OK) { File.Copy(openDirectory + file2read + ".xml", GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read + ".xml", true); if (File.Exists(openDirectory + file2read + ".designer")) { File.Copy(openDirectory + file2read + ".designer", GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read + ".designer", true); } } } } catch (PathTooLongException) { AllErrors.Add("The path is too long to open the function with the ID of " + file2read_onlyDaFileName_Array + ". Maximum path length is 260 characters including function id."); copiedOK = false; } catch (Exception e) { AllErrors.Add("Unknown error when reading function: " + e.ToString()); copiedOK = false; } } else { copiedOK = false; } if (!copiedOK) { try { File.Copy(openDirectory + file2read + ".xml", GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read + ".xml"); if (File.Exists(openDirectory + file2read + ".designer")) { File.Copy(openDirectory + file2read + ".designer", GlobalStaticClass.FUNCTION_DIRECTORY + "\\" + file2read + ".designer", false); } } catch (PathTooLongException) { AllErrors.Add("The path is too long to open the function with the ID of " + file2read_onlyDaFileName_Array + ". Maximum path length is 260 characters including function id."); } catch (Exception e) { AllErrors.Add("Unknown error when reading function: " + e.ToString()); } } } else { (new ErrorForm("Referenced File Not Found", "An External Function referenced in the configuration file cannot be found.\r\n" + "Needed File: \\" + file2read + ".xml", true)).ShowDialog(); GetRidOfBusyForm(_BUSYFORM); return false; } break; } } } #endregion #region Fusion Font else if (isRequiredNode.Name.ToLower() == "font") { string temp_name = ""; float temp_size = -1.0f; string temp_configpath = ""; foreach (XmlAttribute FontAttribute in isRequiredNode.Attributes) { if (FontAttribute.Name.ToLower() == "name") { temp_name = FontAttribute.Value.ToLower(); } else if (FontAttribute.Name.ToLower() == "originalsize") { float.TryParse(FontAttribute.Value.ToLower(), out temp_size); } else if (FontAttribute.Name.ToLower() == "font_config") { temp_configpath = openDirectory + FontAttribute.Value.ToLower(); } } string _fileNameOnly = GlobalStaticClass.PseudoFusionFont.PasPrefix(temp_configpath); bool _needToCopyFont = false; if (File.Exists(GlobalStaticClass.FONT_DIRECTORY + "\\" + _fileNameOnly)) { if (!GlobalStaticClass.FileCompare(GlobalStaticClass.FONT_DIRECTORY + "\\" + _fileNameOnly, temp_configpath)) { if ((new ConfirmDialogForm("Confirm Overwrite?", "Confirm File Overwrite", "The font " + temp_name + " referenced by the configuration file differs from the Configurator's copy of this font. " + "Overwrite the Configurator's file with this different file?")).ShowDialog() == DialogResult.OK) { _needToCopyFont = true; } } } else { _needToCopyFont = true; } if (_needToCopyFont) { if (!File.Exists(temp_configpath)) { AllErrors.Add("There is a file referenced by an external font file that is not where it is supposed to be named: \"" + _fileNameOnly + "\""); continue; } File.Copy(temp_configpath, GlobalStaticClass.FONT_DIRECTORY + "\\" + _fileNameOnly, true); } AllPsuedoBindings.Add(new GlobalStaticClass.PsuedoFontBindings(temp_name, _fileNameOnly)); } #endregion } } #endregion #region Speech else if (subTopConfigNode.Name.ToLower() == "speech") { //Setup of Logic area foreach (XmlAttribute _speechRootEnableAttribute in subTopConfigNode.Attributes) { if (_speechRootEnableAttribute.Name.ToLower() == "enabled") { if (!bool.TryParse(_speechRootEnableAttribute.Value, out GlobalStaticClass.Speech_MasterEnable)) { } } else if (_speechRootEnableAttribute.Name.ToLower() == "global_politeness") { if (!bool.TryParse(_speechRootEnableAttribute.Value, out GlobalStaticClass.Speech_EnableGlobalPolite)) { } } } foreach (XmlNode speechTopNode in subTopConfigNode.ChildNodes) { switch (speechTopNode.Name.ToLower()) { case "system_name": { string new_system_name = speechTopNode.InnerText; if (new_system_name != null && new_system_name != "") { GlobalStaticClass.Speech_StaticSetupClass.generic_system.Add(new_system_name); } } break; case "system_definitions": { foreach (XmlNode _system_definition_nodes in speechTopNode.ChildNodes) { switch (_system_definition_nodes.Name.ToLower()) { case "digital_output_turn_on": { GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output_turn_on.Add(_system_definition_nodes.InnerText); } break; case "digital_output_turn_off": { GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output_turn_off.Add(_system_definition_nodes.InnerText); } break; case "digital_output_id_generic": { GlobalStaticClass.Speech_StaticSetupClass.generic_digital_output.Add(_system_definition_nodes.InnerText); } break; case "analogue_input_query": { GlobalStaticClass.Speech_StaticSetupClass.generic_analogue_input_read.Add(_system_definition_nodes.InnerText); } break; case "analogue_input_id_generic": { GlobalStaticClass.Speech_StaticSetupClass.generic_analogue_input.Add(_system_definition_nodes.InnerText); } break; default: //Error or Unknown break; } } } break; case "custom_definitions": { foreach (XmlNode _custom_definition_nodes in speechTopNode.ChildNodes) { switch (_custom_definition_nodes.Name.ToLower()) { case "digital_output": { GlobalStaticClass.Speech_StaticSetupClass.customDefinition _cD = new GlobalStaticClass.Speech_StaticSetupClass.customDefinition(); foreach (XmlAttribute _customDefAttribute in _custom_definition_nodes.Attributes) { if (_customDefAttribute.Name.ToLower() == "id") { _cD.systemName = _customDefAttribute.Value; break; } } _cD.spokenName = _custom_definition_nodes.InnerText; if (_cD.spokenName != "" && _cD.systemName != "") { GlobalStaticClass.Speech_StaticSetupClass.custom_definition_digital_outputs.Add(_cD); } } break; case "variable": { GlobalStaticClass.Speech_StaticSetupClass.customDefinition _cD = new GlobalStaticClass.Speech_StaticSetupClass.customDefinition(); foreach (XmlAttribute _customDefAttribute in _custom_definition_nodes.Attributes) { if (_customDefAttribute.Name.ToLower() == "id") { _cD.systemName = _customDefAttribute.Value; break; } } _cD.spokenName = _custom_definition_nodes.InnerText; if (_cD.spokenName != "" && _cD.systemName != "") { GlobalStaticClass.Speech_StaticSetupClass.custom_definition_variables.Add(_cD); } } break; default: //Error or Unknown break; } } } break; case "custom_queries": { foreach (XmlNode _queryNode in speechTopNode.ChildNodes) { if (_queryNode.Name.ToLower() == "query") { GlobalStaticClass.Speech_StaticSetupClass.customQuery _cQ = new GlobalStaticClass.Speech_StaticSetupClass.customQuery(); foreach (XmlAttribute _cQAttribute in _queryNode.Attributes) { if (_cQAttribute.Name.ToLower() == "monitor_type") { _cQ.monitor_type = _cQAttribute.Value.ToLower(); } else if (_cQAttribute.Name.ToLower() == "monitor_id") { _cQ.monitor_id = _cQAttribute.Value.ToLower(); } } foreach (XmlNode _queryBuildNodes in _queryNode.ChildNodes) { if (_queryBuildNodes.Name.ToLower() == "build_question") { foreach (XmlNode _queryBuildSubNodes in _queryBuildNodes.ChildNodes) { switch (_queryBuildSubNodes.Name.ToLower()) { case "beginning": { foreach (XmlNode _queryBuildOption in _queryBuildSubNodes.ChildNodes) { if (_queryBuildOption.Name.ToLower() == "option") { _cQ.builder_beginnings.Add(_queryBuildOption.InnerText); } } } break; case "middle": { foreach (XmlNode _queryBuildOption in _queryBuildSubNodes.ChildNodes) { if (_queryBuildOption.Name.ToLower() == "option") { _cQ.builder_middles.Add(_queryBuildOption.InnerText); } } } break; case "ending": { foreach (XmlNode _queryBuildOption in _queryBuildSubNodes.ChildNodes) { if (_queryBuildOption.Name.ToLower() == "option") { _cQ.builder_endings.Add(_queryBuildOption.InnerText); } } } break; } } } else if (_queryBuildNodes.Name.ToLower() == "responses") { foreach (XmlNode _queryBuildResponse in _queryBuildNodes.ChildNodes) { if (_queryBuildResponse.Name.ToLower() == "response") { string _response_b = "", _response_e = ""; foreach (XmlAttribute _responseAttributes in _queryBuildResponse.Attributes) { if (_responseAttributes.Name.ToLower() == "beginning") { _response_b = _responseAttributes.InnerText; } else if (_responseAttributes.Name.ToLower() == "ending") { _response_e = _responseAttributes.InnerText; } } _cQ.possible_responses.Add(new GlobalStaticClass.Speech_Response(_response_b, _response_e)); } } } } GlobalStaticClass.Speech_StaticSetupClass.custom_query_list.Add(_cQ); } } } break; default: //Error or Unknown break; } } } #endregion #region General Configuration else if (subTopConfigNode.Name.ToLower() == "general") { //General Part of the skin file foreach (XmlNode GeneralSubNode in subTopConfigNode.ChildNodes) { switch (GeneralSubNode.Name.ToLower()) { #region Remote Control case "remote": { foreach (XmlAttribute GeneralSubAttribute in GeneralSubNode.Attributes) { if (GeneralSubAttribute.Name.ToLower() == "status") { if (GeneralSubAttribute.Value.ToLower() == "enabled") { GlobalStaticClass.RemoteControlProperties.enabled = true; } else { GlobalStaticClass.RemoteControlProperties.enabled = false; } } else if (GeneralSubAttribute.Name.ToLower() == "user_name") { GlobalStaticClass.RemoteControlProperties.userName = GeneralSubAttribute.Value; } else if (GeneralSubAttribute.Name.ToLower() == "port") { int.TryParse(GeneralSubAttribute.Value, out GlobalStaticClass.RemoteControlProperties.port); } } } break; #endregion #region Debug Settings case "debug": { foreach (XmlAttribute GeneralSubAttribute in GeneralSubNode.Attributes) { if (GeneralSubAttribute.Name.ToLower() == "status") { if (GeneralSubAttribute.Value.ToLower() == "on") { GlobalStaticClass.Debug_MasterEnable = true; } } } if (GlobalStaticClass.Debug_MasterEnable) { foreach (XmlNode _debugNode in GeneralSubNode.ChildNodes) { switch (_debugNode.Name.ToLower()) { #region Debug Windows case "window": { foreach (XmlAttribute _debug_attribute in _debugNode.Attributes) { switch (_debug_attribute.Value.ToLower()) { case "variables": { GlobalStaticClass.Debug_VariableWindow = true; } break; case "ifthen": { GlobalStaticClass.Debug_IfThenWindow = true; } break; case "speech": { GlobalStaticClass.Debug_SpeechWindow = true; } break; default: break; } } } break; #endregion #region Debug Virtual Brain case "virtual_brain": { foreach (XmlAttribute _debug_attribute in _debugNode.Attributes) { switch (_debug_attribute.Name.ToLower()) { case "id": { GlobalStaticClass.Debug_VirtualBrainList.Add(_debug_attribute.Value.ToLower()); } break; default: break; } } } break; #endregion default: break; } } } } break; #endregion #region COM Commands case "com": { foreach (XmlAttribute GeneralSubAttribute in GeneralSubNode.Attributes) { if (GeneralSubAttribute.Name.ToLower() == "status") { if (GeneralSubAttribute.Value.ToLower() == "enabled") { GlobalStaticClass.COM_Master_Enable = true; } else { GlobalStaticClass.COM_Master_Enable = false; } } } foreach (XmlNode COM_CommandsRootNode in GeneralSubNode.ChildNodes) { if (COM_CommandsRootNode.Name.ToLower() == "commands") { foreach (XmlNode COM_CommandNodes in COM_CommandsRootNode.ChildNodes) { if (COM_CommandNodes.Name.ToLower() == "command") { string com_command_id = ""; int com_command_minDVT = 0; foreach (XmlAttribute COM_CommandAttribute in COM_CommandNodes.Attributes) { if (COM_CommandAttribute.Name.ToLower() == "id") { com_command_id = COM_CommandAttribute.Value.ToLower(); } else if (COM_CommandAttribute.Name.ToLower() == "minimum_delta_vote_time") { int.TryParse(COM_CommandAttribute.Value, out com_command_minDVT); } } GlobalStaticClass.COM_Command_Class _command = new GlobalStaticClass.COM_Command_Class(com_command_id); _command.minimum_delta_vote_time = com_command_minDVT; _command.do_statements = GlobalStaticClass.Function_ParseThenAndAntiThenNodesToVoteClassList(COM_CommandNodes, ref AllErrors); GlobalStaticClass.COM_List_of_Commands.Add(_command); } } } else if (COM_CommandsRootNode.Name.ToLower() == "executable_commands") { foreach (XmlNode COM_ProgramNodes in COM_CommandsRootNode.ChildNodes) { if (COM_ProgramNodes.Name.ToLower() == "external_COM_id".ToLower()) { string COM_Program_ID = ""; foreach (XmlAttribute COM_ProgramNodesAttribute in COM_ProgramNodes.Attributes) { if (COM_ProgramNodesAttribute.Name.ToLower() == "id") { COM_Program_ID = COM_ProgramNodesAttribute.Value; break; } } GlobalStaticClass.COM_Execution_Object_Class newCOMExecutionObject = new GlobalStaticClass.COM_Execution_Object_Class(); newCOMExecutionObject.id = COM_Program_ID; foreach (XmlNode COM_CommandNodes in COM_ProgramNodes.ChildNodes) { if (COM_CommandNodes.Name.ToLower() == "command") { string com_command_external = ""; string com_command_internal = ""; List com_command_external_parameters = new List(); foreach (XmlAttribute COM_CommandAttribute in COM_CommandNodes.Attributes) { if (COM_CommandAttribute.Name.ToLower() == "internal_id") { com_command_internal = COM_CommandAttribute.Value.ToLower(); } else if (COM_CommandAttribute.Name.ToLower() == "external_command") { com_command_external = COM_CommandAttribute.Value; } } List _parametersForSort = new List(); foreach (XmlNode COM_CommandNode_EX_Params in COM_CommandNodes.ChildNodes) { GlobalStaticClass.COM_Execution_Object_Class.COM_External_Executable_Parameter_Class _param = new GlobalStaticClass.COM_Execution_Object_Class.COM_External_Executable_Parameter_Class(); foreach (XmlAttribute COM_CommandNode_EX_Params_Attribute in COM_CommandNode_EX_Params.Attributes) { if (COM_CommandNode_EX_Params_Attribute.Name.ToLower() == "order") { int.TryParse(COM_CommandNode_EX_Params_Attribute.Value, out _param._order); } else if (COM_CommandNode_EX_Params_Attribute.Name.ToLower() == "external_command_parameter") { _param._param = COM_CommandNode_EX_Params_Attribute.Value; } } if (_param._order >= 0) { _parametersForSort.Add(_param); } } _parametersForSort.Sort(); foreach (GlobalStaticClass.COM_Execution_Object_Class.COM_External_Executable_Parameter_Class _pClass in _parametersForSort) { com_command_external_parameters.Add(_pClass._param); } } } GlobalStaticClass.COM_List_of_Executable_Commands.Add(newCOMExecutionObject); } } } } } break; #endregion default: //Error or Unknown break; } } } #endregion #region Graphics Configuration else if (subTopConfigNode.Name.ToLower() == "graphics") { //Graphic Part of the skin file foreach (XmlNode GraphicSubNode in subTopConfigNode.ChildNodes) { _BUSYFORM.UpdateBar(); switch (GraphicSubNode.Name.ToLower()) { #region Main Program Global Values case "main_display": foreach (XmlAttribute MainDisplayAttribute in GraphicSubNode.Attributes) { _BUSYFORM.UpdateBar(); switch (MainDisplayAttribute.Name.ToLower()) { #region Size of Program in Pixels (Designed for and Actual) case "designed_for_size": { int Size_x = 1; int Size_y = 1; if (!int.TryParse(MainDisplayAttribute.Value.Substring(0, MainDisplayAttribute.Value.IndexOf(',')), out Size_x) || !int.TryParse(MainDisplayAttribute.Value.Substring(MainDisplayAttribute.Value.IndexOf(',') + 1), out Size_y)) { //Error parsing AllErrors.Add("Designed for size is not parseable"); break; } GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth = Size_x; GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight = Size_y; } break; case "show_at_size": { int Size_x = 1; int Size_y = 1; if (!int.TryParse(MainDisplayAttribute.Value.Substring(0, MainDisplayAttribute.Value.IndexOf(',')), out Size_x) || !int.TryParse(MainDisplayAttribute.Value.Substring(MainDisplayAttribute.Value.IndexOf(',') + 1), out Size_y)) { //Error parsing AllErrors.Add("Display at size is not parseable"); break; } GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtWidth = Size_x; GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtHeight = Size_y; } break; #endregion #region Show or Hide the Menu bar with Min/Max/Close case "menubar": FormBorderStyle FBS = new FormBorderStyle(); switch (MainDisplayAttribute.Value.ToLower()) { case "none": case "hidden": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.None; break; case "fixed": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.FixedSingle; break; case "sizeable": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.Sizable; break; default: //Not recognized type... break; } break; #endregion #region Run in System Tray case "runinsystemtray": { if (MainDisplayAttribute.Value.ToLower() == "true") { GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInSystemTray = true; } else { GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInSystemTray = false; } } break; #endregion #region Minimize to System Tray case "minimizetosystemtray": { if (MainDisplayAttribute.Value.ToLower() == "true") { GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToSystemTray = true; } else { GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToSystemTray = false; } } break; #endregion #region Error or Undefined default: //Not recognized type... break; #endregion } } break; #endregion #region Background Images case "background_image": { string path = ""; Bitmap image = null; string layout = ""; int page = -1; foreach (XmlAttribute BackgroundAttribute in GraphicSubNode.Attributes) { _BUSYFORM.UpdateBar(); switch (BackgroundAttribute.Name.ToLower()) { #region Page to Display Background Image on case "page": int.TryParse(BackgroundAttribute.Value, out page); break; #endregion #region ImageLayout of the Background Image case "style": layout = BackgroundAttribute.Value.ToLower(); break; #endregion #region Actual Image of the Background Image case "imagefilepath": try { path = openDirectory + BackgroundAttribute.Value; image = (Bitmap)(Bitmap)Bitmap.FromFile(path); } catch (Exception) { AllErrors.Add("Background image not found at: " + BackgroundAttribute.Value); } break; #endregion #region Error or Unknown default: //Undefined... break; #endregion } } #region If the new background image Mmeets requirements, add it to the global list... if (image != null && path != "" && layout != "" && page >= 0) { GlobalStaticClass._Global_List_Graphics_BackgroundImage.Add(new GlobalStaticClass.FusionImage_BackgroundImage(path, image, layout, page)); } #endregion break; } #endregion #region Display Buttons case "button": { GlobalStaticClass.FusionImage_DisplayButton newDisplayButton = new GlobalStaticClass.FusionImage_DisplayButton(); newDisplayButton._MyVote = new GlobalStaticClass.Vote_VoteClass(); newDisplayButton._MyVote_UPCLICK = new GlobalStaticClass.Vote_VoteClass(); foreach (XmlAttribute DisplayButtonAttribute in GraphicSubNode.Attributes) { _BUSYFORM.UpdateBar(); switch (DisplayButtonAttribute.Name.ToLower()) { #region Unique ID of button case "id": string newID = DisplayButtonAttribute.Value; bool isUnique = true; foreach (GlobalStaticClass.FusionImage_DisplayButton testDispButton in GlobalStaticClass._Global_List_Graphics_DisplayButton) { _BUSYFORM.UpdateBar(); if (testDispButton._name.ToLower() == newID.ToLower()) { isUnique = false; AllErrors.Add("Cannot add a display button with duplicate ID of: " + newID); break; } } if (isUnique) { newDisplayButton._name = newID; } break; #endregion #region The default Enabled/Disabled State of the Button on Program Start case "enabled": if (DisplayButtonAttribute.Value.ToLower() == "yes" || DisplayButtonAttribute.Value.ToLower() == "enabled") { newDisplayButton.default_state = "enabled"; } else if (DisplayButtonAttribute.Value.ToLower() == "no" || DisplayButtonAttribute.Value.ToLower() == "disabled") { newDisplayButton.default_state = "disabled"; } break; #endregion #region The function of the button (What it does) case "function": switch (DisplayButtonAttribute.Value.ToLower()) { case "trigger output": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.TRIGGER_OUTPUT; break; case "enable or disable": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.ENABLE_OR_DISABLE; break; case "change variable": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_VARIABLE; break; case "change page": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_PAGE; break; case "change timer": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_TIMER; break; case "change logging": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_LOGGING; break; case "send key": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.SEND_KEY; break; case "play sound": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.PLAY_SOUND; break; case "send email": newDisplayButton._MyVote._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.SEND_EMAIL; break; default: AllErrors.Add("Invalid function on display button"); break; } break; #endregion #region The Target ID of whatever the function is case "functiontargetid": newDisplayButton._MyVote._TargetID = DisplayButtonAttribute.Value.ToLower(); break; #endregion #region Vote Type case "vote": newDisplayButton._MyVote_Type = DisplayButtonAttribute.Value.ToLower(); break; #endregion #region Vote Opinion case "vote_opinion": newDisplayButton._MyVote._VoteOpinion = DisplayButtonAttribute.Value.ToLower(); break; #endregion #region Vote Priority case "vote_priority": switch (DisplayButtonAttribute.Value.ToLower()) { case "low": newDisplayButton._MyVote._Priority = GlobalStaticClass.Vote_Priority.LOW; break; case "medium": newDisplayButton._MyVote._Priority = GlobalStaticClass.Vote_Priority.MEDIUM; break; case "high": newDisplayButton._MyVote._Priority = GlobalStaticClass.Vote_Priority.HIGH; break; case "absolute": newDisplayButton._MyVote._Priority = GlobalStaticClass.Vote_Priority.ABSOLUTE; break; default: break; } break; #endregion #region Error or Undefined default: break; #endregion } } if (newDisplayButton._name == "" || newDisplayButton._MyVote == null || newDisplayButton._MyVote._WhatToDo == null || newDisplayButton._MyVote._TargetID == "" || newDisplayButton._MyVote._VoteOpinion == "" || newDisplayButton._MyVote_Type == "") { AllErrors.Add("Display button missing require parameters, skipping it"); continue; } foreach (XmlNode DeZildrenOfDeButton in GraphicSubNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute DeZildrenAttributes in DeZildrenOfDeButton.Attributes) { _BUSYFORM.UpdateBar(); switch (DeZildrenAttributes.Name.ToLower()) { #region Primary Image case "imageprimary": if (File.Exists(openDirectory + DeZildrenAttributes.Value)) { newDisplayButton._path_Primary = openDirectory + DeZildrenAttributes.Value; newDisplayButton._image_Primary = (Bitmap)Bitmap.FromFile(newDisplayButton._path_Primary); newDisplayButton._path = newDisplayButton._path_Primary; newDisplayButton._image = newDisplayButton._image_Primary; } else { AllErrors.Add("Display Button's primary image does not exist or cannot be loaded"); } break; #endregion #region Secondary Image case "imagesecondary": try { newDisplayButton._path_Secondary = openDirectory + DeZildrenAttributes.Value; newDisplayButton._image_Secondary = (Bitmap)Bitmap.FromFile(newDisplayButton._path_Secondary); } catch (FileNotFoundException) { AllErrors.Add("Display Button's secondary image does not exist or cannot be loaded"); } break; #endregion #region Disabled Image case "imagedisabled": try { newDisplayButton._path_Disabled = openDirectory + DeZildrenAttributes.Value; newDisplayButton._image_Disabled = (Bitmap)Bitmap.FromFile(newDisplayButton._path_Disabled); } catch (FileNotFoundException) { AllErrors.Add("Display Button's disabled image does not exist or cannot be loaded"); } break; #endregion #region Pushed Image case "imagepushed": try { newDisplayButton._path_Pushed = openDirectory + DeZildrenAttributes.Value; newDisplayButton._image_Pushed = (Bitmap)Bitmap.FromFile(newDisplayButton._path_Pushed); } catch (FileNotFoundException) { AllErrors.Add("Display Button's pushed image does not exist or cannot be loaded"); } break; #endregion #region Size of Button case "size": int Size_x = 1; int Size_y = 1; if (!int.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out Size_x) || !int.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out Size_y)) { //Error parsing AllErrors.Add("Syntax error parsing the size of a display button item"); } else { newDisplayButton._width = Size_x; newDisplayButton._height = Size_y; } break; #endregion #region Location of Button case "location": float Loc_x = 1; float Loc_y = 1; if (!float.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out Loc_x) || !float.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing AllErrors.Add("Syntax error parsing the location of a display button item"); } else { newDisplayButton._x = (int)Loc_x; newDisplayButton._y = (int)Loc_y; } break; #endregion #region Page of Button case "page": int newPage = -1; if (!int.TryParse(DeZildrenAttributes.Value, out newPage)) { AllErrors.Add("Syntax error parsing the page of a display button item"); } else { bool isUniquePage = true; foreach (int Pagita in newDisplayButton._pages) { _BUSYFORM.UpdateBar(); if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { newDisplayButton._pages.Add(newPage); } } break; #endregion #region Text Strings case "textprimary": newDisplayButton._textPrimary = DeZildrenAttributes.Value; break; case "textsecondary": newDisplayButton._textSecondary = DeZildrenAttributes.Value; break; case "textdisabled": newDisplayButton._textDisabled = DeZildrenAttributes.Value; break; #endregion #region Text Colour - UNSUPPORTED case "colourprimaryargb": { char[] argb_split = { ',' }; string[] argb_string = DeZildrenAttributes.Value.Split(argb_split); int[] argb_int = new int[4]; for (int argb_i = 0; argb_i < 4; argb_i++) { int.TryParse(argb_string[argb_i], out argb_int[argb_i]); } newDisplayButton._textPrimaryColour = Color.FromArgb(argb_int[0], argb_int[1], argb_int[2], argb_int[3]); } break; case "coloursecondaryargb": { char[] argb_split = { ',' }; string[] argb_string = DeZildrenAttributes.Value.Split(argb_split); int[] argb_int = new int[4]; for (int argb_i = 0; argb_i < 4; argb_i++) { int.TryParse(argb_string[argb_i], out argb_int[argb_i]); } newDisplayButton._textSecondaryColour = Color.FromArgb(argb_int[0], argb_int[1], argb_int[2], argb_int[3]); } break; case "colourdisabledargb": { char[] argb_split = { ',' }; string[] argb_string = DeZildrenAttributes.Value.Split(argb_split); int[] argb_int = new int[4]; for (int argb_i = 0; argb_i < 4; argb_i++) { int.TryParse(argb_string[argb_i], out argb_int[argb_i]); } newDisplayButton._textDisabledColour = Color.FromArgb(argb_int[0], argb_int[1], argb_int[2], argb_int[3]); } break; #endregion #region Font Family and Size case "font": newDisplayButton._font_name = DeZildrenAttributes.Value; break; case "font_size": { float temp_FontSize = 0.0f; if (float.TryParse(DeZildrenAttributes.Value, out temp_FontSize)) { newDisplayButton._font_size = temp_FontSize.ToString(); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(DeZildrenAttributes.Value, out newDisplayButton._z_order)) { AllErrors.Add("Syntax error parsing the depth of a display button item"); } } break; #endregion #region Up Click Options case "up_click_function": { switch (DeZildrenAttributes.Value.ToLower()) { case "trigger output": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.TRIGGER_OUTPUT; break; case "enable or disable": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.ENABLE_OR_DISABLE; break; case "change variable": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_VARIABLE; break; case "change page": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_PAGE; break; case "change timer": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_TIMER; break; case "change logging": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.CHANGE_LOGGING; break; case "send key": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.SEND_KEY; break; case "play sound": newDisplayButton._MyVote_UPCLICK._WhatToDo = GlobalStaticClass.Vote_PossibleThingsToDo.PLAY_SOUND; break; default: AllErrors.Add("Invalid function on display button"); break; } break; } break; case "up_click_functiontargetid": { newDisplayButton._MyVote_UPCLICK._TargetID = DeZildrenAttributes.Value.ToLower(); } break; case "up_click_vote_opinion": { newDisplayButton._MyVote_UPCLICK._VoteOpinion = DeZildrenAttributes.Value.ToLower(); ; } break; case "up_click_vote": { newDisplayButton._MyVote_Type_UPCLICK = DeZildrenAttributes.Value.ToLower(); } break; case "up_click_vote_priority": { switch (DeZildrenAttributes.Value.ToLower()) { case "low": newDisplayButton._MyVote_UPCLICK._Priority = GlobalStaticClass.Vote_Priority.LOW; break; case "medium": newDisplayButton._MyVote_UPCLICK._Priority = GlobalStaticClass.Vote_Priority.MEDIUM; break; case "high": newDisplayButton._MyVote_UPCLICK._Priority = GlobalStaticClass.Vote_Priority.HIGH; break; case "absolute": newDisplayButton._MyVote._Priority = GlobalStaticClass.Vote_Priority.ABSOLUTE; break; default: break; } } break; #endregion #region Minimum Time Between Votes (Down) case "minimum_delta_vote_time_down": { if (!int.TryParse(DeZildrenAttributes.Value, out newDisplayButton._Time_down)) { AllErrors.Add("Syntax error parsing the minimum delta time vote (down) of a display button item"); } } break; #endregion #region Minimum Time Between Votes (Up) case "minimum_delta_vote_time_up": { if (!int.TryParse(DeZildrenAttributes.Value, out newDisplayButton._Time_up)) { AllErrors.Add("Syntax error parsing the minimum delta time vote (up) of a display button item"); } } break; #endregion #region Undefined or Error default: break; #endregion } } } if (newDisplayButton._image == null || newDisplayButton._image_Primary == null || newDisplayButton._image_Secondary == null || newDisplayButton._image_Disabled == null || newDisplayButton._image_Pushed == null || newDisplayButton._width <= 0 || newDisplayButton._height <= 0 || newDisplayButton._pages.Count <= 0) { AllErrors.Add("There is a Display Button that does not meet the reqirements to be displayed so it is being skipped"); } else { if (newDisplayButton._MyVote_Type_UPCLICK == null || newDisplayButton._MyVote_UPCLICK._TargetID == null || newDisplayButton._MyVote_UPCLICK._VoteOpinion == null || newDisplayButton._MyVote_UPCLICK._TargetID == "" || newDisplayButton._MyVote_UPCLICK._VoteOpinion == "") { newDisplayButton._MyVote_UPCLICK = null; newDisplayButton._MyVote_Type_UPCLICK = null; } GlobalStaticClass._Global_List_Graphics_DisplayButton.Add(newDisplayButton); } } break; #endregion #region Multi Image Setup case "multiimage": { string MultiImage_id = ""; string MultiImage_monitor = ""; string MultiImage_monitorType = ""; foreach (XmlAttribute MultiImageMainAttributes in GraphicSubNode.Attributes) { _BUSYFORM.UpdateBar(); switch (MultiImageMainAttributes.Name.ToLower()) { case "id": MultiImage_id = MultiImageMainAttributes.Value; break; case "monitorid": MultiImage_monitor = MultiImageMainAttributes.Value.ToLower(); break; case "monitortype": MultiImage_monitorType = MultiImageMainAttributes.Value.ToLower(); break; default: //Error or Unknown break; } } if (MultiImage_id != "" && MultiImage_monitor != "" && MultiImage_monitorType != "") { GlobalStaticClass.FusionImage_MultiImage newDisplayMultiImage = new GlobalStaticClass.FusionImage_MultiImage(); newDisplayMultiImage._name = MultiImage_id; newDisplayMultiImage._monitor_id = MultiImage_monitor; newDisplayMultiImage._monitor_type = MultiImage_monitorType; foreach (XmlNode MultiChildNode in GraphicSubNode.ChildNodes) { _BUSYFORM.UpdateBar(); switch (MultiChildNode.Name.ToLower()) { #region Display Options case "display": foreach (XmlAttribute MultiChildAttribute in MultiChildNode.Attributes) { _BUSYFORM.UpdateBar(); switch (MultiChildAttribute.Name.ToLower()) { #region Size of MultiImage case "size": int Size_x = 1; int Size_y = 1; if (!int.TryParse(MultiChildAttribute.Value.Substring(0, MultiChildAttribute.Value.IndexOf(',')), out Size_x) || !int.TryParse(MultiChildAttribute.Value.Substring(MultiChildAttribute.Value.IndexOf(',') + 1), out Size_y)) { //Error parsing AllErrors.Add("Syntax error parsing the size of a multi image item [" + newDisplayMultiImage._name + "]"); } else { newDisplayMultiImage._width = Size_x; newDisplayMultiImage._height = Size_y; } break; #endregion #region Location of MultiImage case "location": float Loc_x = 1; float Loc_y = 1; if (!float.TryParse(MultiChildAttribute.Value.Substring(0, MultiChildAttribute.Value.IndexOf(',')), out Loc_x) || !float.TryParse(MultiChildAttribute.Value.Substring(MultiChildAttribute.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing AllErrors.Add("Syntax error parsing the location of a multi image item [" + newDisplayMultiImage._name + "]"); } else { newDisplayMultiImage._x = (int)Loc_x; newDisplayMultiImage._y = (int)Loc_y; } break; #endregion #region Page of MultiImage case "page": int newPage = -1; if (!int.TryParse(MultiChildAttribute.Value, out newPage)) { AllErrors.Add("Syntax error parsing the page of a multi image item [" + newDisplayMultiImage._name + "]"); } else { bool isUniquePage = true; foreach (int Pagita in newDisplayMultiImage._pages) { _BUSYFORM.UpdateBar(); if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { newDisplayMultiImage._pages.Add(newPage); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(MultiChildAttribute.Value, out newDisplayMultiImage._z_order)) { AllErrors.Add("Syntax error parsing the depth of a Multi Image item [" + newDisplayMultiImage._name + "]"); } } break; #endregion #region Z-Order case "rotate": { if (!float.TryParse(MultiChildAttribute.Value, out newDisplayMultiImage._rotation)) { AllErrors.Add("Syntax error parsing the rotation of a Multi Image item [" + newDisplayMultiImage._name + "]"); } } break; #endregion #region Error Or Unknown default: //Error or Unknown break; #endregion } } break; #endregion #region Image Node case "image": GlobalStaticClass.FusionImage_MultiImage.MultiImageProperties _newMultiSubImage = new GlobalStaticClass.FusionImage_MultiImage.MultiImageProperties(); foreach (XmlAttribute MultiChildAttribute in MultiChildNode.Attributes) { _BUSYFORM.UpdateBar(); if (MultiChildAttribute.Name.ToLower() == "path") { try { _newMultiSubImage._path = openDirectory + MultiChildAttribute.Value; _newMultiSubImage._image = (Bitmap)Bitmap.FromFile(_newMultiSubImage._path); } catch (FileNotFoundException) { AllErrors.Add("A Multi Image's image does not exist where specified [" + newDisplayMultiImage._name + "]"); continue; } } } foreach (XmlNode MultiChildNodeSubNode in MultiChildNode.ChildNodes) { _BUSYFORM.UpdateBar(); if (MultiChildNodeSubNode.Name.ToLower() == "values") { foreach (XmlAttribute MultiImageSubSubAttribute in MultiChildNodeSubNode.Attributes) { _BUSYFORM.UpdateBar(); switch (MultiImageSubSubAttribute.Name.ToLower()) { case "atleastorequalto": float.TryParse(MultiImageSubSubAttribute.Value, out _newMultiSubImage._low); break; case "atmost": float.TryParse(MultiImageSubSubAttribute.Value, out _newMultiSubImage._high); break; default: //Error or Unknown break; } } } } if (_newMultiSubImage._low <= _newMultiSubImage._high && _newMultiSubImage._high >= _newMultiSubImage._low && _newMultiSubImage._image != null && _newMultiSubImage._path != "") { newDisplayMultiImage._ImageList.Add(_newMultiSubImage); } else { } break; #endregion #region Auto Image case "imageauto": string MultiImageAUTO_directoryname = ""; string MultiImageAUTO_filenamebase = ""; string MultiImageAUTO_filenameextension = ""; int MultiImageAUTO_filenamestart = 0; int MultiImageAUTO_filenameend = 0; float MultiImageAUTO_valuestart = 0.0f; float MultiImageAUTO_valueend = 5.0f; float MultiImageAUTO_rotateangle = 0.0f; foreach (XmlAttribute MultiImageAttributeAUTO in MultiChildNode.Attributes) { _BUSYFORM.UpdateBar(); if (MultiImageAttributeAUTO.Name.ToLower() == "directory_path") { MultiImageAUTO_directoryname = MultiImageAttributeAUTO.Value; } } foreach (XmlNode MultiImageSubNodeAUTO in MultiChildNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute MultiImageSubNodeAttributeAUTO in MultiImageSubNodeAUTO.Attributes) { _BUSYFORM.UpdateBar(); switch (MultiImageSubNodeAttributeAUTO.Name.ToLower()) { case "filename_base": MultiImageAUTO_filenamebase = MultiImageSubNodeAttributeAUTO.Value; break; case "filename_start": int.TryParse(MultiImageSubNodeAttributeAUTO.Value, out MultiImageAUTO_filenamestart); break; case "filename_end": int.TryParse(MultiImageSubNodeAttributeAUTO.Value, out MultiImageAUTO_filenameend); break; case "filename_extension": MultiImageAUTO_filenameextension = MultiImageSubNodeAttributeAUTO.Value; break; case "value_start": float.TryParse(MultiImageSubNodeAttributeAUTO.Value, out MultiImageAUTO_valuestart); break; case "value_end": float.TryParse(MultiImageSubNodeAttributeAUTO.Value, out MultiImageAUTO_valueend); break; case "rotate": float.TryParse(MultiImageSubNodeAttributeAUTO.Value, out MultiImageAUTO_rotateangle); break; default: //Error or Unknown break; } } } if (Directory.Exists(openDirectory + MultiImageAUTO_directoryname)) { int temp_totalSteps = MultiImageAUTO_filenameend - MultiImageAUTO_filenamestart; float temp_totalDeltaValue = MultiImageAUTO_valueend - MultiImageAUTO_valuestart; for (int MultiImageAUTO_i = MultiImageAUTO_filenamestart; MultiImageAUTO_i <= MultiImageAUTO_filenameend; MultiImageAUTO_i++) { float temp_startValue = MultiImageAUTO_valuestart + ((MultiImageAUTO_i / (float)temp_totalSteps) * temp_totalDeltaValue); float temp_endValue = MultiImageAUTO_valuestart + (((MultiImageAUTO_i + 1) / (float)temp_totalSteps) * temp_totalDeltaValue); string MultiImageAUTO_tryImagePath = MultiImageAUTO_directoryname + "\\" + MultiImageAUTO_filenamebase + MultiImageAUTO_i.ToString() + "." + MultiImageAUTO_filenameextension; if (File.Exists(openDirectory + MultiImageAUTO_tryImagePath)) { GlobalStaticClass.FusionImage_MultiImage.MultiImageProperties newMultiDisplayButtonAUTO = new GlobalStaticClass.FusionImage_MultiImage.MultiImageProperties(); newMultiDisplayButtonAUTO._path = openDirectory + MultiImageAUTO_tryImagePath; newMultiDisplayButtonAUTO._image = (Bitmap)Bitmap.FromFile(newMultiDisplayButtonAUTO._path); newMultiDisplayButtonAUTO._low = temp_startValue; newMultiDisplayButtonAUTO._high = temp_endValue; newDisplayMultiImage._ImageList.Add(newMultiDisplayButtonAUTO); } else { AllErrors.Add("File \"" + openDirectory + MultiImageAUTO_tryImagePath + "\" does not exist in directory as it is defined in a multiimage"); continue; } } } else { AllErrors.Add("Directory \"" + MultiImageAUTO_directoryname + "\" not found in " + openDirectory + " and is needed as defined by a multiimage."); continue; } break; #endregion #region Options case "options": foreach (XmlAttribute OptionAttribute in MultiChildNode.Attributes) { _BUSYFORM.UpdateBar(); switch (OptionAttribute.Name.ToLower()) { default: break; } } break; #endregion #region Error or Unknown default: break; #endregion } } if (newDisplayMultiImage._ImageList.Count > 0) { newDisplayMultiImage._image = newDisplayMultiImage._ImageList[0]._image; } GlobalStaticClass._Global_List_Graphics_MultiImage.Add(newDisplayMultiImage); } } break; #endregion #region Rotating Image Setup - UNSUPPORTED case "rotateimage": /* { string RotateImage_id = ""; string RotateImage_monitor = ""; string RotateImage_monitorType = ""; foreach (XmlAttribute RotateImageMainAttributes in GraphicSubNode.Attributes) { switch (RotateImageMainAttributes.Name.ToLower()) { case "id": RotateImage_id = RotateImageMainAttributes.Value.ToLower(); break; case "monitorid": RotateImage_monitor = RotateImageMainAttributes.Value.ToLower(); break; case "monitortype": RotateImage_monitorType = RotateImageMainAttributes.Value.ToLower(); break; default: //Error or Unknown break; } } if (RotateImage_id != "" && RotateImage_monitor != "" && RotateImage_monitorType != "") { DisplayRotateImageCentre newDisplayRotateImage = new DisplayRotateImageCentre(RotateImage_id, RotateImage_monitor, RotateImage_monitorType); foreach (XmlNode RotateChildNode in GraphicSubNode.ChildNodes) { switch (RotateChildNode.Name.ToLower()) { #region Display case "display": foreach (XmlAttribute RotateChildAttribute in RotateChildNode.Attributes) { switch (RotateChildAttribute.Name.ToLower()) { #region Size of Rotate Image case "size": int Size_x = 1; int Size_y = 1; if (!int.TryParse(RotateChildAttribute.Value.Substring(0, RotateChildAttribute.Value.IndexOf(',')), out Size_x) || !int.TryParse(RotateChildAttribute.Value.Substring(RotateChildAttribute.Value.IndexOf(',') + 1), out Size_y)) { //Error parsing DisplayMessageBox("Syntax error parsing the size of a multi image item"); } else { newDisplayRotateImage.DisplaySize = new Size(Size_x, Size_y); } break; #endregion #region Location of Rotate Image case "location": int Loc_x = 1; int Loc_y = 1; if (!int.TryParse(RotateChildAttribute.Value.Substring(0, RotateChildAttribute.Value.IndexOf(',')), out Loc_x) || !int.TryParse(RotateChildAttribute.Value.Substring(RotateChildAttribute.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing DisplayMessageBox("Syntax error parsing the location of a multi image item"); } else { newDisplayRotateImage.DeButtonLocation = new Point((int)Loc_x, (int)Loc_y); } break; #endregion #region Page of Rotate Image case "page": int newPage = -1; if (!int.TryParse(RotateChildAttribute.Value, out newPage)) { DisplayMessageBox("Syntax error parsing the page of a multi image item"); } else { bool isUniquePage = true; foreach (int Pagita in newDisplayRotateImage.DisplayPage) { if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { newDisplayRotateImage.DisplayPage.Add(newPage); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(RotateChildAttribute.Value, out newDisplayRotateImage.MDX_DisplayDepth)) { DisplayMessageBox("Syntax error parsing the depth of a Static Image item, will be set to 0.0f"); } } break; #endregion #region Error Or Unknown default: //Error or Unknown break; #endregion } } break; #endregion #region Option Settings case "options": foreach (XmlAttribute RotateChildAttribute in RotateChildNode.Attributes) { switch (RotateChildAttribute.Name.ToLower()) { #region Streak the Image case "streakimage": if (RotateChildAttribute.Value.ToLower() == "true") { newDisplayRotateImage.streakImage = true; } else if (RotateChildAttribute.Value.ToLower() == "false") { newDisplayRotateImage.streakImage = false; } break; #endregion #region Smooth the Image Rotation case "smoothimage": if (RotateChildAttribute.Value.ToLower() == "true") { newDisplayRotateImage.smoothRotating = true; } else if (RotateChildAttribute.Value.ToLower() == "false") { newDisplayRotateImage.smoothRotating = false; } break; #endregion #region Smooth the Image Rotation case "smoothmaximumangledifference": if (!float.TryParse(RotateChildAttribute.Value, out newDisplayRotateImage.maximumAngleStride)) { DisplayMessageBox("Rotating Image Maximum Smoothing Image Parse Error", true); } break; #endregion #region Error Or Unknown default: //Error or Unknown break; #endregion } } break; #endregion #region Image case "image": foreach (XmlAttribute RotateChildAttribute in RotateChildNode.Attributes) { #region Rotate Image Path if (RotateChildAttribute.Name.ToLower() == "path") { try { newDisplayRotateImage.MDX_Primary = new FusionImage(LoadMyTexture(MDX_Device, RotateChildAttribute.Value), MDX_Device); } catch (FileNotFoundException) { DisplayMessageBox("A Rotate Image's image does not exist where specified.", true); return false; } } #endregion } break; #endregion #region Values case "values": DisplayRotateImageCentre.DisplayRotateImageValues newRotateValues = new DisplayRotateImageCentre.DisplayRotateImageValues(); foreach (XmlAttribute RotateChildAttribute in RotateChildNode.Attributes) { switch (RotateChildAttribute.Name.ToLower()) { #region Minimum Angle for New Setting case "angleminimum": if (!double.TryParse(RotateChildAttribute.Value, out newRotateValues.angle_minimum)) { DisplayMessageBox("Error Reading Minimum Angle for a Rotate Image", true); } break; #endregion #region Maximum Angle for New Setting case "anglemaximum": if (!double.TryParse(RotateChildAttribute.Value, out newRotateValues.angle_maximum)) { DisplayMessageBox("Error Reading Maximum Angle for a Rotate Image", true); } break; #endregion #region Minimum Value for New Setting case "valueminimum": if (!double.TryParse(RotateChildAttribute.Value, out newRotateValues.value_minimum)) { DisplayMessageBox("Error Reading Minimum Value for a Rotate Image", true); } break; #endregion #region Maximum Value for New Setting case "valuemaximum": if (!double.TryParse(RotateChildAttribute.Value, out newRotateValues.value_maximum)) { DisplayMessageBox("Error Reading Maximum Value for a Rotate Image", true); } break; #endregion #region Error or Unknown in New Setting default: //Error Or Unknown break; #endregion } } if (newRotateValues.value_minimum <= newRotateValues.value_maximum && newRotateValues.angle_minimum <= newRotateValues.angle_maximum) { newDisplayRotateImage.MultipleAngleList.Add(newRotateValues); } break; #endregion #region Unknown or Error default: break; #endregion } } AllDisplayRotateImage.Add(newDisplayRotateImage); } } */ break; #endregion #region Static Image case "staticimage": { string path = ""; Bitmap image = null; int width = -1, height = -1, x = -1, y = -1; List pages = new List(); float z_order = 0.0f; foreach (XmlNode DeZildrenOfDeStatic in GraphicSubNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute DeZildrenAttributes in DeZildrenOfDeStatic.Attributes) { _BUSYFORM.UpdateBar(); switch (DeZildrenAttributes.Name.ToLower()) { #region Static Image case "path": try { path = openDirectory + DeZildrenAttributes.Value; image = (Bitmap)Bitmap.FromFile(path); } catch (FileNotFoundException) { AllErrors.Add("A static image's image does not exist or cannot be opened from where specified"); } break; #endregion #region Size of Static Image case "size": if (!int.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out width) || !int.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out height)) { //Error parsing AllErrors.Add("Syntax error parsing the size of a Static Image item"); } break; #endregion #region Location of Static Image case "location": float Loc_x = 1.0f; float Loc_y = 1.0f; if (!float.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out Loc_x) || !float.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing AllErrors.Add("Syntax error parsing the location of a static image item"); } else { x = (int)Loc_x; y = (int)Loc_y; } break; #endregion #region Page of Button case "page": int newPage = -1; if (!int.TryParse(DeZildrenAttributes.Value, out newPage)) { AllErrors.Add("Syntax error parsing the page of a Static Image item"); } else { bool isUniquePage = true; foreach (int Pagita in pages) { _BUSYFORM.UpdateBar(); if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { pages.Add(newPage); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(DeZildrenAttributes.Value, out z_order)) { AllErrors.Add("Syntax error parsing the depth of a Static Image item"); } } break; #endregion #region Undefined or Error default: break; #endregion } } } if (image != null && pages.Count > 0 && width > 0 && height > 0 && x >= 0 && y >= 0 && path != "") { GlobalStaticClass.FusionImage_StaticImage tempStatic = new GlobalStaticClass.FusionImage_StaticImage(path, image); tempStatic._height = height; tempStatic._pages = new List(pages.ToArray()); tempStatic._width = width; tempStatic._x = x; tempStatic._y = y; tempStatic._z_order = z_order; GlobalStaticClass._Global_List_Graphics_StaticImage.Add(tempStatic); } else { AllErrors.Add("A atatic image does not meet requirements to be displayed, it will be skipped"); } } break; #endregion #region Variable Location Image case "variable_location_image": { string path = ""; Bitmap image = null; int width = -1, height = -1, x = -1, y = -1; List pages = new List(); float z_order = 0.0f; float value_min = 0, value_max = 0; int location_min = 0, location_max = 0; GlobalStaticClass.Axis axis = GlobalStaticClass.Axis.HORIZONTAL; string targetType = "", targetID = ""; foreach (XmlNode DeZildrenOfDeVariableLocation in GraphicSubNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute DeZildrenAttributes in DeZildrenOfDeVariableLocation.Attributes) { _BUSYFORM.UpdateBar(); switch (DeZildrenAttributes.Name.ToLower()) { #region Variable Location Image case "path": try { path = openDirectory + DeZildrenAttributes.Value; image = (Bitmap)Bitmap.FromFile(path); } catch (FileNotFoundException) { AllErrors.Add("A Variable Location image's image does not exist or cannot be opened from where specified"); } break; #endregion #region Size of Variable Location Image case "size": if (!int.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out width) || !int.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out height)) { //Error parsing AllErrors.Add("Syntax error parsing the size of a Variable Location Image item"); } break; #endregion #region Location of Variable Location Image case "location": float Loc_x = 1.0f; float Loc_y = 1.0f; if (!float.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out Loc_x) || !float.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing AllErrors.Add("Syntax error parsing the location of a Variable Location image item"); } else { x = (int)Loc_x; y = (int)Loc_y; } break; #endregion #region Page of Button case "page": int newPage = -1; if (!int.TryParse(DeZildrenAttributes.Value, out newPage)) { AllErrors.Add("Syntax error parsing the page of a Variable Location Image item"); } else { bool isUniquePage = true; foreach (int Pagita in pages) { _BUSYFORM.UpdateBar(); if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { pages.Add(newPage); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(DeZildrenAttributes.Value, out z_order)) { AllErrors.Add("Syntax error parsing the depth of a Variable Location Image item"); } } break; #endregion #region Variable Location Image Value Range case "value_minimum": { if (!float.TryParse(DeZildrenAttributes.Value, out value_min)) { AllErrors.Add("Syntax error parsing the minimum value of a Variable Location Image item"); } } break; case "value_maximum": { if (!float.TryParse(DeZildrenAttributes.Value, out value_max)) { AllErrors.Add("Syntax error parsing the maximum value of a Variable Location Image item"); } } break; #endregion #region Variable Location Image Location Range case "location_minimum": { if (!int.TryParse(DeZildrenAttributes.Value, out location_min)) { AllErrors.Add("Syntax error parsing the minimum location of a Variable Location Image item"); } } break; case "location_maximum": { if (!int.TryParse(DeZildrenAttributes.Value, out location_max)) { AllErrors.Add("Syntax error parsing the maximum location of a Variable Location Image item"); } } break; #endregion #region Variable Location Image Translate Axis case "axis": { switch (DeZildrenAttributes.Value.ToLower()) { case "horizontal": axis = GlobalStaticClass.Axis.HORIZONTAL; break; case "vertical": axis = GlobalStaticClass.Axis.VERTICAL; break; default: AllErrors.Add("Syntax error parsing the translate axis of a Variable Location Image item"); break; } } break; #endregion #region Variable Location Target Type case "target_type": { targetType = DeZildrenAttributes.Value; } break; #endregion #region Variable Location Target ID case "target_id": { targetID = DeZildrenAttributes.Value; } break; #endregion #region Undefined or Error default: break; #endregion } } } if (image != null && pages.Count > 0 && width > 0 && height > 0 && x >= 0 && y >= 0 && path != "" && targetID != "" && targetType != "" && value_min < value_max && location_min < location_max) { GlobalStaticClass.FusionImage_VariableLocationImage tempVLI = new GlobalStaticClass.FusionImage_VariableLocationImage(); tempVLI._path = path; tempVLI._image = image; tempVLI._height = height; tempVLI._pages = new List(pages.ToArray()); tempVLI._width = width; tempVLI._x = x; tempVLI._y = y; tempVLI._z_order = z_order; tempVLI._location_minimum = location_min; tempVLI._location_maximum = location_max; tempVLI._value_minimum = value_min; tempVLI._value_maximum = value_max; tempVLI._target = targetType; tempVLI._targetID = targetID; tempVLI._translateAround = axis; GlobalStaticClass._Global_List_Graphics_VariableLocationImage.Add(tempVLI); } else { AllErrors.Add("A variable location image does not meet requirements to be displayed, it will be skipped"); } } break; #endregion #region Fusion Graph case "graph": { string name = GlobalStaticClass.FusionImage_Graph.GetUniqueName(); string timer = "logic timer"; int width = -1, height = -1, x = -1, y = -1; List pages = new List(); float z_order = 0.0f; float value_min = 0, value_max = 0; int time_min = 0, time_max = 0; int lineWidth = 1; Color colour = Color.Black; GlobalStaticClass.Axis axis = GlobalStaticClass.Axis.HORIZONTAL; string targetType = "", targetID = ""; bool smooth = false, fwdBias = false; int smoothNumbers = 10; foreach (XmlAttribute _at in GraphicSubNode.Attributes) { if (_at.Name.ToLower() == "id") { name = _at.Value; } } foreach (XmlNode DeZildrenOfDeVariableLocation in GraphicSubNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute DeZildrenAttributes in DeZildrenOfDeVariableLocation.Attributes) { _BUSYFORM.UpdateBar(); switch (DeZildrenAttributes.Name.ToLower()) { #region Size of Variable Location Image case "size": if (!int.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out width) || !int.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out height)) { //Error parsing AllErrors.Add("Syntax error parsing the size of a Variable Location Image item"); } break; #endregion #region Location of Variable Location Image case "location": float Loc_x = 1.0f; float Loc_y = 1.0f; if (!float.TryParse(DeZildrenAttributes.Value.Substring(0, DeZildrenAttributes.Value.IndexOf(',')), out Loc_x) || !float.TryParse(DeZildrenAttributes.Value.Substring(DeZildrenAttributes.Value.IndexOf(',') + 1), out Loc_y)) { //Error parsing AllErrors.Add("Syntax error parsing the location of a Variable Location image item"); } else { x = (int)Loc_x; y = (int)Loc_y; } break; #endregion #region Page of Button case "page": int newPage = -1; if (!int.TryParse(DeZildrenAttributes.Value, out newPage)) { AllErrors.Add("Syntax error parsing the page of a Variable Location Image item"); } else { bool isUniquePage = true; foreach (int Pagita in pages) { _BUSYFORM.UpdateBar(); if (Pagita == newPage) { isUniquePage = false; break; } } if (isUniquePage) { pages.Add(newPage); } } break; #endregion #region Z-Order case "z_order": { if (!float.TryParse(DeZildrenAttributes.Value, out z_order)) { AllErrors.Add("Syntax error parsing the depth of a Variable Location Image item"); } } break; #endregion #region Line Width case "line_width": { if (!int.TryParse(DeZildrenAttributes.Value, out lineWidth)) { AllErrors.Add("Syntax error parsing the depth of a Variable Location Image item"); } } break; #endregion #region Timer case "timer": { switch (DeZildrenAttributes.Value.ToLower().ToCharArray()[0]) { case 'l': timer = "Logic Timer"; break; case 'i': timer = "Input Timer"; break; case 'o': timer = "Output Timer"; break; case 'g': timer = "Gui Timer"; break; } } break; #endregion #region Line Colour case "line_colour": { char[] argb_split = { ',' }; string[] argb_string = DeZildrenAttributes.Value.Split(argb_split); int[] argb_int = new int[4]; for (int argb_i = 0; argb_i < 4; argb_i++) { int.TryParse(argb_string[argb_i], out argb_int[argb_i]); } colour = Color.FromArgb(argb_int[0], argb_int[1], argb_int[2], argb_int[3]); } break; #endregion #region Variable Location Image Value Range case "value_minimum": { if (!float.TryParse(DeZildrenAttributes.Value, out value_min)) { AllErrors.Add("Syntax error parsing the minimum value of a Variable Location Image item"); } } break; case "value_maximum": { if (!float.TryParse(DeZildrenAttributes.Value, out value_max)) { AllErrors.Add("Syntax error parsing the maximum value of a Variable Location Image item"); } } break; #endregion #region Variable Location Image Location Range case "time_minimum": { if (!int.TryParse(DeZildrenAttributes.Value, out time_min)) { AllErrors.Add("Syntax error parsing the minimum location of a Variable Location Image item"); } } break; case "time_maximum": { if (!int.TryParse(DeZildrenAttributes.Value, out time_max)) { AllErrors.Add("Syntax error parsing the maximum location of a Variable Location Image item"); } } break; #endregion #region Variable Location Image Translate Axis case "axis": { switch (DeZildrenAttributes.Value.ToLower()) { case "horizontal": axis = GlobalStaticClass.Axis.HORIZONTAL; break; case "vertical": axis = GlobalStaticClass.Axis.VERTICAL; break; default: AllErrors.Add("Syntax error parsing the translate axis of a Variable Location Image item"); break; } } break; #endregion #region Variable Location Target Type case "target_type": { targetType = DeZildrenAttributes.Value; } break; #endregion #region Variable Location Target ID case "target_id": { targetID = DeZildrenAttributes.Value; } break; #endregion #region Smoothing case "smooth_enabled": { smooth = (DeZildrenAttributes.Value.ToLower() == "true"); } break; case "smooth_forwardbias": { fwdBias = (DeZildrenAttributes.Value.ToLower() == "true"); } break; case "smooth_number": { int.TryParse(DeZildrenAttributes.Value, out smoothNumbers); } break; #endregion #region Undefined or Error default: break; #endregion } } } if (pages.Count > 0 && width > 0 && height > 0 && x >= 0 && y >= 0 && name != "" && targetID != "" && targetType != "" && value_min < value_max && time_max > 0) { GlobalStaticClass.FusionImage_Graph tempGPH = new GlobalStaticClass.FusionImage_Graph(); tempGPH._name = name; tempGPH._image = new Bitmap(width, height); Graphics g = Graphics.FromImage(tempGPH._image); g.Clear(colour); g.Dispose(); tempGPH._height = height; tempGPH._pages = new List(pages.ToArray()); tempGPH._width = width; tempGPH._x = x; tempGPH._y = y; tempGPH._z_order = z_order; tempGPH._time_maximum = time_max; tempGPH._value_minimum = value_min; tempGPH._value_maximum = value_max; tempGPH._target = targetType; tempGPH._targetID = targetID; tempGPH._graphingAxis = axis; tempGPH._lineThickness = lineWidth; tempGPH._lineColour = colour; tempGPH._timer = timer; tempGPH._smooth = smooth; tempGPH._smoothNumbers = smoothNumbers; tempGPH._forwardBiasNotReverseBias = fwdBias; GlobalStaticClass._Global_List_Graphics_Graphs.Add(tempGPH); } else { AllErrors.Add("A graph instance does not meet requirements to be displayed, it will be skipped"); } } break; #endregion #region Text Label case "text_label": { GlobalStaticClass.FusionFont_TextLabel _tempDisplayTextLabel = new GlobalStaticClass.FusionFont_TextLabel(); string _textLabel_ID = ""; string _textLabel_AutoMonitorType = ""; string _textLabel_AutoMonitorID = ""; string _textLabel_Text = ""; foreach (XmlAttribute _txtAttribute in GraphicSubNode.Attributes) { switch (_txtAttribute.Name.ToLower()) { case "id": _textLabel_ID = _txtAttribute.Value; break; case "auto_monitor": _textLabel_AutoMonitorType = _txtAttribute.Value.ToLower(); break; case "auto_monitortarget": _textLabel_AutoMonitorID = _txtAttribute.Value.ToLower(); break; case "text": _textLabel_Text = _txtAttribute.Value; break; default: break; } } _tempDisplayTextLabel._autoMonitor = _textLabel_AutoMonitorType; _tempDisplayTextLabel._autoMonitorTargetID = _textLabel_AutoMonitorID; _tempDisplayTextLabel._name = _textLabel_ID; _tempDisplayTextLabel._text = _textLabel_Text; foreach (XmlNode _nodeAutoText in GraphicSubNode.ChildNodes) { foreach (XmlAttribute _nodeAutoTextAttribute in _nodeAutoText.Attributes) { switch (_nodeAutoTextAttribute.Name.ToLower()) { case "font_id": _tempDisplayTextLabel._fontName = _nodeAutoTextAttribute.Value; break; case "font_size": float.TryParse(_nodeAutoTextAttribute.Value.ToLower(), out _tempDisplayTextLabel._fontSize); break; case "colour": { char[] argb_split = { ',' }; string[] argb_string = _nodeAutoTextAttribute.Value.Split(argb_split); int[] argb_int = new int[4]; for (int argb_i = 0; argb_i < 4; argb_i++) { int.TryParse(argb_string[argb_i], out argb_int[argb_i]); } _tempDisplayTextLabel._colour = Color.FromArgb(argb_int[0], argb_int[1], argb_int[2], argb_int[3]); } break; case "location": { string[] _locSArray = _nodeAutoTextAttribute.Value.ToLower().Split(new char[] { ',' }); if (_locSArray.Length == 2) { if (!int.TryParse(_locSArray[0], out _tempDisplayTextLabel._x) || !int.TryParse(_locSArray[1], out _tempDisplayTextLabel._y)) { continue; } } } break; case "page": { int _tempPageInt = 0; int.TryParse(_nodeAutoTextAttribute.Value, out _tempPageInt); bool _tempPage_isUnique = true; foreach (int _tempPageCheck in _tempDisplayTextLabel._pages) { if (_tempPageInt == _tempPageCheck) { _tempPage_isUnique = false; break; } } if (_tempPage_isUnique) { _tempDisplayTextLabel._pages.Add(_tempPageInt); } } break; case "decimals": { int _tempDecInt = 1; int.TryParse(_nodeAutoTextAttribute.Value, out _tempDecInt); _tempDisplayTextLabel._maxDecimals = _tempDecInt; } break; case "max_size": { string[] _maxSArray = _nodeAutoTextAttribute.Value.ToLower().Split(new char[] { ',' }); if (_maxSArray.Length == 2) { if (!int.TryParse(_maxSArray[0], out _tempDisplayTextLabel._width) || !int.TryParse(_maxSArray[1], out _tempDisplayTextLabel._height)) { continue; } } } break; default: break; } } } _tempDisplayTextLabel._image = new Bitmap(_tempDisplayTextLabel._width, _tempDisplayTextLabel._height); Graphics _gggg = Graphics.FromImage(_tempDisplayTextLabel._image); _gggg.Clear(_tempDisplayTextLabel._colour); _gggg.Dispose(); GlobalStaticClass._Global_List_Graphics_TextLabels.Add(_tempDisplayTextLabel); } break; #endregion #region Error or Undefined Value case "#comment": break; default: //Not recognized as a type... break; #endregion } } } #endregion #region I/O Setup else if (subTopConfigNode.Name.ToLower() == "io") { //Setup of Brain Instances and I/O Channels XmlNodeList IONodes = subTopConfigNode.ChildNodes; foreach (XmlNode ioConfigNode in IONodes) { _BUSYFORM.UpdateBar(); #region Configure Attached Brains if (ioConfigNode.Name.ToLower() == "brain") { string instanceread = ""; string humanNameread = ""; int versionread = 4; foreach (XmlAttribute idNode in ioConfigNode.Attributes) { _BUSYFORM.UpdateBar(); if (idNode.Name.ToLower() == "id") { humanNameread = idNode.Value; } else if (idNode.Name.ToLower() == "version") { int.TryParse(idNode.Value, out versionread); } } if (humanNameread == "") { AllErrors.Add("Error in Brain ID specified in configuration file"); GetRidOfBusyForm(_BUSYFORM); return false; } if (ioConfigNode.FirstChild == null) { AllErrors.Add("Error in USB Instance ID declaration of Fusion Brain \"" + humanNameread + "\" in configuration file"); GetRidOfBusyForm(_BUSYFORM); return false; } instanceread = ioConfigNode.FirstChild.Value.ToLower(); bool isUnique = true; for (int brain_i = 0; brain_i < GlobalStaticClass._Global_List_Brains.Count; brain_i++) { if (GlobalStaticClass._Global_List_Brains[brain_i]._humanName.ToLower() == humanNameread.ToLower()) { isUnique = false; break; } } if (isUnique) { new GlobalStaticClass._GlobalBrainClass(humanNameread, instanceread, versionread); } else { AllErrors.Add("A brain instance with this ID has already been added, skipping"); } } #endregion #region Configure Timers else if (ioConfigNode.Name.ToLower() == "timer") { int newInterval = -1; foreach (XmlAttribute timerIntervalAttribute in ioConfigNode.Attributes) { _BUSYFORM.UpdateBar(); if (timerIntervalAttribute.Name.ToLower() == "interval") { int.TryParse(timerIntervalAttribute.Value, out newInterval); break; } } if (newInterval == -1) { AllErrors.Add("A timer declaration has no interval value, it will be skipped and set to defaults"); continue; } foreach (XmlAttribute timerAttribute in ioConfigNode.Attributes) { _BUSYFORM.UpdateBar(); if (timerAttribute.Name.ToLower() == "id") { switch (timerAttribute.Value.ToLower()) { case "logic": GlobalStaticClass._GlobalTimerClass._timer_Logic = newInterval; break; case "gui": GlobalStaticClass._GlobalTimerClass._timer_GUI = newInterval; break; case "output": GlobalStaticClass._GlobalTimerClass._timer_Output = newInterval; break; case "input": GlobalStaticClass._GlobalTimerClass._timer_Input = newInterval; break; default: break; } } } } #endregion #region Configure I/O Channels else if (ioConfigNode.Name.ToLower() == "iochannel") { string read_string_port = ""; string read_string_brain = ""; string read_string_id = ""; string read_string_type = ""; int read_int_port; #region Read In and Verify Required Settings foreach (XmlAttribute newChannelAttribute in ioConfigNode.Attributes) { _BUSYFORM.UpdateBar(); if (newChannelAttribute.Name.ToLower() == "id") { read_string_id = newChannelAttribute.Value; } else if (newChannelAttribute.Name.ToLower() == "port") { read_string_port = newChannelAttribute.Value.ToLower(); } else if (newChannelAttribute.Name.ToLower() == "brain") { read_string_brain = newChannelAttribute.Value.ToLower(); } else if (newChannelAttribute.Name.ToLower() == "type") { read_string_type = newChannelAttribute.Value.ToLower(); } } if (read_string_brain == "" || read_string_id == "" || read_string_port == "" || read_string_type == "") { //Minimum channel requirements not met... AllErrors.Add("There is an error in a I/O Channel declaration."); continue; } if (!int.TryParse(read_string_port, out read_int_port)) { AllErrors.Add("Invalid Port in a I/O Channel in the configuration channel. I/O Channel ID: " + read_string_id); continue; } #endregion switch (read_string_type) { #region Digital Output Configuration case "digital_output": GlobalStaticClass._GlobalDigitalOutputClass Temp_DOC = new GlobalStaticClass._GlobalDigitalOutputClass(read_string_brain, read_int_port, read_string_id, "off"); #region Extra Digital Output Only Options foreach (XmlNode doChildren in ioConfigNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute ioAttributes in doChildren.Attributes) { _BUSYFORM.UpdateBar(); switch (ioAttributes.Name.ToLower()) { #region The On/Off State of the Output on Program Start case "defaultstate": if (ioAttributes.Value.ToLower() == "on") { Temp_DOC._defaultState = true; } else if (ioAttributes.Value.ToLower() == "off") { Temp_DOC._defaultState = false; } break; #endregion #region Errors or Unknown default: break; #endregion } } } #endregion break; #endregion #region Analogue Input Configuration case "analogue_input": GlobalStaticClass._GlobalAnalogueInputClass Temp_AIC = new GlobalStaticClass._GlobalAnalogueInputClass(read_string_brain, read_int_port, read_string_id, "true", 15); #region Extra Analogue Input Only Options foreach (XmlNode doChildren in ioConfigNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute ioAttributes in doChildren.Attributes) { _BUSYFORM.UpdateBar(); switch (ioAttributes.Name.ToLower()) { #region Maximum History Points To Store case "history": int newHistory = 200; if (!int.TryParse(ioAttributes.Value, out newHistory)) { AllErrors.Add("Error Parsing Analogue History Value. ID: " + read_string_id); } Temp_AIC._historyKeeping = newHistory; break; #endregion #region Current Value is Actual or Averaged case "auto_average": if (ioAttributes.Value.ToLower() == "true") { Temp_AIC._autoAverage = true; } else if (ioAttributes.Value.ToLower() == "false") { Temp_AIC._autoAverage = false; } break; #endregion #region Errors or Unknown default: break; #endregion } } } #endregion break; #endregion #region Digital Input Configuration - UNSUPPORTED case "digital_input": /* DigitalInputChannel Temp_DIC = new DigitalInputChannel(read_string_brain, read_string_id, read_int_port); AllDigitalInputs.Add(Temp_DIC); */ break; #endregion #region Error in Type default: AllErrors.Add("I/O Channel is of an invalid type. I/O Channel ID: " + read_string_id); continue; #endregion } } #endregion } } #endregion #region Logic else if (subTopConfigNode.Name.ToLower() == "logic") { //Setup of Logic area foreach (XmlNode logicTopNode in subTopConfigNode.ChildNodes) { _BUSYFORM.UpdateBar(); #region Variables if (logicTopNode.Name.ToLower() == "all_variables") { foreach (XmlNode variableNode in logicTopNode) { _BUSYFORM.UpdateBar(); if (variableNode.Name.ToLower() == "variable") { if (variableNode.FirstChild == null) { AllErrors.Add("Error in a variable declaration - no initial value"); continue; } else { object read_initial_value = null; double read_initial_value_double = 0.0; bool read_initial_value_bool = false; string read_name = ""; if (double.TryParse(variableNode.FirstChild.Value, out read_initial_value_double)) { read_initial_value = read_initial_value_double; } else if (bool.TryParse(variableNode.FirstChild.Value, out read_initial_value_bool)) { read_initial_value = read_initial_value_bool; } else { AllErrors.Add("Error in a variable declaration - no initial value"); continue; } foreach (XmlAttribute variableAttribute in variableNode.Attributes) { _BUSYFORM.UpdateBar(); if (variableAttribute.Name.ToLower() == "name") { read_name = variableAttribute.Value.ToLower(); } } if (read_name == "") { AllErrors.Add("Error in a variable declaration - no reference value"); continue; } bool isUnique = true; for (int variable_i = 0; variable_i < GlobalStaticClass._Global_List_Variables.Count; variable_i++) { if (GlobalStaticClass._Global_List_Variables[variable_i]._id == read_name) { isUnique = false; break; } } if (isUnique) { new GlobalStaticClass._GlobalVariableClass(read_name, read_initial_value); } } } } } #endregion #region Logs else if (logicTopNode.Name.ToLower() == "all_logging") { foreach (XmlNode logNode in logicTopNode) { _BUSYFORM.UpdateBar(); if (logNode.Name.ToLower() == "log") { string temp_logID = ""; string temp_logMonitorType = ""; string temp_logMonitorID = ""; string temp_logFireOn = "logic"; bool temp_monitorState = false; string temp_filename = ""; string temp_dataname = ""; string temp_datafrom = ""; bool temp_holdstreamopen = false; int temp_storebeforedump = 150; foreach (XmlAttribute logAttribute in logNode.Attributes) { _BUSYFORM.UpdateBar(); if (logAttribute.Name.ToLower() == "logid") { temp_logID = logAttribute.Value.ToLower(); foreach (GlobalStaticClass._GlobalLogClass test_LogClass in GlobalStaticClass._Global_List_Logs) { _BUSYFORM.UpdateBar(); if (temp_logID == test_LogClass._id) { AllErrors.Add("Another Log has the same ID: " + temp_logID); continue; } } } else if (logAttribute.Name.ToLower() == "monitortype") { temp_logMonitorType = logAttribute.Value.ToLower(); } else if (logAttribute.Name.ToLower() == "targetid") { temp_logMonitorID = logAttribute.Value.ToLower(); } else if (logAttribute.Name.ToLower() == "fire_on") { temp_logFireOn = logAttribute.Value.ToLower(); } } if (temp_logID != "" && temp_logMonitorID != "" && temp_logMonitorType != "") { foreach (XmlNode logChildNode in logNode.ChildNodes) { _BUSYFORM.UpdateBar(); foreach (XmlAttribute logChildAttribute in logChildNode.Attributes) { _BUSYFORM.UpdateBar(); switch (logChildAttribute.Name.ToLower()) { case "defaultmonitorstate": if (logChildAttribute.Value.ToLower() == "on") { temp_monitorState = true; } else { temp_monitorState = false; } break; case "filename": temp_filename = logChildAttribute.Value; break; case "dataname": temp_dataname = logChildAttribute.Value; break; case "datafrom": temp_datafrom = logChildAttribute.Value.ToLower(); break; case "holdstreamopen": if (logChildAttribute.Value.ToLower() == "true") { temp_holdstreamopen = true; } else { temp_holdstreamopen = false; } break; case "storebeforedumping": int.TryParse(logChildAttribute.Value, out temp_storebeforedump); break; default: //Error or Unknown break; } } } new GlobalStaticClass._GlobalLogClass(temp_logID, temp_logMonitorType, temp_logMonitorID, temp_logFireOn, temp_datafrom, temp_monitorState, temp_holdstreamopen, temp_storebeforedump, temp_dataname, temp_filename); } else { //Not enough Log info AllErrors.Add("Log does not meet minimum requirements for adding to configuration, it will be skipped"); } } else { //Error or Unknown } } } #endregion #region Statements else if (logicTopNode.Name.ToLower() == "all_statements") { GlobalStaticClass.Functions_ParseXMLLogicToDesigner(logicTopNode, this, AllErrors, _BUSYFORM); } #endregion } } #endregion } #endregion } catch (Exception e) { (new ErrorForm("Unexpected Error", e.ToString())).ShowDialog(); noErrors = false; } #region SetUp Graphics GlobalStaticClass.GraphicsSort(); List Global_NeededPages = new List(); foreach (GlobalStaticClass.FusionFont_TextLabel _TL in GlobalStaticClass._Global_List_Graphics_TextLabels) { foreach (int p in _TL._pages) { if (!Global_NeededPages.Contains(p)) { Global_NeededPages.Add(p); } } } foreach (GlobalStaticClass.ZOrder_QuelleListeLookupItem _z in GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images) { _BUSYFORM.UpdateBar(); switch (_z._ListReferenceType) { case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_BACKGROUND: { int p = GlobalStaticClass._Global_List_Graphics_BackgroundImage[_z._IndexInList]._page; if (!Global_NeededPages.Contains(p)) { Global_NeededPages.Add(p); } break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_DISPLAYBUTTONS: { foreach (int sub_p in GlobalStaticClass._Global_List_Graphics_DisplayButton[_z._IndexInList]._pages) { _BUSYFORM.UpdateBar(); if (!Global_NeededPages.Contains(sub_p)) { Global_NeededPages.Add(sub_p); } } break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_MULTIIMAGES: { foreach (int sub_p in GlobalStaticClass._Global_List_Graphics_MultiImage[_z._IndexInList]._pages) { _BUSYFORM.UpdateBar(); if (!Global_NeededPages.Contains(sub_p)) { Global_NeededPages.Add(sub_p); } } break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_ROTATEIMAGES: { break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_STATICIMAGES: { foreach (int sub_p in GlobalStaticClass._Global_List_Graphics_StaticImage[_z._IndexInList]._pages) { _BUSYFORM.UpdateBar(); if (!Global_NeededPages.Contains(sub_p)) { Global_NeededPages.Add(sub_p); } } break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_VARIABLELOCATION: { foreach (int sub_p in GlobalStaticClass._Global_List_Graphics_VariableLocationImage[_z._IndexInList]._pages) { _BUSYFORM.UpdateBar(); if (!Global_NeededPages.Contains(sub_p)) { Global_NeededPages.Add(sub_p); } } break; } case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_GRAPH: { foreach (int sub_p in GlobalStaticClass._Global_List_Graphics_Graphs[_z._IndexInList]._pages) { _BUSYFORM.UpdateBar(); if (!Global_NeededPages.Contains(sub_p)) { Global_NeededPages.Add(sub_p); } } break; } default: break; } } foreach (int pageNeeded in Global_NeededPages) { _BUSYFORM.UpdateBar(); Bitmap _tempBitmap = new Bitmap(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); _tempBitmap = GraphicLayoutEditorForm.UpdateGraphics_DrawToBitmap(GraphicLayoutEditorForm.RenderLevel.TEXTURED, GraphicLayoutEditorForm.MouseStatus.NOTHING, _tempBitmap, pageNeeded, null); GlobalStaticClass._Global_List_Graphics_PageList.Add(new GlobalStaticClass.GraphicsPage(_tempBitmap, pageNeeded)); } if (GlobalStaticClass._Global_List_Graphics_PageList.Count > 0) { CurrentGraphicPage = 0; } else { CurrentGraphicPage = -1; } this.DialogResult = DialogResult.None; #endregion UpdateGraphicsPageAreaAndEnableOrDisableButtons(); ReloadAllFunctions(); ReloadAllFonts(); if (!GlobalStaticClass.PseudoFont_BindRelations(AllPsuedoBindings)) { AllErrors.Add("Could not bind all text instances to font instances in this config file"); } MYBUFFA_OLD = UpdateTextualAndList(); GetRidOfBusyForm(_BUSYFORM); #region Show Errors if (AllErrors.Count > 0) { noErrors = false; (new OpenFileErrorDisplayForm(AllErrors)).ShowDialog(); } #endregion return noErrors; } catch (Exception e2) { (new ErrorForm("Unexpected Error", e2.ToString())).ShowDialog(); ClearEverything(); return false; } } #endregion #region New Configuration Icon Clicked private void TSB_NEW_Click(object sender, EventArgs e) { string _new = "", _old = ""; if (MYBUFFA_OLD != "" && MYBUFFA_OLD.Contains(" last_modified=\"")) { _new = MYBUFFA.Substring(0, MYBUFFA.IndexOf(" last_modified=\"")) + MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA.Substring(MYBUFFA.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); _old = MYBUFFA_OLD.Substring(0, MYBUFFA_OLD.IndexOf(" last_modified=\"")) + MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).Substring(MYBUFFA_OLD.Substring(MYBUFFA_OLD.IndexOf(" last_modified=\"") + " last_modified=\"".Length).IndexOf("\"") + 1); } if (_new != _old) { switch ((new ConfirmDialogForm("Save Work", "Save Current Configuration?", "Would you like to save the current configuration file?")).ShowDialog()) { case DialogResult.OK: SaveConfigurationFile(); break; case DialogResult.Cancel: return; } } ClearEverything(); UpdateTextualAndList(); UpdateGraphicsPageAreaAndEnableOrDisableButtons(); } #endregion #region Speech Configuration private void TSB_Speech_Click(object sender, EventArgs e) { SpeechConfigForm _sCF = new SpeechConfigForm(); _sCF.ShowDialog(); UpdateTextualAndList(); } #endregion #region Debugging Setup private void TSB_DEBUG_Click(object sender, EventArgs e) { DebuggingForm _dF = new DebuggingForm(); _dF.ShowDialog(); UpdateTextualAndList(); } #endregion #region Ninja Kitty Wizzard private void TSB_MAGIC_NINJA_Click(object sender, EventArgs e) { NINJA_WIZARD_OPEN(); } private void NINJA_WIZARD_OPEN() { try { NINJA_Form_Base _nF_wizard = new NINJA_Form_Base(this); if (!_nF_wizard.LoadTemplates()) { (new ErrorForm("No Templates", "There were no installed templates found, the wizard cannot output a file without at least 1 template")).ShowDialog(); this.DialogResult = DialogResult.None; return; } else { if (_nF_wizard.ShowDialog() == DialogResult.OK) { this.DialogResult = DialogResult.None; UpdateGraphicsPageAreaAndEnableOrDisableButtons(); ReloadAllFunctions(); ReloadAllFonts(); //if (!GlobalStaticClass.PseudoFont_BindRelations(AllPsuedoBindings)) { AllErrors.Add("Could not bind all text instances to font instances in this config file"); } MYBUFFA_OLD = UpdateTextualAndList(); } } } catch (Exception e) { (new ErrorForm("Unknown Ninja Error", "Please report the following error to us:\r\n" + e.ToString())).ShowDialog(); this.DialogResult = DialogResult.None; } } #endregion #region Remote Control private void TSB_RemoteControl_Click(object sender, EventArgs e) { RemoteControlForm _rCF = new RemoteControlForm(); if (_rCF.ShowDialog() == DialogResult.OK) { _rCF.Save_Info(); } } #endregion private void TSB_COM_Click(object sender, EventArgs e) { COM_SetupForm _csf = new COM_SetupForm(); _csf.Show(); } } }