protected void AddKeywordToThisKeyword(object sender, EventArgs e) { var keywordIndex = int.Parse(((Button)sender).Name.Replace("DynamicStep", "").Replace("AddKeyword", "")); AssignThisKeywordNamesFromTextFields(); if (ThisFormKeywords == null) { var checkNull = AddCurrentKeywordsToKeywordsList(sender, e); if (checkNull == null) { ThisFormKeywords = new List <Keyword>(); } } var path = !FormType.Equals(FormType.Params) ? FilesAndFolderStructure.ConcatFileNameToFolder(Controls["OutputFile"].Text, FilesAndFolderStructure.ConvertFormTypeToFolderType(FormType)) : _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].OutputFilePath; ThisFormKeywords.Add(_formParent.ThisFormKeywords != null ? new Keyword("New Keyword", path, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent) : new Keyword("New Keyword", path, null)); for (var i = NumberOfKeywordsInThisForm; i > keywordIndex; i--) { ThisFormKeywords[i].CopyKeyword(ThisFormKeywords[i - 1]); } if (_formParent.ThisFormKeywords != null) { ThisFormKeywords[keywordIndex] = new Keyword(NameAndOutputToTestCaseFormCommunication.Name, NameAndOutputToTestCaseFormCommunication.OutputFile, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent); } else { ThisFormKeywords[keywordIndex] = new Keyword(NameAndOutputToTestCaseFormCommunication.Name, NameAndOutputToTestCaseFormCommunication.OutputFile, null); } NumberOfKeywordsInThisForm++; AddKeywordField(ThisFormKeywords[NumberOfKeywordsInThisForm - 1], NumberOfKeywordsInThisForm, false, true); for (var i = 1; i < NumberOfKeywordsInThisForm; i++) { Controls["DynamicStep" + i + "Name"].Text = ThisFormKeywords[i - 1].Name.Trim(); } for (var i = 1; i <= NumberOfKeywordsInThisForm; i++) { ((TextWithList)Controls["DynamicStep" + i + "Name"]).TriggerUpdate(ThisFormKeywords[i - 1].Name, ThisFormKeywords[i - 1].ToString()); ((TextWithList)Controls["DynamicStep" + i + "Name"]).EnableKeywordFields(); } }
//adds the list of keywords ( + unimplemented ones ) to a Keyword and returns it protected Keyword AddCurrentKeywordsToKeywordsList(object sender, EventArgs e) { var path = !FormType.Equals(FormType.Params) ? FilesAndFolderStructure.ConcatFileNameToFolder(Controls["OutputFile"].Text, FilesAndFolderStructure.ConvertFormTypeToFolderType(FormType)) : _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].OutputFilePath; // if AddImplementation is pressed a new form should be opened which requires the keyword that it represents var keywordIndex = 0; if (((Button)sender).Name.Contains("DynamicStep") && !((Button)sender).Name.Contains("Params") && !((Button)sender).Name.Contains("AddKeyword") && !((Button)sender).Name.Contains("RemoveKeyword")) { keywordIndex = int.Parse(((Button)sender).Name.Replace("AddImplementation", "").Replace("DynamicStep", "")); } else if (((Button)sender).Name.Contains("DynamicStep") && ((Button)sender).Name.Contains("Params")) { keywordIndex = int.Parse(((Button)sender).Name.Replace("Params", "").Replace("DynamicStep", "")); } // add to the global variable for the form that matches the index of the keyword to implement IndexOfTheKeywordToBeImplemented = keywordIndex; if (keywordIndex <= 0) { keywordIndex = 1; } if (ThisFormKeywords == null) { ThisFormKeywords = new List <Keyword>(); for (var i = 1; i <= NumberOfKeywordsInThisForm; i++) { ThisFormKeywords.Add(new Keyword(Controls["DynamicStep" + i + "Name"].Text, path, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent)); } } else { for (var i = ThisFormKeywords.Count + 1; i <= NumberOfKeywordsInThisForm; i++) { ThisFormKeywords.Add(new Keyword(Controls["DynamicStep" + i + "Name"].Text, path, _formParent.ThisFormKeywords[ImplementationIndexFromTheParent].Parent)); } } AssignThisKeywordNamesFromTextFields(); return(ThisFormKeywords[keywordIndex - 1]); }