// returns the index of the specific tag - keyword / test cases / settings / variables
        public List <SuiteSettings> ReadSettingsFromFile()
        {
            var suiteSettings = new List <SuiteSettings>();

            foreach (var fileName in FilesAndFolderStructure.GetFullSavedFiles(FolderType.Tests))
            {
                var currentSuiteSettings = new SuiteSettings(fileName.Replace(FilesAndFolderStructure.GetFolder(FolderType.Root), ""))
                {
                    Documentation = RobotFileHandler.OccurenceInSettings(fileName, "Documentation").Replace("Documentation", "").Trim(),
                    TestSetup     = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Test Setup").Replace("Test Setup", "").Trim(), fileName, libraries, null)
                };
                currentSuiteSettings.TestTeardown  = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Test Teardown").Replace("Test Teardown", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.SuiteSetup    = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Suite Setup").Replace("Suite Setup", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.SuiteTeardown = new Keyword(RobotFileHandler.OccurenceInSettings(fileName, "Suite Teardown").Replace("Suite Teardown", "").Trim(), fileName, libraries, null);
                currentSuiteSettings.Overwrite     = true;
                suiteSettings.Add(currentSuiteSettings);
            }
            return(suiteSettings);
        }
        private void SetupsSettingsAddForm()
        {
            UpdateOutputFileSuggestions(OutputFile, FormType);
            OutputFile.SelectedIndex = _selectedIndex;
            foreach (var fileName in FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root))
            {
                var add = true;
                if (RobotAutomationHelper.SuiteSettingsList.Count != 0)
                {
                    foreach (var temp in RobotAutomationHelper.SuiteSettingsList)
                    {
                        if (!temp.ToString().Equals(fileName))
                        {
                            continue;
                        }
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    RobotAutomationHelper.SuiteSettingsList.Add(new SuiteSettings(fileName));
                }
            }

            ActiveControl = AddSettingsLabel;

            foreach (var temp in RobotAutomationHelper.SuiteSettingsList)
            {
                if (temp.ToString().Equals(OutputFile.Items[OutputFile.SelectedIndex]))
                {
                    CurrentSuiteSettings = temp;
                    break;
                }
            }


            var folderType = FolderType.Root;

            if (CurrentSuiteSettings.OutputFilePath.Contains(FilesAndFolderStructure.Resources))
            {
                folderType = FolderType.Resources;
            }
            if (CurrentSuiteSettings.OutputFilePath.Contains(FilesAndFolderStructure.Tests))
            {
                folderType = FolderType.Tests;
            }

            if (!CurrentSuiteSettings.Overwrite)
            {
                var realOutput = CurrentSuiteSettings.OutputFilePath;
                switch (folderType)
                {
                case FolderType.Tests:
                    realOutput = realOutput.Remove(0, 5);
                    break;

                case FolderType.Resources:
                    realOutput = realOutput.Remove(0, 9);
                    break;

                case FolderType.Root:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                CurrentSuiteSettings.Documentation = RobotFileHandler.OccurenceInSettings(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root),
                                                                                          "Documentation").Replace("Documentation", "").Trim();
                CurrentSuiteSettings.TestSetup = new Keyword(RobotFileHandler.OccurenceInSettings(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root), "Test Setup").Replace("Test Setup", "").Trim(),
                                                             realOutput, ReadRobotFiles.GetLibs(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root)), null);
                CurrentSuiteSettings.TestTeardown = new Keyword(RobotFileHandler.OccurenceInSettings(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root), "Test Teardown").Replace("Test Teardown", "").Trim(),
                                                                realOutput, ReadRobotFiles.GetLibs(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root)), null);
                CurrentSuiteSettings.SuiteSetup = new Keyword(RobotFileHandler.OccurenceInSettings(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root), "Suite Setup").Replace("Suite Setup", "").Trim(),
                                                              realOutput, ReadRobotFiles.GetLibs(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root)), null);
                CurrentSuiteSettings.SuiteTeardown = new Keyword(RobotFileHandler.OccurenceInSettings(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root), "Suite Teardown").Replace("Suite Teardown", "").Trim(),
                                                                 realOutput, ReadRobotFiles.GetLibs(FilesAndFolderStructure.ConcatFileNameToFolder(CurrentSuiteSettings.OutputFilePath, FolderType.Root)), null);
            }

            ThisFormKeywords = new List <Keyword>();
            if (CurrentSuiteSettings.TestSetup == null)
            {
                CurrentSuiteSettings.TestSetup = new Keyword("", "Auto.robot", null);
            }
            ThisFormKeywords.Add(CurrentSuiteSettings.TestSetup);

            if (CurrentSuiteSettings.TestTeardown == null)
            {
                CurrentSuiteSettings.TestTeardown = new Keyword("", "Auto.robot", null);
            }
            ThisFormKeywords.Add(CurrentSuiteSettings.TestTeardown);

            if (CurrentSuiteSettings.SuiteSetup == null)
            {
                CurrentSuiteSettings.SuiteSetup = new Keyword("", "Auto.robot", null);
            }
            ThisFormKeywords.Add(CurrentSuiteSettings.SuiteSetup);

            if (CurrentSuiteSettings.SuiteTeardown == null)
            {
                CurrentSuiteSettings.SuiteTeardown = new Keyword("", "Auto.robot", null);
            }
            ThisFormKeywords.Add(CurrentSuiteSettings.SuiteTeardown);

            SuiteDocumentation.Text = CurrentSuiteSettings.Documentation;

            if (folderType != FolderType.Tests)
            {
                return;
            }
            for (var i = 1; i <= 4; i++)
            {
                if (Controls["DynamicStep" + i + "Name"] != null)
                {
                    Controls["DynamicStep" + i + "Name"].Text = ThisFormKeywords[i - 1].Name;
                }
                else
                {
                    AddKeywordField(ThisFormKeywords[i - 1], i, false, false);
                }
            }
        }