private void richTextBox1_TextChanged(object sender, EventArgs e) { groupBox1.Controls.Clear(); int pos = richTextBox1.SelectionStart; try { ViewConverter converter = ViewConverter.GetInstance(); XmlDocument document = converter.LoadXmlDocument(richTextBox1.Text); XmlNode rootNode = document.FirstChild; converter.ConvertDocument(rootNode, groupBox1); HashSet <string> names = new HashSet <string>(); converter.GetAllTagsNames(rootNode, names); UpdateRichTextStyle(names.ToArray()); } catch (XmlException xmlException) { UpdateRichTextStyle(null, xmlException.LineNumber); } catch (Exception exception) { //MessageBox.Show(exception.Message); } finally { richTextBox1.SelectionStart = pos; } }
public void GetAllTagsNamesTest() { ViewConverter converter = ViewConverter.GetInstance(); XmlDocument document = converter.LoadXmlDocument(TEST2); XmlNode rootNode = document.FirstChild; HashSet <string> names = new HashSet <string>(); converter.GetAllTagsNames(rootNode, names); Assert.AreEqual(2, names.Count); Assert.IsTrue(names.Contains("Form")); Assert.IsTrue(names.Contains("GroupBox")); }