protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (item != null) { var itemRect = new Rect(item.RenderSize); Point startPoint; Point endPoint; if (!showMarkerAfterItem) { startPoint = itemRect.TopLeft; endPoint = itemRect.TopRight; } else { startPoint = itemRect.BottomLeft; endPoint = itemRect.BottomRight; } startPoint = item.TranslatePoint(startPoint, control); endPoint = item.TranslatePoint(endPoint, control); drawingContext.PushClip(new RectangleGeometry(adornerViewRect)); drawingContext.DrawLine(new Pen(Brushes.Green, 2), startPoint, endPoint); } }
public void Draw(LayerModel layer, DrawingContext c) { // If an animation is present, let it handle the drawing if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation)) { layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c); return; } // Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush var rect = layer.Properties.Contain ? new Rect(layer.AppliedProperties.X*4, layer.AppliedProperties.Y*4, layer.AppliedProperties.Width*4, layer.AppliedProperties.Height*4) : new Rect(layer.Properties.X*4, layer.Properties.Y*4, layer.Properties.Width*4, layer.Properties.Height*4); var clip = new Rect(layer.AppliedProperties.X*4, layer.AppliedProperties.Y*4, layer.AppliedProperties.Width*4, layer.AppliedProperties.Height*4); c.PushClip(new RectangleGeometry(clip)); c.DrawRectangle(layer.AppliedProperties.Brush, null, rect); c.Pop(); }
private void DrawBorders(System.Windows.Media.DrawingContext dc) { dc.PushClip(new RectangleGeometry(new Rect(0, 0, Width, Height))); int lineNumber = StartLine; if (lineNumber > 0) { lineNumber--; } while (lineNumber > 0 && !REPLData.KindIsGap(LineKinds[lineNumber])) { lineNumber--; } while (true) { double topY = (lineNumber - StartLine) * LineHeight + 2; lineNumber++; while (lineNumber < Lines.Count && !REPLData.KindIsGap(LineKinds[lineNumber])) { lineNumber++; } double bottomY = (lineNumber - StartLine) * LineHeight + 2; dc.DrawRoundedRectangle(InsideBrush, BorderPen, new Rect(SpaceWidth / 2, topY + topOffset, Width - SpaceWidth, bottomY - topY - LineHeight / 3), SpaceWidth, SpaceWidth); if (lineNumber >= Lines.Count - 1 || lineNumber > StartLine + Height / LineHeight) { break; } } ; dc.Pop(); }
public void Draw(DrawingContext context, DrawingArgs args) { context.PushClip(new RectangleGeometry(args.RenderBounds)); if (m_IsDirty || args.RequiresFullRedraw) { m_LonePoints.Clear(); System.Windows.Media.StreamGeometry geo = new StreamGeometry(); using (var c = geo.Open()) { Point? figureStart = null; int pointCount = 0; //point in the figure if (Values.Count() == 1 && Values.First().HasValue) { m_LonePoints.Add(Values.First().Value); } else { foreach (var p in Values) { if (p.HasValue) { if (!figureStart.HasValue) { figureStart = p.Value; c.BeginFigure(figureStart.Value, false, false); pointCount = 1; } else { c.LineTo(p.Value, true, true); pointCount++; } } else { //detect lone points and draw a cross if (pointCount == 1) { m_LonePoints.Add(figureStart.Value); } figureStart = null; } } } } m_Geo = geo; m_IsDirty = false; } m_Geo.Transform = args.Transform; context.DrawGeometry(null, Pen, m_Geo); var radius = Pen.Thickness; foreach (var p in m_LonePoints) { context.DrawEllipse(m_Pen.Brush, null, args.Transform.Transform(p), radius, radius); } }
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c) { if (applied?.Brush == null) return; const int scale = 4; // Set up variables for this frame var rect = props.Contain ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale) : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale); var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale); // Take an offset of 4 to allow layers to slightly leave their bounds var progress = (6.0 - props.AnimationProgress)*10.0; if (progress < 0) { // Can't meddle with the original brush because it's frozen. var brush = applied.Brush.Clone(); brush.Opacity = 1 + 0.025*progress; if (brush.Opacity < 0) brush.Opacity = 0; if (brush.Opacity > 1) brush.Opacity = 1; applied.Brush = brush; } rect.Inflate(-rect.Width/100.0*progress, -rect.Height/100.0*progress); clip.Inflate(-clip.Width/100.0*progress, -clip.Height/100.0*progress); c.PushClip(new RectangleGeometry(clip)); c.DrawRectangle(applied.Brush, null, rect); c.Pop(); }
public void Render(DrawingContext drawingContext) { if (IsVisible) { drawingContext.PushClip(_clipGeometry); drawingContext.DrawGeometry(null, PainterCache.GridLinePen, _geometry); drawingContext.Pop(); } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { if (_bitmap != null) { drawingContext.PushClip(new RectangleGeometry(new Rect(RenderSize))); drawingContext.DrawImage(_bitmap, new Rect(new Size(_bitmap.Width, _bitmap.Height))); drawingContext.Pop(); } }
public void DrawCircle(Point center, DrawingContext drawingContext, Size windowSize, bool drawCircle) { var rectangle = new Rect(center.X - Radius, center.Y - Radius, Radius * 2, Radius * 2); var path = new PathGeometry(); path.AddGeometry(new EllipseGeometry(rectangle)); drawingContext.PushClip(path); var windowRect = new Rect(windowSize); drawingContext.DrawImage(Bitmap, windowRect); if (drawCircle) drawingContext.DrawEllipse(Brushes.Transparent, new Pen(Brushes.Red, 1.5), center, Radius, Radius); }
/// <summary>This method performs the actual render operation to show a text label</summary> /// <param name="dc">Drawing context</param> /// <param name="info">Render info</param> /// <param name="scale">The scale.</param> /// <param name="offset">The offset.</param> public virtual void RenderHeader(DrawingContext dc, AutoHeaderTextRenderInfo info, double scale, Point offset) { dc.PushTransform(new TranslateTransform(offset.X, offset.Y)); dc.PushTransform(new ScaleTransform(scale, scale)); dc.PushClip(new RectangleGeometry(info.RenderRect)); info.FormattedText.SetMaxTextWidths(new[] { info.RenderRect.Width }); info.FormattedText.MaxLineCount = 1; info.FormattedText.Trimming = TextTrimming.CharacterEllipsis; dc.DrawText(info.FormattedText, info.RenderRect.TopLeft); dc.Pop(); dc.Pop(); dc.Pop(); }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { if (_bitmap != null) { var bitmapSize = new Vector(_bitmap.Width, _bitmap.Height); var dpiScaleToWpfScale = CurrentHwndSource.CompositionTarget.TransformFromDevice; var adjustedBitmapSize = dpiScaleToWpfScale.Transform(bitmapSize); drawingContext.PushClip(new RectangleGeometry(new Rect(RenderSize))); drawingContext.DrawImage(_bitmap, new Rect(new Size(adjustedBitmapSize.X, adjustedBitmapSize.Y))); drawingContext.Pop(); } }
//private const int Margin = 3; protected override void InnerDraw(DrawingContext drawingContext) { base.InnerDraw(drawingContext); if (_scaleTransform != null) drawingContext.PushTransform(_scaleTransform); if (_clipGeometry != null) drawingContext.PushClip(_clipGeometry); drawingContext.DrawDrawing(_textDrawing); if (_clipGeometry != null) drawingContext.Pop(); if (_scaleTransform != null) drawingContext.Pop(); }
protected override void OnRender(DrawingContext ctx) { ctx.PushClip(new RectangleGeometry(new Rect(0, 0, this.ActualWidth, this.ActualHeight)));//restrict drawing to textbox ctx.DrawRectangle(LineNumberBackground, null, new Rect(0, 0, this.ActualWidth, this.ActualHeight));//Draw Background int count = (int)(this.ActualHeight / CodeBox.GetLineHeight()); string lineText = string.Join( Environment.NewLine, Enumerable.Range(firstLine + 1, count).Select(l => l.ToString()).ToArray()); var text = CodeBox.GetFormatText(lineText, LineNumberForeground); ctx.DrawText(text, new Point(0, 0)); }
private void DrawText(System.Windows.Media.DrawingContext dc) { dc.PushClip(new RectangleGeometry(new Rect(10, 0, Width - 20, Height))); for (int lineNumber = StartLine; lineNumber < Lines.Count && lineNumber <= StartLine + Height / LineHeight; lineNumber++) { double Y = (lineNumber - StartLine) * LineHeight + 2; if (lineNumber == CursorLine) { dc.DrawRectangle(BackCursorBrush, null, new Rect(0, Y, Width, LineHeight)); } DrawTextUsingString(dc, lineNumber, Y); } dc.Pop(); }
public void Render(DrawingContext drawingContext) { if (!_hidden) { if (_renderClip != null) { drawingContext.PushClip(_renderClip); } OnRender(drawingContext); if (_renderClip != null) { drawingContext.Pop(); } } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { Double width = this.ActualWidth; Double height = this.ActualHeight; Double a = width / 2; Double b = height / 2; Point centerPoint = new Point(a, b); Double thickness = this.BorderThickness.Left; EllipseGeometry ellipse = new EllipseGeometry(centerPoint, a, b); drawingContext.PushClip(ellipse); drawingContext.DrawGeometry( this.Background, new Pen(this.BorderBrush, thickness), ellipse); }
protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height) { // Clip to rounded rectangle shape. dc.PushClip(new RectangleGeometry(new Rect(new Size(width, height)), Roundness, Roundness)); // Draw image. dc.PushTransform(new TranslateTransform(BorderWidth, BorderWidth)); dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height)); dc.Pop(); dc.Pop(); // Draw border. dc.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(BorderColor.ToWpfColor()), BorderWidth), new Rect(BorderWidth / 2.0, BorderWidth / 2.0, width - BorderWidth, height - BorderWidth), Roundness, Roundness); }
protected override void OnRender(DrawingContext dc) { if ( this.ClipToBounds ) { dc.PushClip( new RectangleGeometry( new Rect( 0, 0, this.ActualWidth, this.ActualHeight ) ) ); } dc.DrawRectangle( Brushes.White, new Pen(), new Rect( 0, 0, this.ActualWidth, this.ActualHeight ) ); base.OnRender( dc ); if ( this.Text == String.Empty && this.HintTextImage != null ) { dc.DrawText( this.HintTextImage, new Point( 4, ( this.ActualHeight - this.HintTextImage.Height ) / 2 ) ); } if ( this.ClipToBounds ) { // pop the clip that we added dc.Pop(); } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (_diffs != null) { var viewLeft = _editLeft.TextArea.TextView; var viewRight = _editRight.TextArea.TextView; viewLeft.EnsureVisualLines(); viewRight.EnsureVisualLines(); var leftFirst = viewLeft.VisualLines.First().FirstDocumentLine.LineNumber; var leftLast = viewLeft.VisualLines.Last().LastDocumentLine.LineNumber; var rightFirst = viewRight.VisualLines.First().FirstDocumentLine.LineNumber; var rightLast = viewRight.VisualLines.Last().LastDocumentLine.LineNumber; Func<ListCompare, bool> inRange = (c => Math.Abs(c.Base) >= leftFirst && Math.Abs(c.Base) <= leftLast || Math.Abs(c.Compare) >= rightFirst && Math.Abs(c.Compare) <= rightLast); var start = 0; while (start < _diffs.Count && !inRange(_diffs[start])) start++; if (start >= _diffs.Count) start--; var end = start; while (start >= 0 && GetDiffType(_diffs[start]) != DiffType.Normal) start--; while (end < _diffs.Count && inRange(_diffs[end])) end++; end--; while (end < _diffs.Count && GetDiffType(_diffs[end]) != DiffType.Normal) end++; var lastType = GetDiffType(_diffs[start]); DiffType currType; Geometry geom; drawingContext.PushClip(new RectangleGeometry(new Rect(new Point(0, 0), this.RenderSize))); for (var i = start + 1; i <= end; i++) { currType = GetDiffType(_diffs[i]); if (currType != lastType) { geom = GetPath(new Point(0, viewLeft.GetOrConstructVisualLine(viewLeft.Document.GetLineByNumber(Math.Abs(_diffs[i].Base))).VisualTop - viewLeft.VerticalOffset), new Point(Width, viewRight.GetOrConstructVisualLine(viewRight.Document.GetLineByNumber(Math.Abs(_diffs[i].Compare))).VisualTop - viewRight.VerticalOffset)); drawingContext.DrawGeometry(null, new Pen() { Thickness = 2, Brush = Brushes.Black }, geom); } lastType = currType; } } }
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c) { if (applied.Brush == null) return; const int scale = 4; // Set up variables for this frame var rect = props.Contain ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale) : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale); var s1 = new Rect(new Point(rect.X, rect.Y + props.AnimationProgress), new Size(rect.Width, rect.Height)); var s2 = new Rect(new Point(s1.X, s1.Y - rect.Height), new Size(rect.Width, rect.Height + .5)); var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale); c.PushClip(new RectangleGeometry(clip)); c.DrawRectangle(applied.Brush, null, s1); c.DrawRectangle(applied.Brush, null, s2); c.Pop(); }
protected override void OnRender(System.Windows.Media.DrawingContext dc) { BackBrush = new SolidColorBrush(Colors.AntiqueWhite); BackCursorBrush = new SolidColorBrush(Colors.Yellow); ForeBrush = new SolidColorBrush(Colors.Chocolate); BackHighBrush = new SolidColorBrush(Colors.Red); ForeHighBrush = new SolidColorBrush(Colors.Yellow); dc.DrawRectangle(BackBrush, null, new Rect(0, 0, Width, Height)); dc.PushClip(new RectangleGeometry(new Rect(0, 0, Width, Height))); for (int lineNumber = StartLine; lineNumber < LineStarts.Length && lineNumber <= StartLine + Height / LineHeight; lineNumber++) { double Y = (lineNumber - StartLine) * LineHeight + 2; if (lineNumber == CursorLine) { dc.DrawRectangle(BackCursorBrush, null, new Rect(0, Y, Width, LineHeight)); } if (TheList != null) { double X = LineIndentations[lineNumber] * SpaceWidth + 2; int startToken = LineStarts[lineNumber]; int finishToken = (lineNumber < LineStarts.Length - 1) ? (LineStarts[lineNumber + 1] - 1) : (LineStarts.Length - 1); for (int i = startToken; i <= finishToken; i++) { if (i > 0 && TheList[i - 1].Kind != LexKind.Delimiter && TheList[i].Kind != LexKind.Delimiter) { X += SpaceWidth; } DrawTextUsingLexList(dc, i, ref X, Y); } } else if (Source != null) { DrawTextUsingString(dc, LineStarts[lineNumber], LineLengths[lineNumber], Y); } } }
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c) { if (applied.Brush == null) return; const int scale = 4; // Set up variables for this frame var rect = props.Contain ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale) : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale); var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale); // Can't meddle with the original brush because it's frozen. var brush = applied.Brush.Clone(); brush.Opacity = (Math.Sin(props.AnimationProgress*Math.PI) + 1)*(props.Opacity/2); applied.Brush = brush; c.PushClip(new RectangleGeometry(clip)); c.DrawRectangle(applied.Brush, null, rect); c.Pop(); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); // Introduce clipping drawingContext.PushClip(new RectangleGeometry(new Rect(_adornedElement.RenderSize))); foreach (ChartMarkerSet set in MarkerSets) { // ChartPrimitive parent = set.ParentPrimitive; var setBrush = new SolidColorBrush(set.Fill); var setPen = new Pen(new SolidColorBrush(set.Stroke), set.StrokeWidth); foreach (ChartPoint p in set.Points) { // Snap the marker's Y-position onto the parent primitive var snappedToParentPos = p.Point; // snappedToParentPos.Y = parent.GetValueY(p.Point.X); // Then render it to the adorner layer (which is on top of the plot canvas) Point pixelPos = _parentChart.ToPixel(snappedToParentPos); drawingContext.DrawEllipse(setBrush, setPen, pixelPos, set.Size/2, set.Size/2); const double labelOffsetY = 10; Point labelPixelOffset = new Point(0, +5); if (snappedToParentPos.Y >= 0) labelPixelOffset.Offset(0, labelOffsetY); else labelPixelOffset.Offset(0, -labelOffsetY); // ChartHelper.RenderTextToChartPosition(drawingContext, _parentChart.TextCanvasInfo, p.Label, set.Color, snappedToParentPos, labelPixelOffset, FlipYAxis, true); } } // End clipping drawingContext.Pop(); }
protected override void OnRender(DrawingContext dc) { Brush bgBrush = Background; dc.DrawRectangle(bgBrush, null, new Rect(RenderSize)); if (Items == null) { return; } try { //long tickStart = DateTime.Now.Ticks; //パフォーマンス計測用 double selfLeft = Canvas.GetLeft(this); // Items 設定時に CreateDrawTextList を行うと、番組表に複数のタブを設定していると // 全てのタブの GlyphRun を一度に生成しようとするので、最初の表示までに多くの時間がかかる。 // 表示しようとするタブのみ GlyphRun を行うことで、最初の応答時間を削減することにする。 CreateDrawTextList(); //long tickGlyphRun = DateTime.Now.Ticks; //パフォーマンス計測用 foreach (ProgramViewItem info in Items) { dc.DrawRectangle(bgBrush, null, new Rect(info.LeftPos - selfLeft, info.TopPos, info.Width, 1)); dc.DrawRectangle(bgBrush, null, new Rect(info.LeftPos - selfLeft, info.TopPos + info.Height, info.Width, 1)); if (info.Height > 1) { dc.DrawRectangle(info.ContentColor, null, new Rect(info.LeftPos - selfLeft, info.TopPos + 0.5, info.Width - 1, info.Height - 0.5)); if (textDrawDict.ContainsKey(info)) { dc.PushClip(new RectangleGeometry(new Rect(info.LeftPos - selfLeft, info.TopPos + 0.5, info.Width - 1, info.Height - 0.5))); foreach (TextDrawItem txtinfo in textDrawDict[info]) { dc.DrawGlyphRun(txtinfo.FontColor, txtinfo.Text); } dc.Pop(); } } } // EpgViewPanel は複数に分けて Render するので、最後のパネルが Render し終わったら // 些細なメモリ節約のために cache をクリアする ItemFontNormal.ClearCache(); ItemFontTitle.ClearCache(); //パフォーマンス計測用 //long tickDraw = DateTime.Now.Ticks; //Console.Write("GlyphRun = " + Math.Round((tickGlyphRun - tickStart)/10000D).ToString() // + ", Draw = " + Math.Round((tickDraw - tickGlyphRun)/10000D).ToString() // + ", Total = " + Math.Round((tickDraw-tickStart)/10000D).ToString() + "\n"); } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
/// <summary>Draws the text glyph in the specified target area.</summary> /// <param name="dc">The drawing context to draw on.</param> /// <param name="foreground">The text foreground brush.</param> /// <param name="targetArea">The target area where the text is to be drawn (according to the specified alignment).</param> /// <param name="alignment">Indicates how to align the text with respect to the target area.</param> public void Draw(DrawingContext dc, Brush foreground, Rect targetArea, TextAlign alignment) { if (IsEmpty || targetArea.IsEmpty || foreground == null) return; // compute bounds var bounds = _computeBounds(targetArea, alignment); dc.PushTranslate(bounds.X + SharpnessVector.X, bounds.Y + SharpnessVector.Y); if (TextOverflow == TextOverflow.Ignore || Width <= bounds.Width) { // ignore overflow - use original glyph run and draw it without clipping _drawGlyphRun(dc, _fullRun, foreground); } else if (TextOverflow == TextOverflow.Clip) { // clip overflow - use original glyph run but clip it to fit bounds var clipRect = new RectangleGeometry(new Rect(new Point(), bounds.Size)); clipRect.Freeze(); dc.PushClip(clipRect); _drawGlyphRun(dc, _fullRun, foreground); dc.Pop(); } else { // trim overflow - create a trimmed glyph run that fits the bounds and cache it for next invocation // (the caching of the trimmed glyph is effective only if the width does not change - e.g., when drawing the same glyph in a different color) if (_trimmedWidth.CertainlyDifferent(bounds.Width)) { var result = _buildGlyph(false, bounds.Width); _trimmedRun = (result != null ? result.GlyphRun : null); _trimmedWidth = bounds.Width; } _drawGlyphRun(dc, _trimmedRun, foreground); } dc.Pop(); }
/// <summary> /// render map in WPF /// </summary> /// <param name="g"></param> void DrawMap(DrawingContext g) { if(MapProvider == EmptyProvider.Instance || MapProvider == null) { return; } Core.tileDrawingListLock.AcquireReaderLock(); Core.Matrix.EnterReadLock(); try { foreach(var tilePoint in Core.tileDrawingList) { Core.tileRect.Location = tilePoint.PosPixel; Core.tileRect.OffsetNegative(Core.compensationOffset); //if(region.IntersectsWith(Core.tileRect) || IsRotated) { bool found = false; Tile t = Core.Matrix.GetTileWithNoLock(Core.Zoom, tilePoint.PosXY); if(t.NotEmpty) { foreach(GMapImage img in t.Overlays) { if(img != null && img.Img != null) { if(!found) found = true; var imgRect = new Rect(Core.tileRect.X + 0.6, Core.tileRect.Y + 0.6, Core.tileRect.Width + 0.6, Core.tileRect.Height + 0.6); if(!img.IsParent) { g.DrawImage(img.Img, imgRect); } else { // TODO: move calculations to loader thread var geometry = new RectangleGeometry(imgRect); var parentImgRect = new Rect(Core.tileRect.X - Core.tileRect.Width * img.Xoff + 0.6, Core.tileRect.Y - Core.tileRect.Height * img.Yoff + 0.6, Core.tileRect.Width * img.Ix + 0.6, Core.tileRect.Height * img.Ix + 0.6); g.PushClip(geometry); g.DrawImage(img.Img, parentImgRect); g.Pop(); geometry = null; } } } } else if(FillEmptyTiles && MapProvider.Projection is MercatorProjection) { #region -- fill empty tiles -- int zoomOffset = 1; Tile parentTile = Tile.Empty; long Ix = 0; while(!parentTile.NotEmpty && zoomOffset < Core.Zoom && zoomOffset <= LevelsKeepInMemmory) { Ix = (long)Math.Pow(2, zoomOffset); parentTile = Core.Matrix.GetTileWithNoLock(Core.Zoom - zoomOffset++, new GMap.NET.GPoint((int)(tilePoint.PosXY.X / Ix), (int)(tilePoint.PosXY.Y / Ix))); } if(parentTile.NotEmpty) { long Xoff = Math.Abs(tilePoint.PosXY.X - (parentTile.Pos.X * Ix)); long Yoff = Math.Abs(tilePoint.PosXY.Y - (parentTile.Pos.Y * Ix)); var geometry = new RectangleGeometry(new Rect(Core.tileRect.X + 0.6, Core.tileRect.Y + 0.6, Core.tileRect.Width + 0.6, Core.tileRect.Height + 0.6)); var parentImgRect = new Rect(Core.tileRect.X - Core.tileRect.Width * Xoff + 0.6, Core.tileRect.Y - Core.tileRect.Height * Yoff + 0.6, Core.tileRect.Width * Ix + 0.6, Core.tileRect.Height * Ix + 0.6); // render tile { foreach(GMapImage img in parentTile.Overlays) { if(img != null && img.Img != null && !img.IsParent) { if(!found) found = true; g.PushClip(geometry); g.DrawImage(img.Img, parentImgRect); g.DrawRectangle(SelectedAreaFill, null, geometry.Bounds); g.Pop(); } } } geometry = null; } #endregion } // add text if tile is missing if(!found) { lock(Core.FailedLoads) { var lt = new LoadTask(tilePoint.PosXY, Core.Zoom); if(Core.FailedLoads.ContainsKey(lt)) { g.DrawRectangle(EmptytileBrush, EmptyTileBorders, new Rect(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height)); var ex = Core.FailedLoads[lt]; FormattedText TileText = new FormattedText("Exception: " + ex.Message, System.Globalization.CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, tileTypeface, 14, Brushes.Red); TileText.MaxTextWidth = Core.tileRect.Width - 11; g.DrawText(TileText, new System.Windows.Point(Core.tileRect.X + 11, Core.tileRect.Y + 11)); g.DrawText(EmptyTileText, new System.Windows.Point(Core.tileRect.X + Core.tileRect.Width / 2 - EmptyTileText.Width / 2, Core.tileRect.Y + Core.tileRect.Height / 2 - EmptyTileText.Height / 2)); } } } if(ShowTileGridLines) { g.DrawRectangle(null, EmptyTileBorders, new Rect(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height)); if(tilePoint.PosXY == Core.centerTileXYLocation) { FormattedText TileText = new FormattedText("CENTER:" + tilePoint.ToString(), System.Globalization.CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, tileTypeface, 16, Brushes.Red); TileText.MaxTextWidth = Core.tileRect.Width; g.DrawText(TileText, new System.Windows.Point(Core.tileRect.X + Core.tileRect.Width / 2 - EmptyTileText.Width / 2, Core.tileRect.Y + Core.tileRect.Height / 2 - TileText.Height / 2)); } else { FormattedText TileText = new FormattedText("TILE: " + tilePoint.ToString(), System.Globalization.CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, tileTypeface, 16, Brushes.Red); TileText.MaxTextWidth = Core.tileRect.Width; g.DrawText(TileText, new System.Windows.Point(Core.tileRect.X + Core.tileRect.Width / 2 - EmptyTileText.Width / 2, Core.tileRect.Y + Core.tileRect.Height / 2 - TileText.Height / 2)); } } } } } finally { Core.Matrix.LeaveReadLock(); Core.tileDrawingListLock.ReleaseReaderLock(); } }
private void Render(DrawingContext drawingContext) { drawingContext.DrawRectangle(Brushes.White, null, new Rect(new Point(), RenderSize)); if (m_blame == null || m_emSize == 0) return; Typeface typeface = TextElementUtility.GetTypeface(this); BlameLayout layout = m_layout.WithRenderSize(RenderSize); foreach (Rect newLineRectangle in layout.NewLines) drawingContext.DrawRectangle(m_newLineBrush, null, newLineRectangle); foreach (DisplayBlock block in layout.Blocks) { Rect blockRectangle = block.CommitPosition; drawingContext.DrawRectangle(m_personBrush[block.AuthorIndex], null, block.AuthorPosition); drawingContext.DrawRectangle(GetOrCreateCommitBrush(block), null, blockRectangle); drawingContext.DrawLine(new Pen(Brushes.LightGray, 1), new Point(0, blockRectangle.Bottom + 0.5), new Point(RenderSize.Width, blockRectangle.Bottom + 0.5)); FormattedText authorText = CreateSmallFormattedText(block.AuthorName, typeface, block.AuthorWidth); drawingContext.DrawText(authorText, new Point(block.AuthorX, block.TextY)); FormattedText dateText = CreateSmallFormattedText(block.Date, typeface, block.DateWidth); dateText.TextAlignment = TextAlignment.Right; drawingContext.DrawText(dateText, new Point(block.DateX, block.TextY)); if (block.ShowsSummary) { Rect summaryPosition = block.SummaryPosition; FormattedText commitText = CreateSmallFormattedText(block.Summary, typeface, summaryPosition.Width); commitText.MaxLineCount = Math.Max(1, (int) (summaryPosition.Height / commitText.Height)); commitText.Trimming = TextTrimming.WordEllipsis; drawingContext.DrawText(commitText, summaryPosition.TopLeft); } } Column lineNumberColumn = layout.LineNumberColumn; double yOffset = 0; double lineNumberWidth = lineNumberColumn.Width; foreach (DisplayLine line in layout.Lines) { FormattedText lineNumberText = CreateFormattedText(line.LineNumber.ToString(CultureInfo.InvariantCulture), typeface); lineNumberText.TextAlignment = TextAlignment.Right; lineNumberText.SetForegroundBrush(Brushes.DarkCyan); lineNumberWidth = Math.Max(lineNumberWidth, lineNumberText.Width); lineNumberText.MaxTextWidth = lineNumberWidth; drawingContext.DrawText(lineNumberText, new Point(lineNumberColumn.Left, yOffset)); yOffset += layout.LineHeight; } layout = layout.WithLineNumberWidth(lineNumberWidth); Column codeColumn = layout.CodeColumn; Geometry clipGeometry = new RectangleGeometry(new Rect(codeColumn.Left, 0, RenderSize.Width - codeColumn.Left, RenderSize.Height)); drawingContext.PushClip(clipGeometry); yOffset = 0; foreach (DisplayLine line in layout.Lines) { double xOffset = layout.CodeColumn.Left - HorizontalOffset; foreach (LinePart part in line.Parts) { FormattedText text = CreateFormattedText(string.Join("", part.Text.Replace("\t", " ")), typeface); if (!line.IsNew && part.Status == LinePartStatus.New) drawingContext.DrawRectangle(m_changedTextBrush, null, new Rect(xOffset, yOffset, text.WidthIncludingTrailingWhitespace, layout.LineHeight)); drawingContext.DrawText(text, new Point(xOffset, yOffset)); xOffset += text.WidthIncludingTrailingWhitespace; } layout = layout.WithCodeWidth(xOffset - codeColumn.Left + HorizontalOffset); yOffset += layout.LineHeight; } drawingContext.Pop(); double commitRightX = layout.CommitColumn.Right; drawingContext.DrawLine(new Pen(Brushes.DarkGray, 1), new Point(commitRightX, 0), new Point(commitRightX, Math.Min(yOffset, RenderSize.Height))); double lineNumberRightX = layout.CodeMarginColumn.Right; drawingContext.DrawLine(new Pen(Brushes.DarkGray, 1), new Point(lineNumberRightX, 0), new Point(lineNumberRightX, Math.Min(yOffset, RenderSize.Height))); SetHorizontalScrollInfo(layout.Width, RenderSize.Width, null); if (layout != m_layout) { m_layout = layout; RedrawSoon(); } }
//*********************************************************************************************** //*********************************************************************************************** //*********************************************************************************************** //*********************************************************************************************** //*********************************************************************************************** protected override void OnRender(DrawingContext drawingContext) { drawingContext.DrawRectangle(Background, null, new Rect(new Size(ActualWidth, ActualHeight))); drawingContext.PushClip(new RectangleGeometry(new Rect(new Size(ActualWidth, ActualHeight)))); DrawMainLines(drawingContext); DrawGridLines(drawingContext); DrawAllGraphLines(drawingContext); }
protected override void OnRender(DrawingContext dc) { dc.DrawRectangle(Background, null, new Rect(RenderSize)); this.VisualTextRenderingMode = TextRenderingMode.ClearType; this.VisualTextHintingMode = TextHintingMode.Fixed; this.UseLayoutRounding = true; if (Items == null) { return; } try { double sizeNormal = Settings.Instance.FontSize; double sizeTitle = Settings.Instance.FontSizeTitle; Brush bgBrush = Background; foreach (ProgramViewItem info in Items) { dc.DrawRectangle(bgBrush, null, new Rect(info.LeftPos, info.TopPos, info.Width, 1)); dc.DrawRectangle(bgBrush, null, new Rect(info.LeftPos, info.TopPos + info.Height, info.Width, 1)); if (info.Height > 1) { dc.DrawRectangle(info.ContentColor, null, new Rect(info.LeftPos + 0, info.TopPos + 0.5, info.Width - 1, info.Height - 0.5)); if (textDrawDict.ContainsKey(info)) { dc.PushClip(new RectangleGeometry(new Rect(info.LeftPos + 0, info.TopPos + 0.5, info.Width - 1, info.Height - 0.5))); foreach (TextDrawItem txtinfo in textDrawDict[info]) { dc.DrawGlyphRun(txtinfo.FontColor, txtinfo.Text); } dc.Pop(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
protected override void OnRender(DrawingContext DC) { DC.DrawRectangle(BorderBrush, null, new Rect(0, 0, ActualWidth, ActualHeight)); Rect bounds = new Rect( BorderThickness.Left, BorderThickness.Top, ActualWidth - (BorderThickness.Right + BorderThickness.Left), ActualHeight - (BorderThickness.Top + BorderThickness.Bottom)); DC.PushClip(new RectangleGeometry(bounds)); DC.DrawRectangle(Background, null, bounds); DrawTimeAxis(DC, bounds); if (Signals.Empty()) return; Signal stats = SelectedSignal; Signal stabilize = stats; if (stabilize == null) stabilize = Signals.First(); double sampleRate = Signals.SampleRate; double f0 = 0.0; // Remembe the clock for when we analyzed the signal to keep the signals in sync even if new data gets added in the background. long sync = stabilize.Clock; lock (stabilize.Lock) { int Decimate = 1 << (int)Math.Floor(Math.Log(sampleRate / 22000, 2)); int BlockSize = 8192; if (stabilize.Count >= BlockSize) { double[] data = stabilize.Skip(stabilize.Count - BlockSize).ToArray(); // Estimate the fundamental frequency of the signal. double phase; double f = Frequency.Estimate(data, Decimate, out phase); // Convert phase from (-pi, pi] to (0, 1] phase = ((phase + Math.PI) / (2 * Math.PI)); // Shift all the signals by the phase in samples to align the signal between frames. if (f > 1.0) sync -= (int)Math.Round(phase * BlockSize / f); // Compute fundamental frequency in Hz. f0 = sampleRate * f / BlockSize; } } double mean = 0.0; double peak = 0.0; double rms = 0.0; if (stats != null) { lock (stats.Lock) { // Compute statistics of the clock signal. mean = stats.Sum() / stats.Count; peak = stats.Max(i => Math.Abs(i - mean), 0.0); rms = Math.Sqrt(stats.Sum(i => (i - mean) * (i - mean)) / stats.Count); } } else { foreach (Signal i in signals) lock (i.Lock) peak = Math.Max(peak, i.Max(j => Math.Abs(j), 0.0)); } // Compute the target min/max double bound = peak; double gamma = 0.1; double window = Math.Max(Math.Pow(2.0, Math.Ceiling(Math.Log(bound + 1e-9, 2.0))), 1e-2); Vmax = Math.Max(TimeFilter(Vmax, window, gamma), Math.Abs(bound + (Vmean - mean))); Vmean = TimeFilter(Vmean, mean, gamma); if (Math.Abs(mean) * 1e2 < Vmax) Vmean = 0.0; DrawSignalAxis(DC, bounds); foreach (Signal i in signals.Except(stabilize).Append(stabilize)) lock (i.Lock) DrawSignal(DC, bounds, i, (int)(sync - i.Clock)); if (stats != null) DrawStatistics(DC, bounds, stats.Pen.Brush, peak, mean, rms, f0); if (tracePoint.HasValue) DrawTrace(DC, bounds, tracePoint.Value); DC.Pop(); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (image != null) { var container = new Rect ( this.Padding.Left, this.Padding.Top, this.ActualWidth - this.Padding.Right - this.Padding.Left, this.ActualHeight - this.Padding.Bottom - this.Padding.Top ); var horizontal = image.Width > image.Height; var sz = new Size ( horizontal ? container.Height / (image.Height / image.Width) : container.Width, horizontal ? container.Height : container.Width / (image.Width / image.Height) ); var rect = new Rect ( container.Left + container.Width / 2 - sz.Width / 2, container.Top + container.Height / 2 - sz.Height / 2, sz.Width, sz.Height ); drawingContext.PushClip(new RectangleGeometry(container)); drawingContext.DrawImage(image, rect); drawingContext.Pop(); } }
/// <summary> /// Draw highlight /// </summary> override protected void OnRender(DrawingContext dc) { #if DEBUG DocumentsTrace.FixedTextOM.Highlight.Trace(string.Format("HightlightVisual Rendering")); #endif if (_panel.Highlights.ContainsKey(_page)) { ArrayList highlights = _panel.Highlights[_page]; Size pageSize = _panel.ComputePageSize(_page); Rect clipRect = new Rect(new Point(0, 0), pageSize); dc.PushClip(new RectangleGeometry(clipRect)); if (highlights != null) { _UpdateHighlightBackground(dc, highlights); _UpdateHighlightForeground(dc, highlights); } dc.Pop(); //clip } if (_rubberbandSelector != null && _rubberbandSelector.Page == _page) { Rect r = _rubberbandSelector.SelectionRect; if (!r.IsEmpty) { dc.DrawRectangle(SelectionHighlightInfo.ObjectMaskBrush, null, r); } } }
private void _UpdateHighlightForeground(DrawingContext dc, ArrayList highlights) { foreach (FixedHighlight fh in highlights) { Brush fg = null; if (fh.HighlightType == FixedHighlightType.None) { #if NEVER // use this code if you want to see unrecognized highlights bg = Brushes.Yellow; #else continue; #endif } Glyphs g = fh.Glyphs; if (g == null) { continue; } Rect clipRect = fh.ComputeDesignRect(); if (clipRect == Rect.Empty) { continue; } GeneralTransform transform = fh.Element.TransformToAncestor(_page); Transform t = transform.AffineTransform; if (t != null) { dc.PushTransform(t); } else { dc.PushTransform(Transform.Identity); } dc.PushClip(new RectangleGeometry(clipRect)); if (fh.HighlightType == FixedHighlightType.TextSelection) { fg = SelectionHighlightInfo.ForegroundBrush; } else if (fh.HighlightType == FixedHighlightType.AnnotationHighlight) { fg = fh.ForegroundBrush; } // can add cases for new types of highlights GlyphRun gr = g.ToGlyphRun(); if (fg == null) { fg = g.Fill; } dc.PushGuidelineY1(gr.BaselineOrigin.Y); dc.PushClip(g.Clip); dc.DrawGlyphRun(fg, gr); dc.Pop(); // Glyphs clip dc.Pop(); // Guideline dc.Pop(); // clip dc.Pop(); // transform } }
protected virtual void CreatePageVisual(Rect pageBounds, DrawingVisual source, bool isFooterPage, DrawingContext drawingContext) { drawingContext.DrawRectangle(null, FramePen, new Rect { X = FrameRect.X, Y = FrameRect.Y, Width = FrameRect.Width, Height = FrameRect.Height }); var offsetX = PageMargins.Left - pageBounds.X - 1; var offsetY = PageMargins.Top - pageBounds.Y; drawingContext.PushTransform(new TranslateTransform(offsetX, offsetY + HeaderHeight)); var pg = new Rect(new Point(pageBounds.X, pageBounds.Y), new Size(pageBounds.Width, pageBounds.Height)); drawingContext.PushClip(new RectangleGeometry(pg)); //drawingContext.PushOpacityMask(Brushes.White); drawingContext.DrawDrawing(source.Drawing); }
/// <summary> /// Draw glyphrun /// </summary> /// <param name="drawingContext">The drawing context to draw into </param> /// <param name="foregroundBrush"> /// The foreground brush of the glyphrun. Pass in "null" to draw the /// glyph run with the foreground in TextRunProperties. /// </param> /// <param name="glyphRun">The GlyphRun to be drawn </param> /// <returns>bounding rectangle of drawn glyphrun</returns> /// <Remarks> /// TextEffect drawing code may use a different foreground brush for the text. /// </Remarks> internal Rect DrawGlyphRun( DrawingContext drawingContext, Brush foregroundBrush, GlyphRun glyphRun ) { Debug.Assert(_shapeable != null); Rect inkBoundingBox = glyphRun.ComputeInkBoundingBox(); if (!inkBoundingBox.IsEmpty) { // glyph run's ink bounding box is relative to its origin inkBoundingBox.X += glyphRun.BaselineOrigin.X; inkBoundingBox.Y += glyphRun.BaselineOrigin.Y; } if (drawingContext != null) { int pushCount = 0; // the number of push we do try { if (_textEffects != null) { // we need to push in the same order as they are set for (int i = 0; i < _textEffects.Count; i++) { // get the text effect by its index TextEffect textEffect = _textEffects[i]; if (textEffect.Transform != null && textEffect.Transform != Transform.Identity) { drawingContext.PushTransform(textEffect.Transform); pushCount++; } if (textEffect.Clip != null) { drawingContext.PushClip(textEffect.Clip); pushCount++; } if (textEffect.Foreground != null) { // remember the out-most non-null brush // this brush will be used to draw the glyph run foregroundBrush = textEffect.Foreground; } } } _shapeable.Draw(drawingContext, foregroundBrush, glyphRun); } finally { for (int i = 0; i < pushCount; i++) { drawingContext.Pop(); } } } return inkBoundingBox; }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { if (group == null) { return; } Rect area = new Rect(0, 0, AdornedElement.RenderSize.Width, AdornedElement.RenderSize.Height); drawingContext.PushClip(new RectangleGeometry(area)); drawingContext.DrawRectangle(Brushes.White, null, area); var threads = group.Threads; int rowIndex = 0; KeyValuePair <int, int> mainThreadInterval = new KeyValuePair <int, int>(); for (int threadIndex = 0; threadIndex < threads.Count; ++threadIndex) { List <EventFrame> frames = threads[threadIndex].Events; RowRange rowRange = rows[threadIndex]; if (rowRange.MaxDepth > 0 && frames.Count > 0) { KeyValuePair <int, int> interval = CalculateEventRange(frames, Position, Position + Range); if (threadIndex == group.Board.MainThreadIndex) { mainThreadInterval = interval; } Brush backgroundBrush = Brushes.White; if (rowIndex++ % 2 == 0) { backgroundBrush = AlternativeBackgroundColor; drawingContext.DrawRectangle(AlternativeBackgroundColor, null, new Rect(0, rowRange.Offset, AdornedElement.RenderSize.Width, rowRange.Height)); } for (int i = interval.Key; i <= interval.Value; ++i) { OnRenderFrame(drawingContext, frames[i], rowRange.Offset, rowRange.MaxDepth, backgroundBrush); } } } int mainThreadIndex = group.Board.MainThreadIndex; RenderFPSLines(drawingContext, group.Threads[mainThreadIndex].Events, mainThreadInterval); if (FocusedFrame != null) { RowRange rowRange = rows[FocusedFrame.Header.ThreadIndex]; Durable interval = FocusedNode != null ? FocusedNode.Entry as Durable : FocusedFrame.Header as Durable; Rect focusedRectangle = CalculateRect(interval, rowRange.Offset, rowRange.Height); drawingContext.DrawRectangle(null, selectedPen, focusedRectangle); } RenderSelectedScopes(drawingContext); drawingContext.Pop(); base.OnRender(drawingContext); }
protected override void OnRender(DrawingContext drawingContext) { drawingContext.PushClip(GetLayoutClip(m_clipSize)); Rect rect = new Rect(new Point(0,0), m_clipSize); drawingContext.DrawRectangle(Brushes.Transparent, null, rect); int index = ((int) (ScrollValue/m_itemHeight)); Point position = new Point(5,5); while (position.Y < m_clipSize.Height && index < m_list.Count) { if (SelectedIndex == index) { SolidColorBrush mySolidColorBrush = new SolidColorBrush { Color = Color.FromArgb(0xFF, 0x00, 0x80, 0xC0) }; Rect myRect = new Rect(new Point(position.X - 3, position.Y) , new Size(Width - 4, m_itemHeight)); drawingContext.DrawRectangle(mySolidColorBrush, null, myRect); } ItemRender.Render(drawingContext, position, m_list[index]); position.Offset(0, m_itemHeight); index++; } drawingContext.Pop(); }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { //base.OnRender(drawingContext); if (this.Text != "") { FormattedText formattedText = null; double leftMargin = 4.0 + this.BorderThickness.Left; double topMargin = 2 + this.BorderThickness.Top; if (IsAllowFormatSqlContent) { #region MyRendering EnsureScrolling(); formattedText = new FormattedText( this.Text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface(this.FontFamily.Source), this.FontSize, BaseForeground); //Text that matches the textbox's formattedText.MaxTextWidth = this.ViewportWidth; // space for scrollbar formattedText.MaxTextHeight = Math.Max(this.ActualHeight + this.VerticalOffset, 0); //Adjust for scrolling drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, this.ActualWidth, this.ActualHeight))); //restrict text to textbox //Background hilight foreach (Decoration dec in mDecorations) { if (dec.DecorationType == EDecorationType.Hilight) { List <Pair> ranges = dec.Ranges(this.Text); foreach (Pair p in ranges) { Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length); if (geom != null) { #if DEBUG Debug.WriteLine("Draw geometry"); #endif drawingContext.DrawGeometry(dec.Brush, null, geom); } } } } //Underline foreach (Decoration dec in mDecorations) { if (dec.DecorationType == EDecorationType.Underline) { List <Pair> ranges = dec.Ranges(this.Text); foreach (Pair p in ranges) { Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length); if (geom != null) { StackedRectangleGeometryHelper srgh = new StackedRectangleGeometryHelper(geom); foreach (Geometry g in srgh.BottomEdgeRectangleGeometries()) { #if DEBUG Debug.WriteLine("Draw geometry2"); #endif drawingContext.DrawGeometry(dec.Brush, null, g); } } } } } //Strikethrough foreach (Decoration dec in mDecorations) { if (dec.DecorationType == EDecorationType.Strikethrough) { List <Pair> ranges = dec.Ranges(this.Text); foreach (Pair p in ranges) { Geometry geom = formattedText.BuildHighlightGeometry(new Point(leftMargin, topMargin - this.VerticalOffset), p.Start, p.Length); if (geom != null) { StackedRectangleGeometryHelper srgh = new StackedRectangleGeometryHelper(geom); foreach (Geometry g in srgh.CenterLineRectangleGeometries()) { #if DEBUG Debug.WriteLine("Draw geometry3"); #endif drawingContext.DrawGeometry(dec.Brush, null, g); } } } } } #region TextColor foreach (Decoration dec in mDecorations) { if (dec.DecorationType == EDecorationType.TextColor) { List <Pair> ranges = dec.Ranges(this.Text); foreach (Pair p in ranges) { #if DEBUG Debug.WriteLine("Set background brush" + p.Start.ToString()); #endif //this method will paint the text ,it will cost many ,many times, //if the sql script large enough (more than 100k) //So I'd rather use simplest textbox with no formatted sql text replace this control. formattedText.SetForegroundBrush(dec.Brush, p.Start, p.Length); } } } #endregion #if DEBUG Debug.WriteLine("End drawing"); #endif #endregion } if (formattedText == null) { this.Foreground = new SolidColorBrush(Colors.Black); } drawingContext.DrawText(formattedText, new Point(leftMargin, topMargin - this.VerticalOffset)); } }
protected override void OnRender(DrawingContext drawingContext) { double rowHeight; double curY; double curX; // Draw ColumnHeaders and CornerBox RectangleGeometry completeDrawGeo = new RectangleGeometry(new Rect(0, 0, ActualWidth, ActualHeight)); drawingContext.PushClip(completeDrawGeo); DrawColumnHeaders(drawingContext); DrawCornerBox(drawingContext); drawingContext.Pop(); // If needed, draw SelectionButtons if (RowSelectionButtonWidth > 0) { RectangleGeometry rowSelectionButtonGeo = new RectangleGeometry(new Rect(0, ColumnHeaderHeight, ActualWidth, ActualHeight - ColumnHeaderHeight)); drawingContext.PushClip(rowSelectionButtonGeo); curY = ColumnHeaderHeight + 1 - scrollYOffset; for (int rowIdx = 0; rowIdx < RowList.Count; rowIdx++) { rowHeight = OnGetRowHeight(rowIdx); DrawRowSelectionButton(drawingContext, rowIdx, new Rect(0, curY, RowSelectionButtonWidth, rowHeight)); curY += rowHeight + 1; } drawingContext.Pop(); } // Draw rows (with cells) RectangleGeometry completeDataGeo = new RectangleGeometry(new Rect(RowSelectionButtonWidth+1, ColumnHeaderHeight+1, ActualWidth - RowSelectionButtonWidth, ActualHeight - ColumnHeaderHeight)); drawingContext.PushClip(completeDataGeo); curY = ColumnHeaderHeight + 1 - scrollYOffset; for (int rowIdx = 0; rowIdx < RowList.Count; rowIdx++) { curX = RowSelectionButtonWidth + 1 - scrollXOffset; rowHeight = OnGetRowHeight(rowIdx); // Draw Cells for (int colIdx = 0; colIdx < ColumnList.Count; colIdx++) { Column column = ColumnList[colIdx]; Rect cellRect = new Rect(curX, curY, column.Width, rowHeight); DrawCell(drawingContext, null, colIdx, rowIdx, cellRect); curX += column.Width + 1; } curY += rowHeight + 1; } drawingContext.Pop(); base.OnRender(drawingContext); }
protected override void OnRender(System.Windows.Media.DrawingContext dcRendering) { if (m_bSuspendRendering) { return; } while (m_bPauseOutput) { Thread.Sleep(250); } if (this.Text.Length > 0) { int iStartVisibleLine = -1; int iEndVisibleLine = -1; int iOffset = -1; int iOffsetNext = -1; string strLine = ""; EnsureScrolling(); FormattedText ftDisplayedLines = new FormattedText( this.Text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface(this.FontFamily.Source), this.FontSize, BaseForeground); // Text that matches the textbox's double dLeftMargin = 4.0 + this.BorderThickness.Left; double dTopMargin = 2.0 + this.BorderThickness.Top; double dRightMargin = this.ActualWidth - 5.0; // Fix to long lines writing over right edge when horizontal scrollbar is preset ftDisplayedLines.MaxTextHeight = Math.Max(this.ActualHeight + this.VerticalOffset, 0); // Adjust for scrolling dcRendering.PushClip(new RectangleGeometry(new Rect(dLeftMargin, dTopMargin, dRightMargin, this.ActualHeight))); // Restrict text to textbox #region Text Coloring and Shading ftDisplayedLines.SetForegroundBrush(m_brBlack); // Default text color for any text not colored by offset / length if (m_eSyntaxColoringMode == SyntaxColoringMode.Dasm) #region DASM Output { #region Comments // Label: 0 Orange // Instruction Address: 14 Red // Mnemonic: 20 Blue // Data Address: 43 Purple // Annotation: 51 Date green // Data1 26 / 25 // Data2 52 // Data3 62 / 4 // Data4 75 // 1 2 3 4 5 6 7 8 9 0 1 // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 // Loop_02_0A0F 0A0F: SIO F3 10 28 5475 Keyboard Set Error Indicator Restore Data Key // 0A12: SNS 70 12 FF,1 0x0B0C 5475 Keyboard 2 sense bytes // 0A20: data F1 6B F1 F2 6B F1 F3 40 <.k.. k..@> <1,12 ,13 > // Background for breakpoints (R:253 G:207 B:207) #FDCFCF // Background for disabled breakpoints (R:248 G:226 B:226) #F8E2E2 // Background for active bookmark (R:0 G:198 B:255) #00C6FF // Background for disabled bookmark (R:0 G:239 B:255) #00EFFF // Background for current active line (R:236 G:254 B:85) #ECFE55 // Mnemonics: blue (R:0 G:0 B:255) #0000FF // Operand addresses & command codes: black (R:0 G:0 B:0) #000000 // Instruction addresses & command codes: dark red (R:128 G:0 B:0) #800000 // Annotation: dark green (R:0 G:128 B:0) (same as comments in Visual Studio) #008000 // Register labels: purple (R:139 G:0 B:164) #8B00A4 // Register values: light purple (R:212 G:0 B:250) #D400FA // Changed register values: red (R:255 G:0 B:0) #FF0000 // Operand labels: purple (R:139 G:0 B:164) #8B00A4 // Operand memory: magenta (R:255 G:0 B:255) #FF00FF // Changed memory: red (R:255 G:0 B:0) #FF0000 // Reset condition register flags: gray (R:128 G:128 B:128) #808080 #endregion iStartVisibleLine = GetFirstVisibleLineIndex(); iEndVisibleLine = GetLastVisibleLineIndex(); for (int iIdx = iStartVisibleLine; iIdx <= iEndVisibleLine; ++iIdx) { try { // Text coloring try { iOffset = GetCharacterIndexFromLineIndex(iIdx); iOffsetNext = GetCharacterIndexFromLineIndex(iIdx + 1); } catch (ArgumentOutOfRangeException) { // Fail silently } strLine = Text.Substring(iOffset, iOffsetNext - iOffset); if (strLine.Length >= 101 && IsHexColon(strLine.Substring(0, 5)) && strLine[58] == '<') { // 1 2 3 4 5 6 7 8 9 0 1 2 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //0300: 7C 00 52 75 02 CE 71 F5 CE F3 F9 07 D1 F9 0C 6D <|.Ru ..q. .... ...m> <@... ...5 .39. J9._> ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 5); // Data address ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 6, 50); // Hex data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 58, 1); // Lead Op1 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 59, 42); // Op1 hex ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 78, 4); // Middle Op1 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1); // Trail Op1 angle bracket } //else if (strLine.Length >= 75 && // strLine.Substring (0, 4) == "XOXO") //{ // ftDisplayedLines.SetForegroundBrush (m_brPurple, iOffset, 9); // ftDisplayedLines.SetForegroundBrush (m_brFuchsia, iOffset + 18, 9); // ftDisplayedLines.SetForegroundBrush (m_brDkGreen, iOffset + 45, 9); // ftDisplayedLines.SetForegroundBrush (m_brCoral, iOffset + 63, 5); //} else if (strLine.Length >= 5 && IsHexColon(strLine.Substring(14, 5))) { ftDisplayedLines.SetForegroundBrush(m_brBlack, iOffset, strLine.Length); // Background text ftDisplayedLines.SetForegroundBrush(m_brRoyalBlue, iOffset, 12); // Loop / Jump label ftDisplayedLines.SetForegroundBrush(m_brCoral, iOffset + 14, 5); // Hex address string strTest1 = strLine.Substring(14, 5); // Hex/Colon test string strTest2 = strLine.Substring(20, 4); // "data" label test if (strTest2 == "data") { // 1 2 3 4 5 6 7 8 9 0 1 2 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 002E: data 7C 3C 40 40 40 40 40 40 <|<@@ @@@@> <@. > <EF__ ____> <H.'' ''''> // 001E: data 01 00 6F 03 76 57 1B 5D <..o. vW.]> <..?. ...)> <..01 2345> <.... ....> ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 26, 25); // Hex data string ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 52, 1); // Lead data angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 53, 48); // Hex, ascii, HPL & 5475 data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 62, 4); // First pair angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 75, 4); // Second pair angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 88, 4); // Third pair angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1); // Trail data angle bracket } else// if (IsHexColon (strTest1)) { ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 20, 5); // Mnemonic if (strLine.Length >= 26) { ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 26, Math.Min(strLine.Length, 15)); // Instruction code } if (strLine.Length >= 49) { ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 43, 6); // Data address } if (strLine.Length >= 51) { ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 51, strLine.Length - 51); // Annotation } } } else if (strLine.Length >= 52 && IsBlank(strLine.Substring(0, 51))) { ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 51, strLine.Length - 51); // Annotation } iOffset = GetCharacterIndexFromLineIndex(iIdx); #region Test code for breakpoint and bookmark buttons ////drawingContext.PushClip (new RectangleGeometry (new Rect (0, 0, leftMargin, topMargin))); // Restrict text to textbox //double dLeft = leftMargin - this.HorizontalOffset - 13; //double dTop = topMargin + (iIdx * 13.55) + 7 - this.VerticalOffset; ////Console.WriteLine ("Left: {0:###.#} Top: {1:###.#}", dLeft, dTop); //if (iIdx % 3 == 0) //{ // drawingContext.DrawEllipse (new SolidColorBrush (Colors.Red), null, // new Point (dLeft, dTop), 5, 5); //} //else if (iIdx % 3 == 1) //{ // drawingContext.DrawEllipse (new SolidColorBrush (Colors.Transparent), new Pen (new SolidColorBrush (Colors.Red), 1.0), // new Point (dLeft, dTop), 5, 5); //} //if (iIdx % 4 == 0) //{ // drawingContext.DrawRectangle (new SolidColorBrush (Colors.Blue), null, new Rect (new Point (3, dTop), // new Point (dLeft + 5, dTop + 7))); //} //else if (iIdx % 4 == 1) //{ // drawingContext.DrawRectangle (new SolidColorBrush (Colors.Transparent), new Pen (new SolidColorBrush (Colors.Blue), 1.0), // new Rect (new Point (3, dTop), // new Point (dLeft + 5, dTop + 7))); //} ////drawingContext.PushClip (new RectangleGeometry (new Rect (leftMargin, topMargin, this.ActualWidth, this.ActualHeight))); // Restrict text to textbox #endregion #region Highlighting //0 1 //01234567890123456789 //Entry_0000 0000: if (m_bEnableHighlightLine) { if (iIdx == m_iCurrentLineIdx) { Geometry geomCurrentLine = ftDisplayedLines.BuildHighlightGeometry(new Point(dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 14, strLine.Length - 14); if (geomCurrentLine != null) { dcRendering.DrawGeometry(m_brYellow, null, geomCurrentLine); } } else if (m_liGrayedCode.Contains(iIdx) && strLine.Substring(20, 4) != "data" && strLine.Substring(0, 5) != "Entry") { Geometry geomCurrentLine = ftDisplayedLines.BuildHighlightGeometry(new Point(dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 14, 5); if (geomCurrentLine != null) { dcRendering.DrawGeometry(m_brLtGray, null, geomCurrentLine); } } } #region Old highlighting for breakpoints and bookmarks //if (iIdx == 0) //{ // // TODO: Replace magic numbers with variable // Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 12, 2); // if (geom != null) // { // dcRendering.DrawGeometry (m_brBrkPt, null, geom); // } //} //else if (iIdx == 2) //{ // // TODO: Replace magic numbers with variable // Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 12, 2); // if (geom != null) // { // dcRendering.DrawGeometry (m_brDisBrkPt, null, geom); // } ////} ////else if (iIdx == 2) ////{ // // TODO: Replace magic numbers with variable // geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset, 4); // if (geom != null) // { // dcRendering.DrawGeometry (m_brBkMrk, null, geom); // } // //geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 4, 4); // //if (geom != null) // //{ // // dcRendering.DrawGeometry (m_brBkMrk, null, geom); // //} //} //else if (iIdx == 3) //{ // // TODO: Replace magic numbers with variable // Geometry geom = ftDisplayedLines.BuildHighlightGeometry (new Point (dLeftMargin, dTopMargin - this.VerticalOffset), iOffset + 26, 11); // if (geom != null) // { // dcRendering.DrawGeometry (m_brDisBkMrk, null, geom); // } //} #endregion #endregion } catch (ArgumentOutOfRangeException) { if (strLine.Length > 0) { Console.WriteLine("ArgumentOutOfRangeException: [" + iIdx.ToString() + "] " + strLine); } // Fail silently } } } #endregion else if (m_eSyntaxColoringMode == SyntaxColoringMode.Trace) #region Trace Output { iStartVisibleLine = GetFirstVisibleLineIndex(); iEndVisibleLine = GetLastVisibleLineIndex(); for (int iIdx = iStartVisibleLine; iIdx <= iEndVisibleLine - 1; ++iIdx) { try { try { iOffset = GetCharacterIndexFromLineIndex(iIdx); iOffsetNext = GetCharacterIndexFromLineIndex(iIdx + 1); } catch (ArgumentOutOfRangeException) { // Fail silently } strLine = Text.Substring(iOffset, iOffsetNext - iOffset); if (strLine.Length >= 15 && strLine.Substring(0, 5) == "Step:") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //Step: 1, Timing: 608 608.00µs (6 08) ftDisplayedLines.SetForegroundBrush(m_brTeal, iOffset, 14); // Step Count ftDisplayedLines.SetForegroundBrush(m_brRoyalBlue, iOffset + 15, strLine.Length - 15); // Timing } else if (strLine.Length >= 22 && strLine.Substring(0, 3) == "IL:") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //IL: M LA C2 01 0000 0x0000 XR1 ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length); // Default for string ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 6, 5); // Mnemonic ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 12, 15); // Instruction code } else if (strLine.Length >= 20 && strLine.Substring(0, 20) == " 1 2") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 1 2 3 4 5 6 7 8 9 ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length); } else if (strLine.Length >= 20 && strLine.Substring(0, 20) == "12345678901234567890") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length); } else if (strLine.Length >= 126 && IsHexColon(strLine.Substring(25, 5)) && strLine[83] == '<') { // 1 2 3 4 5 6 7 8 9 0 1 2 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // 0080: 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 <@@@@ @@@@ @@@@ @@@@> < > ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, 24); ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 25, 5); // Data address ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 31, 50); // Hex data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 83, 1); // Lead Op1 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 84, 42); // Op1 hex ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 103, 4); // Middle Op1 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 126, 1); // Trail Op1 angle bracket } else if (strLine.Length >= 9 && strLine.Substring(0, 9) == " >>> ") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // >>> MFCU Read Buffer (0x0000): ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length); } else if (strLine.Length >= 17 && strLine.Substring(0, 17) == " MFCU ") { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 // MFCU Read DAR after LIO: 0x0000 ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset, strLine.Length); } else if (strLine.Length >= 106 && IsHexColon(strLine.Substring(5, 5)) && strLine[63] == '<') { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //Op2: 0020: 71 F5 FF F3 F1 40 F1 F1 00 D0 00 00 <q... .@.. .... > <.5.3 1 11 .}.. > ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 4); // "Op1:" label ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 5, 57); // Hex data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 63, 1); // Lead Op1 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 64, 42); // Op1 hex ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 83, 4); // Middle Op1 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 106, 1); // Trail Op1 angle bracket } else if (strLine.Length >= 102 && IsHexColon(strLine.Substring(0, 5)) && strLine[58] == '<') { // 1 2 3 4 5 6 7 8 9 0 //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //0000: 5C 09 71 14 5C 14 86 34 D0 00 F4 5F 88 F2 04 03 <\\.q. \\..4 ..._ ....> <*... *.f. }.4^ h2..> ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 5); // Hex data address ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 6, 51); // Hex data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 58, 1); // Lead Op1 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 59, 42); // Op1 hex ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 78, 4); // Middle Op1 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 101, 1); // Trail Op1 angle bracket } else if (strLine.Length >= 61 && strLine.Substring(0, 4) == "Op1:") { // 1 2 3 4 5 6 7 8 9 0 1 2 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //Op1: 0060: 00 00 00 00 00 00 00 00 <.... ....> <.... ....> Op2: 002C: F0 7C 6C D0 87 60 57 20 <.|l. .`W > <0@%} g-..> ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset, 4); // "Op1:" label ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 5, 31); // Hex data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 37, 1); // Lead Op1 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 38, 22); // Op1 hex ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 47, 4); // Middle Op1 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 60, 1); // Trail Op1 angle bracket if (strLine.Contains("Op2:")) { ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 63, 4); // "Op2:" label ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 100, 1); // Lead Op2 angle bracket ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 68, 31); // Op2 hex data values ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 101, 22); // Op2 ascii data values ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 110, 4); // Middle Op2 angle brackets ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 123, 1); // Trail Op2 angle bracket } } else if (strLine.Length >= 118 && IsHexColon(strLine.Substring(0, 5)) && strLine.Substring(43, 4) == "IAR:") { // 1 2 3 4 5 6 7 8 9 0 1 2 //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 //0000: LA C2 01 0000 00 00 IAR: 0004 XR1: 0000 XR2: 0000 ARR: 0000 CR: EQ Timing: 6.08µs //00D5: A 76 02 FA,1 00 FA IAR: 00D8 XR1: 0000 XR2: 0053 ARR: 00A6 CR: HI BO XR2: 0x0057 --> 0x0053 ftDisplayedLines.SetForegroundBrush(m_brCoral, iOffset, 5); // Instruction address ftDisplayedLines.SetForegroundBrush(m_brMedSeaGrn, iOffset + 6, 5); // Mnemonic ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 12, 15); // Instruction code ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 29, 13); // Annotation ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 43, 4); // IAR label ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 48, 55); // Register values ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 54, 4); // XR1 label ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 65, 4); // XR2 label ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 76, 4); // ARR label ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 87, 3); // CR label if (strLine.Substring(105, 8) == "Timing: ") { ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 105, 15); // Timing } else { ftDisplayedLines.SetForegroundBrush(m_brPurple, iOffset + 103, 4); // Register label ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 108, 6); // Old register value ftDisplayedLines.SetForegroundBrush(m_brDkGreen, iOffset + 115, 3); // "-->" ftDisplayedLines.SetForegroundBrush(m_brFuchsia, iOffset + 119, 6); // New register value } } else if (strLine.Length >= 7 && strLine.Substring(0, 7) == "- - - -") { ftDisplayedLines.SetForegroundBrush(m_brFirebrick, iOffset, strLine.Length); } } catch (ArgumentOutOfRangeException) { //Console.WriteLine ("ArgumentOutOfRangeException: [" + iIdx.ToString () + "] " + strLine); // Fail silently } } } #endregion // Trace Output dcRendering.DrawText(ftDisplayedLines, new Point(dLeftMargin - this.HorizontalOffset, dTopMargin - this.VerticalOffset)); #endregion // Text Coloring and Shading } }