Пример #1
0
        internal static void AddAnchor(PermanentAnchor anchor)
        {
            permanentAnchors.Add(anchor);

            IDocument doc;

            if (openDocuments.TryGetValue(anchor.FileName, out doc))
            {
                anchor.AttachTo(doc);
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a new Task instance.
 /// </summary>
 /// <param name="fileName">The file that the task refers to. Use null if the task does not refer to a file.</param>
 /// <param name="description">Description of the task. This parameter cannot be null.</param>
 /// <param name="column">Task column (1-based), use 0 if no column is known</param>
 /// <param name="line">Task line (1-based), use 0 if no line number is known</param>
 /// <param name="type">Type of the task</param>
 public SDTask(FileName fileName, string description, int column, int line, TaskType type)
 {
     if (description == null)
         throw new ArgumentNullException("description");
     this.type        = type;
     this.description = description.Trim();
     if (fileName != null) {
         hasLocation = line >= 1;
         this.position = new PermanentAnchor(fileName, Math.Max(1, line), Math.Max(1, column));
         position.Deleted += position_Deleted;
     }
 }
Пример #3
0
		public SearchResultNode(SearchResultMatch result)
		{
			this.result = result;
			
			IDocument document = result.CreateDocument();
			var startPosition = result.GetStartPosition(document);
			int lineNumber = startPosition.Line;
			int column = startPosition.Column;
			this.anchor = new PermanentAnchor(FileName.Create(result.FileName), lineNumber, column);
			anchor.SurviveDeletion = true;
			
			if (lineNumber >= 1 && lineNumber <= document.TotalNumberOfLines) {
				IDocumentLine matchedLine = document.GetLine(lineNumber);
				inlineBuilder = new HighlightedInlineBuilder(matchedLine.Text);
				inlineBuilder.SetFontFamily(0, inlineBuilder.Text.Length, resultLineFamily);
				
				IHighlighter highlighter = document.GetService(typeof(IHighlighter)) as IHighlighter;
				if (highlighter != null) {
					HighlightedLine highlightedLine = highlighter.HighlightLine(lineNumber);
					int startOffset = highlightedLine.DocumentLine.Offset;
					// copy only the foreground color
					foreach (HighlightedSection section in highlightedLine.Sections) {
						if (section.Color.Foreground != null) {
							inlineBuilder.SetForeground(section.Offset - startOffset, section.Length, section.Color.Foreground.GetBrush(null));
						}
					}
				}
				
				// now highlight the match in bold
				if (column >= 1) {
					var endPosition = result.GetEndPosition(document);
					if (endPosition.Line == startPosition.Line && endPosition.Column > startPosition.Column) {
						// subtract one from the column to get the offset inside the line's text
						int startOffset = column - 1;
						int endOffset = Math.Min(inlineBuilder.Text.Length, endPosition.Column - 1);
						inlineBuilder.SetFontWeight(startOffset, endOffset - startOffset, FontWeights.Bold);
					}
				}
			}
		}
Пример #4
0
		public Task(BuildError error)
		{
			if (error == null)
				throw new ArgumentNullException("error");
			type = error.IsWarning ? TaskType.Warning : TaskType.Error;
			int line = Math.Max(error.Line, 1);
			int column = Math.Max(error.Column, 1);
			if (!string.IsNullOrEmpty(error.FileName)) {
				hasLocation = error.Line >= 1;
				this.position = new PermanentAnchor(FileName.Create(error.FileName), line, column);
				position.Deleted += position_Deleted;
			}
			if (string.IsNullOrEmpty(error.ErrorCode)) {
				description = error.ErrorText;
			} else {
				description = error.ErrorText + " (" + error.ErrorCode + ")";
			}
			if (error.ContextMenuAddInTreeEntry != null) {
				contextMenuAddInTreeEntry = error.ContextMenuAddInTreeEntry;
			}
			tag = error.Tag;
			this.BuildError = error;
		}
Пример #5
0
		internal static void AddAnchor(PermanentAnchor anchor)
		{
			permanentAnchors.Add(anchor);
			
			IDocument doc;
			if (openDocuments.TryGetValue(anchor.FileName, out doc))
				anchor.AttachTo(doc);
		}
Пример #6
0
		public SearchResultNode(SearchResultMatch result)
		{
			this.result = result;
			this.anchor = new PermanentAnchor(result.FileName, result.StartLocation.Line, result.StartLocation.Column);
			anchor.SurviveDeletion = true;
		}