Exemplo n.º 1
0
        /// <summary>
        /// Gets the first offset greater or equal to <paramref name="startOffset"/> where a folded folding starts.
        /// Returns -1 if there are no foldings after <paramref name="startOffset"/>.
        /// </summary>
        public int GetNextFoldedFoldingStart(int startOffset)
        {
            FoldingSection fs = foldings.FindFirstSegmentWithStartAfter(startOffset);

            while (fs != null && !fs.IsFolded)
            {
                fs = foldings.GetNextSegment(fs);
            }
            return(fs != null ? fs.StartOffset : -1);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes a folding section from this manager.
 /// </summary>
 public void RemoveFolding(FoldingSection fs)
 {
     if (fs == null)
     {
         throw new ArgumentNullException("fs");
     }
     document.VerifyAccess();
     fs.IsFolded = false;
     foldings.Remove(fs);
     textView.Redraw(fs, DispatcherPriority.Normal);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a folding for the specified text section.
        /// </summary>
        public FoldingSection CreateFolding(int startOffset, int endOffset)
        {
            if (startOffset >= endOffset)
            {
                throw new ArgumentException("startOffset must be less than endOffset");
            }
            FoldingSection fs = new FoldingSection(this, startOffset, endOffset);

            foldings.Add(fs);
            textView.Redraw();
            return(fs);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets all foldings that start exactly at <paramref name="startOffset"/>.
        /// </summary>
        public ReadOnlyCollection <FoldingSection> GetFoldingsAt(int startOffset)
        {
            List <FoldingSection> result = new List <FoldingSection>();
            FoldingSection        fs     = foldings.FindFirstSegmentWithStartAfter(startOffset);

            while (fs != null && fs.StartOffset == startOffset)
            {
                result.Add(fs);
                fs = foldings.GetNextSegment(fs);
            }
            return(result.AsReadOnly());
        }
Exemplo n.º 5
0
        void TextViewVisualLinesChanged(object sender, EventArgs e)
        {
            foreach (FoldingMarginMarker m in markers)
            {
                RemoveVisualChild(m);
            }
            markers.Clear();
            InvalidateVisual();
            if (TextView != null && FoldingManager != null && TextView.VisualLinesValid)
            {
                foreach (VisualLine line in TextView.VisualLines)
                {
                    FoldingSection fs = FoldingManager.GetNextFolding(line.FirstDocumentLine.Offset);
                    if (fs == null)
                    {
                        continue;
                    }
                    if (fs.StartOffset <= line.LastDocumentLine.Offset + line.LastDocumentLine.Length)
                    {
                        FoldingMarginMarker m = new FoldingMarginMarker {
                            IsExpanded          = !fs.IsFolded,
                            SnapsToDevicePixels = true,
                            VisualLine          = line,
                            FoldingSection      = fs
                        };
                        markers.Add(m);
                        AddVisualChild(m);

                        m.IsMouseDirectlyOverChanged += delegate { InvalidateVisual(); };

                        InvalidateMeasure();
                        continue;
                    }
                }
            }
        }
		/// <summary>
		/// Removes a folding section from this manager.
		/// </summary>
		public void RemoveFolding(FoldingSection fs)
		{
			if (fs == null)
				throw new ArgumentNullException("fs");
			document.VerifyAccess();
			fs.IsFolded = false;
			foldings.Remove(fs);
			textView.Redraw(fs, DispatcherPriority.Normal);
		}
		/// <summary>
		/// Creates a folding for the specified text section.
		/// </summary>
		public FoldingSection CreateFolding(int startOffset, int endOffset)
		{
			if (startOffset >= endOffset)
				throw new ArgumentException("startOffset must be less than endOffset");
			FoldingSection fs = new FoldingSection(this, startOffset, endOffset);
			foldings.Add(fs);
			textView.Redraw();
			return fs;
		}