Example #1
0
        private void SimulationNameButton_Click(object sender, EventArgs e)
        {
            string NewSimulationName = SimulationNameTextBox.Text;

            bool Valid = Common.IsNameValid(NewSimulationName);

            if (!Valid)
            {
                MessageBox.Show("Invalid simulation name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string OldSimulationName = SimulationController.SimulationName;

            foreach (Model ConnectedModel in SimulationController.Models)
            {
                string OldResPath = ConnectedModel.GetResultsDirectoryPath();
                string NewResPath = OldResPath.Replace(OldSimulationName, NewSimulationName);
                ConnectedModel.SetResultsDirectoryPath(NewResPath);

                string  ModelName      = ConnectedModel.GetName();
                TextBox ResPathTextBox = (TextBox)Pages.Controls.Find(ModelResTextBoxName + ModelName, true)[0];
                ResPathTextBox.Text = ResPathTextBox.Text.Replace(OldSimulationName, NewSimulationName);

                if (ConnectedModel.GetType() == ModelsTypes.UOCNS)
                {
                    string OldConfigPath = ((UOCNS)ConnectedModel).GetConfigFilePath();
                    string NewConfigPath = OldConfigPath.Replace(OldSimulationName, NewSimulationName);
                    ((UOCNS)ConnectedModel).SetConfigFilePath(NewConfigPath);

                    TextBox ConfigPathTextBox = (TextBox)Pages.Controls.Find(UocnsConfigFilePathTextBoxName + ModelName, true)[0];
                    ConfigPathTextBox.Text = ConfigPathTextBox.Text.Replace(OldSimulationName, NewSimulationName);
                }
                else if (ConnectedModel.GetType() == ModelsTypes.Booksim)
                {
                    string OldConfigPath = ((Booksim)ConnectedModel).GetConfigFilePath();
                    string NewConfigPath = OldConfigPath.Replace(OldSimulationName, NewSimulationName);
                    ((Booksim)ConnectedModel).SetConfigFilePath(NewConfigPath);

                    TextBox ConfigPathTextBox = (TextBox)Pages.Controls.Find(BooksimConfigFilePathTextBoxName + ModelName, true)[0];
                    ConfigPathTextBox.Text = ConfigPathTextBox.Text.Replace(OldSimulationName, NewSimulationName);
                }
                else if (ConnectedModel.GetType() == ModelsTypes.Newxim)
                {
                    string OldConfigPath = ((Newxim)ConnectedModel).GetConfigFilePath();
                    string NewConfigPath = OldConfigPath.Replace(OldSimulationName, NewSimulationName);
                    ((Newxim)ConnectedModel).SetConfigFilePath(NewConfigPath);

                    TextBox ConfigPathTextBox = (TextBox)Pages.Controls.Find(NewximConfigFilePathTextBoxName + ModelName, true)[0];
                    ConfigPathTextBox.Text = ConfigPathTextBox.Text.Replace(OldSimulationName, NewSimulationName);
                }
            }

            SimulationController.SimulationName = NewSimulationName;
        }
Example #2
0
 public void DeleteModel(string UnwantedModelName)
 {
     foreach (Model ConnectedModel in Models)
     {
         if (ConnectedModel.GetName() == UnwantedModelName)
         {
             Models.Remove(ConnectedModel);
             return;
         }
     }
 }
Example #3
0
 public Model FindModel(string WantedModelName)
 {
     foreach (Model ConnectedModel in Models)
     {
         if (ConnectedModel.GetName() == WantedModelName)
         {
             return(ConnectedModel);
         }
     }
     return(null);
 }
Example #4
0
        private void ExportResultsButton_Click(object sender, EventArgs e)
        {
            if (SimulationController.SimulationState[3] != State.Finished)
            {
                MessageBox.Show("It is possible to export results only after the end of a simulation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ModelsStateTable.SelectedRows.Count == 0)
            {
                foreach (Model ConnectedModel in SimulationController.Models)
                {
                    ResultsToCsv(ConnectedModel);

                    int   ModelIndex = SimulationController.FindModelIndex(ConnectedModel.GetName());
                    Chart Graph      = (Chart)ModelsResultsPages.TabPages[ModelIndex].Controls[0].Controls[1];
                    Graph.SaveImage(ConnectedModel.GetResultsDirectoryPath() + "\\" + ResultGraphFilename, System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            else
            {
                foreach (DataGridViewRow Row in ModelsStateTable.SelectedRows)
                {
                    string ModelName      = (string)Row.Cells[0].Value;
                    Model  ConnectedModel = SimulationController.FindModel(ModelName);
                    ResultsToCsv(ConnectedModel);

                    int   ModelIndex = SimulationController.FindModelIndex(ConnectedModel.GetName());
                    Chart Graph      = (Chart)ModelsResultsPages.TabPages[ModelIndex].Controls[0].Controls[1];
                    Graph.SaveImage(ConnectedModel.GetResultsDirectoryPath() + "\\" + ResultGraphFilename, System.Drawing.Imaging.ImageFormat.Png);
                }
            }

            if (CompareButton.Enabled == false)
            {
                string ComparisonFolder = Directory.GetCurrentDirectory() + "\\" + SimulationFolderName + "\\" + SimulationController.SimulationName + "\\" + ComparisonFolderName;
                Directory.CreateDirectory(ComparisonFolder);
                Chart CompareGraph = (Chart)ModelsResultsPages.TabPages[ModelsResultsPages.TabPages.Count - 1].Controls[0].Controls[0];
                CompareGraph.SaveImage(ComparisonFolder + "\\" + ResultGraphFilename, System.Drawing.Imaging.ImageFormat.Png);
            }
        }