コード例 #1
0
 public MouseLeftDownInfo(HexBufferSpan span, Point point, int clicks, HexBufferLineFormatter bufferLines)
 {
     Span        = span;
     Point       = point;
     Clicks      = clicks;
     BufferLines = bufferLines;
 }
コード例 #2
0
        string GenerateHtmlFragmentCore(HexBufferLineFormatter bufferLines, NormalizedHexBufferSpanCollection spans, HexView?hexView, string delimiter, CancellationToken cancellationToken)
        {
            HexClassifier?classifier = null;

            try {
                VSTC.IClassificationFormatMap classificationFormatMap;
                if (!(hexView is null))
                {
                    classifier = viewClassifierAggregatorService.GetClassifier(hexView);
                    classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(hexView);
                }
                else
                {
                    classifier = spans.Count == 0 ? null : classifierAggregatorService.GetClassifier(spans[0].Buffer);
                    classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.HexEditor);
                }

                const int tabSize = 4;
                var       builder = new HexHtmlBuilder(classificationFormatMap, delimiter, tabSize);
                if (spans.Count != 0)
                {
                    Debug2.Assert(!(classifier is null));
                    builder.Add(bufferLines, classifier, spans, cancellationToken);
                }
                return(builder.Create());
            }
コード例 #3
0
 void WpfHexView_Closed(object sender, EventArgs e)
 {
     RemoveAllLines();
     latestBufferLines  = null;
     wpfHexView.Closed -= WpfHexView_Closed;
     wpfHexView.Options.OptionChanged -= Options_OptionChanged;
     UnhookEnabledEvents();
 }
コード例 #4
0
ファイル: HexView.cs プロジェクト: pashav15/pashav
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="oldBufferLines">Old instance</param>
 /// <param name="newBufferLines">New instance</param>
 public BufferLinesChangedEventArgs(HexBufferLineFormatter oldBufferLines, HexBufferLineFormatter newBufferLines)
 {
     if (newBufferLines == null)
     {
         throw new ArgumentNullException(nameof(newBufferLines));
     }
     OldBufferLines = oldBufferLines;
     NewBufferLines = newBufferLines;
 }
コード例 #5
0
ファイル: HexSelectionImpl.cs プロジェクト: pashav15/pashav
        static HexCell GetCell(HexBufferLineFormatter bufferLines, HexBufferPoint position)
        {
            var line = bufferLines.GetLineFromPosition(position);
            var cell = line.ValueCells.GetCell(position);

            if (cell == null && position == line.BufferEnd && position > line.BufferStart)
            {
                cell = line.ValueCells.GetCell(position - 1);
            }
            return(cell);
        }
コード例 #6
0
 public HexBufferLineImpl(HexBufferLineFormatter hexBufferLineFormatter, HexPosition lineNumber, ReadOnlyCollection <HexColumnType> columnOrder, HexBufferSpan bufferSpan, HexBytes hexBytes, string text, bool isOffsetColumnPresent, bool isValuesColumnPresent, bool isAsciiColumnPresent, HexPosition logicalOffset, HexCellCollection valueCells, HexCellCollection asciiCells, VST.Span offsetSpan, VST.Span fullValuesSpan, VST.Span visibleValuesSpan, VST.Span fullAsciiSpan, VST.Span visibleAsciiSpan)
 {
     if (hexBufferLineFormatter == null)
     {
         throw new ArgumentNullException(nameof(hexBufferLineFormatter));
     }
     if (columnOrder == null)
     {
         throw new ArgumentNullException(nameof(columnOrder));
     }
     if (bufferSpan.IsDefault)
     {
         throw new ArgumentException();
     }
     if (hexBytes.IsDefault)
     {
         throw new ArgumentException();
     }
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     if (valueCells.IsDefault)
     {
         throw new ArgumentNullException(nameof(valueCells));
     }
     if (asciiCells.IsDefault)
     {
         throw new ArgumentNullException(nameof(asciiCells));
     }
     LineProvider           = hexBufferLineFormatter;
     LineNumber             = lineNumber;
     ColumnOrder            = columnOrder;
     BufferSpan             = bufferSpan;
     HexBytes               = hexBytes;
     Text                   = text;
     IsOffsetColumnPresent  = isOffsetColumnPresent;
     IsValuesColumnPresent  = isValuesColumnPresent;
     IsAsciiColumnPresent   = isAsciiColumnPresent;
     LogicalOffset          = logicalOffset;
     ValueCells             = valueCells;
     AsciiCells             = asciiCells;
     this.offsetSpan        = offsetSpan;
     this.fullValuesSpan    = fullValuesSpan;
     this.visibleValuesSpan = visibleValuesSpan;
     this.fullAsciiSpan     = fullAsciiSpan;
     this.visibleAsciiSpan  = visibleAsciiSpan;
 }
コード例 #7
0
            public LayoutHelper(HexBufferLineFormatter bufferLines, HexLineTransformProvider lineTransformProvider, double newViewportTop, HashSet <HexViewLine> oldVisibleLines, List <PhysicalLine> oldLines, HexFormattedLineSource formattedLineSource)
            {
                this.bufferLines           = bufferLines;
                this.lineTransformProvider = lineTransformProvider;
                requestedViewportTop       = newViewportTop;
                this.oldLines            = oldLines;
                this.formattedLineSource = formattedLineSource;
                toPhysicalLine           = new Dictionary <HexFormattedLine, PhysicalLine>();
                this.oldVisibleLines     = oldVisibleLines;

                foreach (var physLine in oldLines)
                {
                    foreach (var line in physLine.Lines)
                    {
                        toPhysicalLine[line] = physLine;
                    }
                }
            }
コード例 #8
0
        void RecreateColumnLines()
        {
            delayRecreateColumnLinesCalled = false;
            if (wpfHexView.IsClosed)
            {
                return;
            }

            RemoveAllLines();
            if (!enabled)
            {
                return;
            }

            if (wpfHexView.ViewportHeight == 0)
            {
                return;
            }

            var line   = wpfHexView.HexViewLines.FirstVisibleLine;
            var top    = wpfHexView.ViewportTop;
            var bottom = wpfHexView.ViewportBottom;

            foreach (var info in GetColumnPositions(line.BufferLine))
            {
                var lineKind = GetColumnLineKind(info.Key);
                if (lineKind == HexColumnLineKind.None)
                {
                    continue;
                }
                var  props    = editorFormatMap.GetProperties(classificationTypeNames[(int)info.Key]);
                var  pen      = GetPen(props, lineKind);
                var  bounds   = line.GetCharacterBounds(info.Value);
                var  x        = Math.Round(bounds.Left + bounds.Width / 2 - PEN_THICKNESS / 2) + 0.5;
                var  lineElem = new LineElement(info.Key, x, top, bottom, pen);
                bool added    = adornmentLayer.AddAdornment(VSTE.AdornmentPositioningBehavior.OwnerControlled, (HexBufferSpan?)null, null, lineElem, null);
                if (added)
                {
                    lineElements.Add(lineElem);
                }
            }

            latestBufferLines = wpfHexView.BufferLines;
        }
コード例 #9
0
        void RecreateRectangles()
        {
            delayRecreateRectanglesCalled = false;
            if (wpfHexView.IsClosed)
            {
                return;
            }

            RemoveAllRectangles();
            if (!enabled)
            {
                return;
            }

            if (wpfHexView.ViewportHeight == 0)
            {
                return;
            }

            var line   = wpfHexView.HexViewLines.FirstVisibleLine;
            var top    = wpfHexView.ViewportTop;
            var bottom = wpfHexView.ViewportBottom;

            foreach (var info in GetRectanglePositions(line))
            {
                var props   = editorFormatMap.GetProperties(GetClassificationTypeName(info.type));
                var bgBrush = GetBackgroundBrush(props);
                if (bgBrush == null || TWPF.BrushComparer.Equals(bgBrush, Brushes.Transparent))
                {
                    continue;
                }
                var  lineElem = new RectangleElement(info.type, info.rect, bgBrush, null);
                bool added    = adornmentLayer.AddAdornment(VSTE.AdornmentPositioningBehavior.OwnerControlled, (HexBufferSpan?)null, null, lineElem, null);
                if (added)
                {
                    rectangleElements.Add(lineElem);
                }
            }

            latestBufferLines = wpfHexView.BufferLines;
        }
コード例 #10
0
ファイル: HexView.cs プロジェクト: 0xd4d/dnSpy
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="oldBufferLines">Old instance</param>
		/// <param name="newBufferLines">New instance</param>
		public BufferLinesChangedEventArgs(HexBufferLineFormatter oldBufferLines, HexBufferLineFormatter newBufferLines) {
			if (newBufferLines == null)
				throw new ArgumentNullException(nameof(newBufferLines));
			OldBufferLines = oldBufferLines;
			NewBufferLines = newBufferLines;
		}
コード例 #11
0
ファイル: HexHtmlBuilderService.cs プロジェクト: 0xd4d/dnSpy
		/// <summary>
		/// Creates an HTML fragment that can be copied to the clipboard
		/// </summary>
		/// <param name="spans">Spans</param>
		/// <param name="bufferLines">Buffer lines provider</param>
		/// <param name="cancellationToken">Cancellation token</param>
		/// <returns></returns>
		public string GenerateHtmlFragment(NormalizedHexBufferSpanCollection spans, HexBufferLineFormatter bufferLines, CancellationToken cancellationToken) =>
			GenerateHtmlFragment(spans, bufferLines, DefaultDelimiter, cancellationToken);
コード例 #12
0
 /// <summary>
 /// Creates an HTML fragment that can be copied to the clipboard
 /// </summary>
 /// <param name="spans">Spans</param>
 /// <param name="bufferLines">Buffer lines provider</param>
 /// <param name="cancellationToken">Cancellation token</param>
 /// <returns></returns>
 public string GenerateHtmlFragment(NormalizedHexBufferSpanCollection spans, HexBufferLineFormatter bufferLines, CancellationToken cancellationToken) =>
 GenerateHtmlFragment(spans, bufferLines, DefaultDelimiter, cancellationToken);
コード例 #13
0
 /// <summary>
 /// Creates an HTML fragment that can be copied to the clipboard
 /// </summary>
 /// <param name="spans">Spans</param>
 /// <param name="bufferLines">Buffer lines provider</param>
 /// <param name="delimiter">Delimiter added between generated html strings</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public abstract string GenerateHtmlFragment(NormalizedHexBufferSpanCollection spans, HexBufferLineFormatter bufferLines, string delimiter, CancellationToken cancellationToken);
コード例 #14
0
 public bool TryUpdateBufferLines(HexBufferLineFormatter bufferLines) => BufferLines == bufferLines;
コード例 #15
0
 public HexBufferLineImpl(HexBufferLineFormatter hexBufferLineFormatter, HexPosition lineNumber, ReadOnlyCollection <HexColumnType> columnOrder, HexBufferSpan bufferSpan, in HexBytes hexBytes, string text, bool isOffsetColumnPresent, bool isValuesColumnPresent, bool isAsciiColumnPresent, HexPosition logicalOffset, in HexCellCollection valueCells, in HexCellCollection asciiCells, VST.Span offsetSpan, VST.Span fullValuesSpan, VST.Span visibleValuesSpan, VST.Span fullAsciiSpan, VST.Span visibleAsciiSpan)
コード例 #16
0
        public void Add(HexBufferLineFormatter bufferLines, HexClassifier classifier, NormalizedHexBufferSpanCollection spans, CancellationToken cancellationToken)
        {
            if (bufferLines == null)
            {
                throw new ArgumentNullException(nameof(bufferLines));
            }
            if (classifier == null)
            {
                throw new ArgumentNullException(nameof(classifier));
            }
            if (spans == null)
            {
                throw new ArgumentNullException(nameof(spans));
            }
            if (spans.Count != 0 && spans[0].Buffer != bufferLines.Buffer)
            {
                throw new ArgumentException();
            }

            var classificationSpans = new List <HexClassificationSpan>();

            foreach (var span in spans)
            {
                if (spansCount > 0)
                {
                    htmlWriter.WriteRaw(delimiter);
                }
                spansCount++;

                var pos = span.Start;
                for (;;)
                {
                    classificationSpans.Clear();
                    var line    = bufferLines.GetLineFromPosition(pos);
                    var text    = line.GetText(span);
                    var context = new HexClassificationContext(line, line.TextSpan);
                    classifier.GetClassificationSpans(classificationSpans, context, cancellationToken);

                    int textPos = 0;
                    foreach (var tagSpan in classificationSpans)
                    {
                        if (textPos < tagSpan.Span.Start)
                        {
                            WriteCss(classificationFormatMap.DefaultTextProperties);
                            htmlWriter.WriteSpan(cssWriter.ToString(), text, textPos, tagSpan.Span.Start - textPos);
                        }
                        WriteCss(classificationFormatMap.GetTextProperties(tagSpan.ClassificationType));
                        htmlWriter.WriteSpan(cssWriter.ToString(), text, tagSpan.Span.Start, tagSpan.Span.Length);
                        textPos = tagSpan.Span.End;
                    }
                    if (textPos < text.Length)
                    {
                        WriteCss(classificationFormatMap.DefaultTextProperties);
                        htmlWriter.WriteSpan(cssWriter.ToString(), text, textPos, text.Length - textPos);
                    }
                    htmlWriter.WriteRaw("<br/>");

                    pos = line.BufferEnd;
                    if (pos >= span.End)
                    {
                        break;
                    }
                }
            }
        }
コード例 #17
0
        public override string GenerateHtmlFragment(NormalizedHexBufferSpanCollection spans, HexBufferLineFormatter bufferLines, string delimiter, CancellationToken cancellationToken)
        {
            if (spans is null)
            {
                throw new ArgumentNullException(nameof(spans));
            }
            if (bufferLines is null)
            {
                throw new ArgumentNullException(nameof(bufferLines));
            }
            if (delimiter is null)
            {
                throw new ArgumentNullException(nameof(delimiter));
            }
            if (spans.Count != 0 && spans[0].Buffer != bufferLines.Buffer)
            {
                throw new ArgumentException();
            }

            return(GenerateHtmlFragmentCore(bufferLines, spans, null, delimiter, cancellationToken));
        }
コード例 #18
0
ファイル: HexHtmlBuilderService.cs プロジェクト: 0xd4d/dnSpy
		/// <summary>
		/// Creates an HTML fragment that can be copied to the clipboard
		/// </summary>
		/// <param name="spans">Spans</param>
		/// <param name="bufferLines">Buffer lines provider</param>
		/// <param name="delimiter">Delimiter added between generated html strings</param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		public abstract string GenerateHtmlFragment(NormalizedHexBufferSpanCollection spans, HexBufferLineFormatter bufferLines, string delimiter, CancellationToken cancellationToken);