Пример #1
0
        private void StopModelButton_Click(object sender, EventArgs e)
        {
            int NumErrors = 0;

            foreach (DataGridViewRow Row in ModelsStateTable.SelectedRows)
            {
                string ModelName  = (string)Row.Cells[0].Value;
                int    ModelIndex = SimulationController.FindModelIndex(ModelName);

                try
                {
                    if (!SimulationController.ModelsProcesses[ModelIndex].HasExited)
                    {
                        SimulationController.ModelsProcesses[ModelIndex].Kill();
                    }
                }
                catch (Exception KillException)
                {
                    ToLogsTextBox("Process kill error: " + KillException.Message);
                    NumErrors++;
                }
            }

            if (NumErrors != 0)
            {
                MessageBox.Show(NumErrors.ToString() + " errors occured at attempt to stop model(s) simulation process", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            ModelsStateTable.ClearSelection();
        }
Пример #2
0
        private void DeleteModelButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow Row in ModelsStateTable.SelectedRows)
            {
                string ModelName = (string)Row.Cells[0].Value;

                int ModelIndex = SimulationController.FindModelIndex(ModelName);
                ModelsResultsPages.TabPages.RemoveAt(ModelIndex);

                TabPage ModelPage = (TabPage)Pages.Controls.Find(ModelPageName + ModelName, true)[0];
                Pages.Controls.Remove(ModelPage);

                SimulationController.DeleteModel(ModelName);

                SimulationController.ModelsStates.RemoveAt(ModelIndex);
                ModelsStateTable.Rows.RemoveAt(ModelIndex);
            }

            if (SimulationController.Models.Count == 0)
            {
                DeleteModelButton.Enabled     = false;
                StartSimulationButton.Enabled = false;
            }

            ModelsStateTable.ClearSelection();
        }