コード例 #1
0
        protected override int?GetLineNumber(ITextViewLine viewLine, ref LineNumberState state)
        {
            if (owner == null)
            {
                return(null);
            }
            CustomLineNumberState customState;

            if (state == null)
            {
                state = customState = new CustomLineNumberState();
            }
            else
            {
                customState = (CustomLineNumberState)state;
            }
            if (state.SnapshotLine == null || state.SnapshotLine.EndIncludingLineBreak != viewLine.Start)
            {
                state.SnapshotLine = viewLine.Start.GetContainingLine();
            }
            else
            {
                state.SnapshotLine = state.SnapshotLine.Snapshot.GetLineFromLineNumber(state.SnapshotLine.LineNumber + 1);
            }
            return(owner.GetLineNumber(viewLine, state.SnapshotLine, ref customState.State));
        }
コード例 #2
0
        Line CreateLine(ITextViewLine viewLine, LineNumberState lineNumberState, int lineNumber)
        {
            var lineNumberString = GetLineNumberString(lineNumber);
            var lineNumberSource = new LineNumberSource(lineNumberString, GetLineNumberTextFormattingRunProperties(viewLine, lineNumberState, lineNumber));
            var textLine         = textFormatter !.FormatLine(lineNumberSource, 0, 0, defaultTextParagraphProperties, null);

            return(new Line(lineNumber, textLine, lineNumberTextRight, viewLine.TextTop + viewLine.Baseline - textLine.TextBaseline));
        }
コード例 #3
0
        void UpdateLines(IList <ITextViewLine> newOrReformattedLines, IList <ITextViewLine> translatedLines)
        {
            if (wpfTextViewHost.IsClosed)
            {
                return;
            }
            var textViewLines = wpfTextViewHost.TextView.TextViewLines;

            if (textViewLines == null)
            {
                return;
            }

            foreach (var viewLine in newOrReformattedLines)
            {
                if (identityTagToLine.TryGetValue(viewLine.IdentityTag, out var line))
                {
                    identityTagToLine.Remove(viewLine.IdentityTag);
                    line.Dispose();
                }
            }
            foreach (var viewLine in translatedLines)
            {
                if (identityTagToLine.TryGetValue(viewLine.IdentityTag, out var line))
                {
                    identityTagToLine.Remove(viewLine.IdentityTag);
                    line.Dispose();
                }
            }
            var             newDict         = new Dictionary <object, Line>();
            LineNumberState lineNumberState = null;

            foreach (var viewLine in textViewLines)
            {
                var lineNumber = GetLineNumber(viewLine, ref lineNumberState);
                if (lineNumber == null)
                {
                    continue;
                }

                if (!identityTagToLine.TryGetValue(viewLine.IdentityTag, out var line) || line.Number != lineNumber)
                {
                    line = CreateLine(viewLine, lineNumberState, lineNumber.Value);
                }
                else
                {
                    identityTagToLine.Remove(viewLine.IdentityTag);
                }
                newDict[viewLine.IdentityTag] = line;
            }
            foreach (var line in identityTagToLine.Values)
            {
                line.Dispose();
            }

            identityTagToLine = newDict;
            textLayer.UpdateLines(identityTagToLine.Values.ToArray());
        }
コード例 #4
0
ファイル: LineNumberMargin.cs プロジェクト: manojdjoshi/dnSpy
		protected override int? GetLineNumber(ITextViewLine viewLine, ref LineNumberState state) {
			if (!viewLine.IsFirstTextViewLineForSnapshotLine)
				return null;
			if (state == null)
				state = new LineNumberState();
			if (state.SnapshotLine == null || state.SnapshotLine.EndIncludingLineBreak != viewLine.Start)
				state.SnapshotLine = viewLine.Start.GetContainingLine();
			else
				state.SnapshotLine = state.SnapshotLine.Snapshot.GetLineFromLineNumber(state.SnapshotLine.LineNumber + 1);
			return state.SnapshotLine.LineNumber + 1;
		}
コード例 #5
0
		protected override int? GetLineNumber(ITextViewLine viewLine, ref LineNumberState state) {
			if (owner == null)
				return null;
			CustomLineNumberState customState;
			if (state == null)
				state = customState = new CustomLineNumberState();
			else
				customState = (CustomLineNumberState)state;
			if (state.SnapshotLine == null || state.SnapshotLine.EndIncludingLineBreak != viewLine.Start)
				state.SnapshotLine = viewLine.Start.GetContainingLine();
			else
				state.SnapshotLine = state.SnapshotLine.Snapshot.GetLineFromLineNumber(state.SnapshotLine.LineNumber + 1);
			return owner.GetLineNumber(viewLine, state.SnapshotLine, ref customState.State);
		}
コード例 #6
0
 protected override int?GetLineNumber(ITextViewLine viewLine, ref LineNumberState state)
 {
     if (!viewLine.IsFirstTextViewLineForSnapshotLine)
     {
         return(null);
     }
     if (state == null)
     {
         state = new LineNumberState();
     }
     if (state.SnapshotLine == null || state.SnapshotLine.EndIncludingLineBreak != viewLine.Start)
     {
         state.SnapshotLine = viewLine.Start.GetContainingLine();
     }
     else
     {
         state.SnapshotLine = state.SnapshotLine.Snapshot.GetLineFromLineNumber(state.SnapshotLine.LineNumber + 1);
     }
     return(state.SnapshotLine.LineNumber + 1);
 }
コード例 #7
0
		protected override TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber) {
			Debug.Assert(owner != null);
			Debug.Assert(state != null);
			if (owner == null)
				throw new InvalidOperationException();
			var customState = (CustomLineNumberState)state;
			return owner.GetLineNumberTextFormattingRunProperties(viewLine, customState.SnapshotLine, lineNumber, customState.State);
		}
コード例 #8
0
		protected abstract TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber);
コード例 #9
0
		Line CreateLine(ITextViewLine viewLine, LineNumberState lineNumberState, int lineNumber) {
			var lineNumberString = GetLineNumberString(lineNumber);
			var lineNumberSource = new LineNumberSource(lineNumberString, GetLineNumberTextFormattingRunProperties(viewLine, lineNumberState, lineNumber));
			var textLine = textFormatter.FormatLine(lineNumberSource, 0, 0, defaultTextParagraphProperties, null);
			return new Line(lineNumber, textLine, lineNumberTextRight, viewLine.TextTop + viewLine.Baseline - textLine.TextBaseline);
		}
コード例 #10
0
		protected abstract int? GetLineNumber(ITextViewLine viewLine, ref LineNumberState state);
コード例 #11
0
 protected abstract TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber);
コード例 #12
0
        protected override TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber)
        {
            Debug.Assert(owner != null);
            Debug.Assert(state != null);
            if (owner == null)
            {
                throw new InvalidOperationException();
            }
            var customState = (CustomLineNumberState)state;

            return(owner.GetLineNumberTextFormattingRunProperties(viewLine, customState.SnapshotLine, lineNumber, customState.State));
        }
コード例 #13
0
 protected abstract int?GetLineNumber(ITextViewLine viewLine, ref LineNumberState state);
コード例 #14
0
 protected override TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber) =>
 lineNumberTextFormattingRunProperties;
コード例 #15
0
ファイル: LineNumberMargin.cs プロジェクト: manojdjoshi/dnSpy
		protected override TextFormattingRunProperties GetLineNumberTextFormattingRunProperties(ITextViewLine viewLine, LineNumberState state, int lineNumber) =>
			lineNumberTextFormattingRunProperties;