コード例 #1
0
        public void DrawLine(Graphics g, ref float xPos, float xOffset, float yPos, Color c)
        {
            SizeF spaceSize = this.GetSpaceSize(g);

            foreach (DrawableLine.SimpleTextWord word in this.words)
            {
                switch (word.Type)
                {
                case TextWordType.Word:
                {
                    xPos = xPos + DrawableLine.DrawDocumentWord(g, word.Word, new PointF(xPos + xOffset, yPos), (word.Bold ? this.boldMonospacedFont : this.monospacedFont), (c == Color.Empty ? word.Color : c));
                    continue;
                }

                case TextWordType.Space:
                {
                    xPos += spaceSize.Width;
                    continue;
                }

                case TextWordType.Tab:
                {
                    float width = spaceSize.Width * 4f;
                    xPos += width;
                    xPos  = (float)((int)((xPos + 2f) / width)) * width;
                    continue;
                }

                default:
                {
                    continue;
                }
                }
            }
        }
コード例 #2
0
		public SearchResultNode(IDocument document, SearchResult result)
		{
			drawDefault = false;
			this.result = result;
			startPosition = result.GetStartPosition(document);
			Point endPosition = result.GetEndPosition(document);
			positionText =  "(" + (startPosition.Y + 1) + ", " + (startPosition.X + 1) + ") ";
			
			LineSegment line = document.GetLineSegment(startPosition.Y);
			drawableLine = new DrawableLine(document, line, RegularMonospacedFont, BoldMonospacedFont);
			drawableLine.SetBold(0, drawableLine.LineLength, false);
			if (startPosition.Y == endPosition.Y) {
				drawableLine.SetBold(startPosition.X, endPosition.X, true);
			}
			
			specialText = result.DisplayText;
			if (specialText != null) {
				displayText = positionText + specialText;
			} else {
				displayText = positionText + document.GetText(line).Replace("\t", "    ");
			}
			Text = displayText;
		}