Exemple #1
0
        public int markWord(int start, string word, HighlightStyle color)
        {
            int retInt = -1;

            if (start > this.intRtf.Text.Length)
            {
                return(-1);
            }

            int end = this.intRtf.Find(word, start, RichTextBoxFinds.WholeWord);

            if (end > -1)
            {
                this.intRtf.Select(end, word.Length);
                this.intRtf.SelectionColor = color.ForeColor;
                if (this.intRtf.SelectionBackColor != Color.Transparent)
                {
                    this.intRtf.SelectionBackColor = color.BackColor;
                }
                this.intRtf.SelectionFont = color.Font;
                retInt = end + word.Length + 1;

                if (retInt > this.intRtf.Text.Length || retInt <= start)
                {
                    return(-1);
                }
            }

            return(retInt);
        }
Exemple #2
0
 private void regColorWord(string word, HighlightStyle col)
 {
     if (!this.wordColors.ContainsKey(word))
     {
         this.wordColors.Add(word, col);
     }
 }
Exemple #3
0
 private void colorizeWord(string word, int pos, HighlightStyle color)
 {
     this.intRtf.Select(pos, word.Length);
     this.intRtf.SelectionColor = color.ForeColor;
     if (this.intRtf.SelectionBackColor != Color.Transparent)
     {
         this.intRtf.SelectionBackColor = color.BackColor;
     }
     this.intRtf.SelectionFont = color.Font;
 }
Exemple #4
0
 private void colorizeWord(string word, int pos)
 {
     if (this.wordColors.ContainsKey(word))
     {
         HighlightStyle color = (HighlightStyle)this.wordColors[word];
         colorizeWord(word, pos, color);
     }
     else
     {
         colorizeWord(word, pos, this.mainStyle);
     }
 }
Exemple #5
0
 public void markWordsAll(string[] words, HighlightStyle color)
 {
     foreach (string word in words)
     {
         if (this.Mode == RtfColoring.MODE_DIRECT)
         {
             markWordsAll(word, color);
         }
         else
         {
             regColorWord(word, color);
         }
     }
 }
Exemple #6
0
        public void markWordsAll(string word, HighlightStyle color)
        {
            if (this.Mode == RtfColoring.MODE_WORD)
            {
                regColorWord(word, color);
                return;
            }

            this.storePositions();
            int searchPos = this.startPosition;

            while (searchPos != -1)
            {
                searchPos = this.markWord(searchPos, word, color);
            }
            this.resetPositions();
        }
Exemple #7
0
        public int markTextLine(string word, HighlightStyle color)
        {
            int retInt = -1;

            string[] words = word.Split('\n');
            this.markWordsAll(words, color);

            /*
             * int end = this.intRtf.Find(words[0], 0, RichTextBoxFinds.None);
             * if (end > -1)
             * {
             *  this.intRtf.Select(end, word.Length);
             *  this.intRtf.SelectionColor = color.ForeColor;
             *  this.intRtf.SelectionBackColor = color.BackColor;
             *  this.intRtf.SelectionFont = color.Font;
             *  retInt = end + 1;
             * }
             */
            return(retInt);
        }
Exemple #8
0
 public void setColor(HighlightStyle highlight)
 {
     this.currentHighlight = highlight;
     this.setColor(currentHighlight.ForeColor);
     this.setBackColor(currentHighlight.BackColor);
 }
Exemple #9
0
        public void markFullLine(int lineNumber, HighlightStyle color, Boolean lineCaret, Boolean markText, string DisplayText, int wordselect)
        {
            if (lineNumber >= this.intRtf.Lines.Count())
            {
                return;
            }

            int existingLinesCharCount = 0;

            for (int ln = this.startLine; ln < lineNumber; ln++)
            {
                existingLinesCharCount += this.intRtf.Lines[ln].Length + 1; // +1 for line ending
            }

            int    index = this.intRtf.GetFirstCharIndexFromLine(lineNumber);
            string line  = this.intRtf.Lines[lineNumber];

            if (null == line)
            {
                return;
            }

            int end = line.Length;

            //string word = this.intRtf.Lines[lineNumber];
            //this.markWordsAll(word, color);


            if (end > 0)
            {
                //this.intRtf.Select(index, end);
                if (this.Mode == RtfColoring.MODE_WORD && lineCaret)
                {
                    Point pt    = this.intRtf.GetPositionFromCharIndex(existingLinesCharCount);
                    Point ptend = this.intRtf.GetPositionFromCharIndex(existingLinesCharCount + end);
                    ptend.Y += (int)this.intRtf.Font.Size;

                    RichBoxMarker rbMarker = new RichBoxMarker();

                    rbMarker.topLeft        = pt;
                    rbMarker.BottomRight    = ptend;
                    rbMarker.ForeColor      = color.ForeColor;
                    rbMarker.firstCharIndex = existingLinesCharCount;
                    if (wordselect >= 0)
                    {
                        string[] words    = line.Split('\n');
                        int      addChars = 0;
                        for (int i = 0; i < words.Length && i <= wordselect; i++)
                        {
                            addChars += words[i].Length;
                        }
                        rbMarker.firstCharIndex += addChars;
                    }
                    rbMarker.lastCharIndex = existingLinesCharCount + end;
                    rbMarker.displayText   = DisplayText;
                    this.intRtf.LineMarker.Add(rbMarker);
                }
                if (markText)
                {
                    this.intRtf.SelectionStart     = existingLinesCharCount;
                    this.intRtf.SelectionLength    = end;
                    this.intRtf.SelectionColor     = color.ForeColor;
                    this.intRtf.SelectionBackColor = color.BackColor;
                    this.intRtf.SelectionFont      = color.Font;
                }
            }
        }
Exemple #10
0
 public void markFullLine(int lineNumber, HighlightStyle color, Boolean lineCaret, Boolean markText, string DisplayText)
 {
     this.markFullLine(lineNumber, color, lineCaret, markText, DisplayText, -1);
 }
Exemple #11
0
 public void markFullLine(int lineNumber, HighlightStyle color, Boolean lineCaret, Boolean markText)
 {
     this.markFullLine(lineNumber, color, lineCaret, markText, null);
 }
Exemple #12
0
 public void markFullLine(int lineNumber, HighlightStyle color)
 {
     this.markFullLine(lineNumber, color, false, true, null);
 }