Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private void regColorWord(string word, HighlightStyle col)
 {
     if (!this.wordColors.ContainsKey(word))
     {
         this.wordColors.Add(word, col);
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 public void setColor(HighlightStyle highlight)
 {
     this.currentHighlight = highlight;
     this.setColor(currentHighlight.ForeColor);
     this.setBackColor(currentHighlight.BackColor);
 }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 10
0
 public void markFullLine(int lineNumber, HighlightStyle color, Boolean lineCaret, Boolean markText, string DisplayText)
 {
     this.markFullLine(lineNumber, color, lineCaret, markText, DisplayText, -1);
 }
Ejemplo n.º 11
0
 public void markFullLine(int lineNumber, HighlightStyle color, Boolean lineCaret, Boolean markText)
 {
     this.markFullLine(lineNumber, color, lineCaret, markText, null);
 }
Ejemplo n.º 12
0
 public void markFullLine(int lineNumber, HighlightStyle color)
 {
     this.markFullLine(lineNumber, color, false, true, null);
 }