)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create a DOM reader like application using WinForms SyntaxEditor (EditControl)?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 12, 2019

DOM reader

The DOM reader can be created using the ILexemLine and IConfigLexem interface as shown in the code below.

C#

private ArrayList GetLexems()
{
   int j=0;
   for (int i=1; i=this.editControl1.PhysicalLineCount; i++)
   {
       ILexemLine line = this.editControl1.GetLine(i);
       foreach (ILexem lexem in line.LineLexems)
       {
           IConfigLexem configLexem = lexem.Config;
           if ((configLexem.Format.Name == "MethodName") || (configLexem.Format.Name == "PropertyName") || (configLexem.Format.Name == "EventHandler"))
           {
               a[j++]=i;
               lexemList.Add(lexem);
           }
       }
   }
   return lexemList;
}
private ArrayList GetLexems2()
{
   int j=0;
   for (int i=1; i=this.editControl1.PhysicalLineCount; i++)
   {
      ILexemLine line = this.editControl1.GetLine(i);
      foreach (ILexem lexem2 in line.LineLexems)
      {
         IConfigLexem configLexem = lexem2.Config;
         if((configLexem.Format.Name == "NameSpaceName"))
         {
             strNameSpace = lexem2.Text;
         }
         if ((configLexem.Format.Name == "class"))
         {
             strClass = lexem2.Text;
             a[j++]=i;
             lexemList2.Add(lexem2);
         }
      }
   }
   return lexemList2;
}

 

VB

Private Function GetLexems() As ArrayList
   Dim j As Integer=0
   Dim i As Integer=1
   Do While i=Me.editControl1.PhysicalLineCount
        Dim line As ILexemLine = Me.editControl1.GetLine(i)
        For Each lexem As ILexem In line.LineLexems
             Dim configLexem As IConfigLexem = lexem.Config
             If (configLexem.Format.Name = "MethodName") OrElse (configLexem.Format.Name = "PropertyName") OrElse (configLexem.Format.Name = "EventHandler") Then
                 a(j += 1)=i
                 lexemList.Add(lexem)
             End If
        Next lexem
        i += 1
        Loop
    Return lexemList
End Function
Private Function GetLexems2() As ArrayList
   Dim j As Integer=0
   Dim i As Integer=1
   Do While i=Me.editControl1.PhysicalLineCount
       Dim line As ILexemLine = Me.editControl1.GetLine(i)
       For Each lexem2 As ILexem In line.LineLexems
          Dim configLexem As IConfigLexem = lexem2.Config
          If (configLexem.Format.Name = "NameSpaceName") Then
             strNameSpace = lexem2.Text
          End If
          If (configLexem.Format.Name = "class") Then
             strClass = lexem2.Text
             a(j += 1)=i
             lexemList2.Add(lexem2)
          End If
       Next lexem2
       i += 1
       Loop
   Return lexemList2
End Function

 

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon