private void OpenAssembly(object sender, EventArgs e)
        {
            DialogResult result = openProcessExeDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try {
                    _assembly = Assembly.Load(File.ReadAllBytes(openProcessExeDialog.FileName));
                    MethodInfo m = _assembly.GetModules(false)[0].GetMethod("Main");
                    if (m == null)
                    {
                        MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to have been compiled with the PLR!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                } catch (Exception) {
                    MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to be a .NET assembly!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                btnStart.Enabled     = true;
                btnStartStep.Enabled = true;
                this.Text            = "Process Viewer - " + openProcessExeDialog.FileName;
                ClearAll();
                result               = openProcessSourceDialog.ShowDialog();
                _loadedSystem        = null;
                _visual              = null;
                txtProcessState.Text = "";
                if (result == DialogResult.Cancel)
                {
                    MessageBox.Show("No source file selected. Visualization of the current state of the system will not be available during execution", "No source file chosen", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (result == DialogResult.OK)
                {
                    _sourceFile          = openProcessSourceDialog.FileName;
                    txtProcessState.Text = File.ReadAllText(_sourceFile);
                    string ext = Path.GetExtension(_sourceFile).ToLower().Substring(1);
                    if (!_parsers.ContainsKey(ext))
                    {
                        ErrorMsg("No suitable parser found", "No parser is loaded that parses files of type \"" + ext + "\"");
                    }
                    else
                    {
                        _parser = _parsers[ext];
                        try {
                            _loadedSystem = _parser.Parse(_sourceFile);
                            FindUnsupportedNodes f = new FindUnsupportedNodes();
                            f.Start(_loadedSystem);
                            if (f.typeName != "")
                            {
                                MessageBox.Show("Sorry, visualization are currently not supported for systems that use the class " + f.typeName + ", however, the application can be run without visualization!", "Cannot show visualization", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                _loadedSystem = null;
                            }
                        } catch (ParseException pex) {
                            ErrorMsg("Failed to parse source file", "Failed to parse source file " + _sourceFile + ", error: \n" + pex.Message);
                        }
                    }
                }
            }
        }
 private void StartExecutionInStepMode(object sender, EventArgs e)
 {
     if (_status == RunStatus.Stopped)
     {
         if (_loadedSystem != null)
         {
             _visual = new ProcessStateVisualization(_loadedSystem, _parser.Formatter);
         }
     }
     _status = RunStatus.Stepping;
     ClearAll();
     processThreadWorker.RunWorkerAsync();
     EnableControls();
 }
 private void StartExecution(object sender, EventArgs e)
 {
     if (_status == RunStatus.Stopped)
     {
         if (_loadedSystem != null)
         {
             _visual = new ProcessStateVisualization(_loadedSystem, _parser.Formatter);
         }
         _status = RunStatus.Running;
         ClearAll();
         processThreadWorker.RunWorkerAsync();
     }
     else if (_status == RunStatus.Stepping)
     {
         _status = RunStatus.Running;
         if (lstCandidateActions.Items.Count > 0)
         {
             _chosenAction = (CandidateAction)lstCandidateActions.Items[_rng.Next(lstCandidateActions.Items.Count)];
         }
     }
     EnableControls();
 }
 private void StartExecutionInStepMode(object sender, EventArgs e)
 {
     if (_status == RunStatus.Stopped) {
         if (_loadedSystem != null) {
             _visual = new ProcessStateVisualization(_loadedSystem, _parser.Formatter);
         }
     }
     _status = RunStatus.Stepping;
     ClearAll();
     processThreadWorker.RunWorkerAsync();
     EnableControls();
 }
 private void StartExecution(object sender, EventArgs e)
 {
     if (_status == RunStatus.Stopped) {
         if (_loadedSystem != null) {
             _visual = new ProcessStateVisualization(_loadedSystem, _parser.Formatter);
         }
         _status = RunStatus.Running;
         ClearAll();
         processThreadWorker.RunWorkerAsync();
     } else if (_status == RunStatus.Stepping) {
         _status = RunStatus.Running;
         if (lstCandidateActions.Items.Count > 0) {
             _chosenAction = (CandidateAction)lstCandidateActions.Items[_rng.Next(lstCandidateActions.Items.Count)];
         }
     }
     EnableControls();
 }
        private void OpenAssembly(object sender, EventArgs e)
        {
            DialogResult result = openProcessExeDialog.ShowDialog();
            if (result == DialogResult.OK) {
                try {
                    _assembly = Assembly.Load(File.ReadAllBytes(openProcessExeDialog.FileName));
                    MethodInfo m = _assembly.GetModules(false)[0].GetMethod("Main");
                    if (m == null) {
                        MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to have been compiled with the PLR!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                } catch (Exception) {
                    MessageBox.Show("Unable to open assembly " + openProcessExeDialog.FileName + ", it does not appear to be a .NET assembly!", "Failed to open assembly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                btnStart.Enabled = true;
                btnStartStep.Enabled = true;
                this.Text = "Process Viewer - " + openProcessExeDialog.FileName;
                ClearAll();
                result = openProcessSourceDialog.ShowDialog();
                _loadedSystem = null;
                _visual = null;
                txtProcessState.Text = "";
                if (result == DialogResult.Cancel) {
                    MessageBox.Show("No source file selected. Visualization of the current state of the system will not be available during execution", "No source file chosen", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                } else if (result == DialogResult.OK) {
                    _sourceFile = openProcessSourceDialog.FileName;
                    txtProcessState.Text = File.ReadAllText(_sourceFile);
                    string ext = Path.GetExtension(_sourceFile).ToLower().Substring(1);
                    if (!_parsers.ContainsKey(ext)) {
                        ErrorMsg("No suitable parser found", "No parser is loaded that parses files of type \"" + ext + "\"");
                    } else {
                        _parser = _parsers[ext];
                        try {
                            _loadedSystem = _parser.Parse(_sourceFile);
                            FindUnsupportedNodes f = new FindUnsupportedNodes();
                            f.Start(_loadedSystem);
                            if (f.typeName != "") {
                                MessageBox.Show("Sorry, visualization are currently not supported for systems that use the class " + f.typeName + ", however, the application can be run without visualization!", "Cannot show visualization", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                _loadedSystem = null;
                            }
                        } catch (ParseException pex) {
                            ErrorMsg("Failed to parse source file", "Failed to parse source file " + _sourceFile + ", error: \n" + pex.Message);
                        }
                    }
                }

            }
        }