public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mLogCallback = new LogCallback(LogCallback); mKey = Registry.CurrentUser.CreateSubKey(@"Software\Earlab\DesktopEarlabGUI"); mModuleDirectory = new RegistryString(mKey, "ModuleDirectory", null); mOutputDirectory = new RegistryString(mKey, "OutputDirectory", null); mDiagramFile = new RegistryString(mKey, "RunParameterFile", null); mParameterFile = new RegistryString(mKey, "ModuleParameterFile", null); mFrameCount = new RegistryInt(mKey, "FrameCount", 0); udFrameCount.Value = mFrameCount.Value; mWindowState = new RegistryFormWindowState(mKey, "WindowState", FormWindowState.Normal); mWindowLocation = new RegistryPoint(mKey, "WindowLocation", this.Location); mWindowSize = new RegistrySize(mKey, "WindowSize", this.MinimumSize); this.Location = mWindowLocation.Value; this.Size = mWindowSize.Value; this.WindowState = mWindowState.Value; udFrameCount.Focus(); UpdateStatusDisplay(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mModuleKey = Registry.LocalMachine.CreateSubKey(@"Software\EarLab"); mApplicationKey = Registry.CurrentUser.CreateSubKey(@"Software\EarLab\EarLab GUI"); mLogCallback = new LogCallback(LogCallback); mModuleDirectory = new RegistryString(mModuleKey, "ModulesPath", @"C:\Program Files\EarLab\Modules"); mInputDirectory = new RegistryString(mApplicationKey, "InputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Signals"); mOutputDirectory = new RegistryString(mApplicationKey, "OutputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Output"); mDiagramFile = new RegistryString(mApplicationKey, "RunParameterFile", null); mParameterFile = new RegistryString(mApplicationKey, "ModuleParameterFile", null); mFrameCount = new RegistryInt(mApplicationKey, "FrameCount", 0); mEnableSuperuserMode = new RegistryBool(mApplicationKey, "SuperuserMode", false); udFrameCount.Value = mFrameCount.Value; mWindowState = new RegistryFormWindowState(mApplicationKey, "WindowState", FormWindowState.Normal); mWindowLocation = new RegistryPoint(mApplicationKey, "WindowLocation", this.Location); mWindowSize = new RegistrySize(mApplicationKey, "WindowSize", this.MinimumSize); this.Location = mWindowLocation.Value; this.Size = mWindowSize.Value; this.WindowState = mWindowState.Value; if (mEnableSuperuserMode.Value) { menuEnvironment.Enabled = true; menuEnvironment.Visible = true; menuFileOpenDiagram.Enabled = true; menuFileOpenDiagram.Visible = true; menuFileOpenParameters.Enabled = true; menuFileOpenParameters.Visible = true; menuFileSeparator.Enabled = true; menuFileSeparator.Visible = true; } udFrameCount.Focus(); UpdateStatusDisplay(); }
private void Init(RegistryKey theKey, string ParameterName, Rectangle DefaultValue) { Location = new RegistryPoint(theKey, ParameterName + "_Location", DefaultValue.Location); Size = new RegistrySize(theKey, ParameterName + "_Size", DefaultValue.Size); }
public Form1(string [] args) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mModuleKey = Registry.LocalMachine.CreateSubKey(@"Software\EarLab"); mApplicationKey = Registry.CurrentUser.CreateSubKey(@"Software\EarLab\EarLab GUI"); mLogCallback = new LogCallback(LogCallback); mModuleDirectory = new RegistryString(mModuleKey, "ModulesPath", @"C:\Program Files\EarLab\Modules"); mInputDirectory = new RegistryString(mApplicationKey, "InputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Signals"); mOutputDirectory = new RegistryString(mApplicationKey, "OutputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Output"); mDiagramFile = new RegistryString(mApplicationKey, "RunParameterFile", null); mParameterFile = new RegistryString(mApplicationKey, "ModuleParameterFile", null); mFrameCount = new RegistryInt(mApplicationKey, "FrameCount", 0); mEnableSuperuserMode = new RegistryBool(mApplicationKey, "SuperuserMode", false); udFrameCount.Value = mFrameCount.Value; mWindowState = new RegistryFormWindowState(mApplicationKey, "WindowState", FormWindowState.Normal); mWindowLocation = new RegistryPoint(mApplicationKey, "WindowLocation", this.Location); mWindowSize = new RegistrySize(mApplicationKey, "WindowSize", this.MinimumSize); this.Location = mWindowLocation.Value; this.Size = mWindowSize.Value; this.WindowState = mWindowState.Value; if (mEnableSuperuserMode.Value) { menuEnvironment.Enabled = true; menuEnvironment.Visible = true; menuFileOpenDiagram.Enabled = true; menuFileOpenDiagram.Visible = true; menuFileOpenParameters.Enabled = true; menuFileOpenParameters.Visible = true; menuFileSeparator.Enabled = true; menuFileSeparator.Visible = true; } if (args.Length > 0) { bool dashN = false; // -n <FrameCount> bool dashI = false; // -i <InputDirectory> bool dashO = false; // -o <OutputDirectory> bool DiagramFileSpecified = false; bool ParameterFileSpecified = false; RunningFromCommandLineInput = false; try { for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-n": try { FrameCount = int.Parse(args[++i]); dashN = true; } catch (FormatException) { throw new ApplicationException("Frame count (-n) must be a non-zero positive integer. \"" + args[i] + "\" is invalid"); } break; case "-m": ModuleDirectory = args[++i]; break; case "-i": InputDirectory = args[++i]; dashI = true; break; case "-o": OutputDirectory = args[++i]; dashO = true; break; case "-l": LoadAndWait = true; break; default: if (!DiagramFileSpecified) { DiagramFile = args[i]; DiagramFileSpecified = true; } else { if (!ParameterFileSpecified) { ParameterFile = args[i]; ParameterFileSpecified = true; } else { throw new ApplicationException("Too many parameters specified"); } } break; } // switch } // for if (dashN && dashI && dashO && DiagramFileSpecified && ParameterFileSpecified) { RunningFromCommandLineInput = true; } } // try catch (ApplicationException e) { string Message; Message = e.Message + "\n"; Message += "Usage: EarLabGUI -n <NumFrames> [-m <ModuleDirectory>] [-i <InputDirectory>] [-o <OutputDirectory>]\n"; Message += " <DiagramFile> <ParameterFile>\n"; Message += "\n"; Message += "Where: <NumFrames> is a positive integer which is the number of frames over\n"; Message += " which the simulation will be run\n"; Message += " <ModuleDirectory> is a directory path that contains the module executables\n"; Message += " that will be used for this simulation. If this option is not provided,\n"; Message += " the module directory defaults to the directory into which EarLab was installed.\n"; Message += " <InputDirectory> is a directory path that contains the input files for the model.\n"; Message += " <OutputDirectory> is a directory path that will contain the output files produced by the model.\n"; Message += " <DiagramFile> is a file that describes an Earlab model\n"; Message += " <ParameterFile> is a parameter file that contains parameter definitions\n"; Message += " for all modules specified by the <DiagramFile>.\n"; System.Windows.Forms.MessageBox.Show(Message); } } else { RunningFromCommandLineInput = false; } if (LoadAndWait) { RunningFromCommandLineInput = false; } udFrameCount.Focus(); UpdateStatusDisplay(); if (RunningFromCommandLineInput) { timerCommandlineRun.Enabled = true; } }