Exemple #1
0
 public void HighLight(string StartMarker, string EndMarker)
 {
     if (this.InvokeRequired)
     {
         HighLight_d HD = new HighLight_d(HighLight);
         this.Invoke(HD, new object[] { StartMarker, EndMarker });
     }
     else
     {
         int    SSI      = this.SelectionStart;
         int    SSL      = this.SelectionLength;
         string TempText = this.Text;
         this.Text = TempText;//this is done to clear all previous selection highlighting
         bool   CheckFurther = true;
         int    Pointer      = 0;
         string Content      = this.Text;
         while (CheckFurther && Content.Length > Pointer)
         {
             int Start = Content.IndexOf(StartMarker, Pointer);
             int Stop  = Content.IndexOf(EndMarker, Start + StartMarker.Length);
             if (Start == -1 || Stop == -1)
             {
                 CheckFurther = false;
             }
             if (CheckFurther)
             {
                 this.SelectionStart     = Start;
                 this.SelectionLength    = Stop - Start;
                 this.SelectionBackColor = Color.Orange;
             }
             Pointer = Stop + EndMarker.Length;
         }
         this.SelectionStart  = SSI;
         this.SelectionLength = SSL;
     }
 }
Exemple #2
0
 public void HighLight(string StartMarker, string EndMarker)
 {
     if (this.InvokeRequired)
     {
         HighLight_d HD = new HighLight_d(HighLight);
         this.Invoke(HD, new object[] { StartMarker, EndMarker });
     }
     else
     {
         int SSI = this.SelectionStart;
         int SSL = this.SelectionLength;
         string TempText = this.Text;
         this.Text = TempText;//this is done to clear all previous selection highlighting
         bool CheckFurther = true;
         int Pointer = 0;
         string Content = this.Text;
         while (CheckFurther && Content.Length > Pointer)
         {
             int Start = Content.IndexOf(StartMarker, Pointer);
             int Stop = Content.IndexOf(EndMarker, Start + StartMarker.Length);
             if (Start == -1 || Stop == -1) CheckFurther = false;
             if (CheckFurther)
             {
                 this.SelectionStart = Start;
                 this.SelectionLength = Stop - Start;
                 this.SelectionBackColor = Color.Orange;
             }
             Pointer = Stop + EndMarker.Length;
         }
         this.SelectionStart = SSI;
         this.SelectionLength = SSL;
     }
 }