public Path CreateLineForMinSpanningTreeEdge(DelaunayEdge edge) { if (this.minimumSpanningTreePaths == null) { this.minimumSpanningTreePaths = new Dictionary<DelaunayEdge, Path>(); } if (!this.minimumSpanningTreePaths.ContainsKey(edge)) { LineGeometry geometry = new LineGeometry(new Point(edge.Start.X, edge.Start.Y), new Point(edge.End.X, edge.End.Y)); geometry.Freeze(); Path path = new Path(); path.Data = geometry; path.StrokeThickness = MinimumSpanningTreeTickness; path.Stroke = new SolidColorBrush(Color.FromArgb(120, minimumSpanningTreeEdgeColor.A, minimumSpanningTreeEdgeColor.G, minimumSpanningTreeEdgeColor.B)); this.minimumSpanningTreePaths[edge] = path; } return this.minimumSpanningTreePaths[edge]; }
public Path CreateEdgeLine(DelaunayEdge edge) { if (this.edgesPaths == null) { this.edgesPaths = new Dictionary<DelaunayEdge, Path>(); } if (!this.edgesPaths.ContainsKey(edge)) { LineGeometry geometry = new LineGeometry(new Point(edge.Start.X, edge.Start.Y), new Point(edge.End.X, edge.End.Y)); geometry.Freeze(); Path path = new Path(); path.Data = geometry; path.StrokeThickness = EdgeTickness; path.Stroke = new SolidColorBrush(EdgeColor); this.edgesPaths[edge] = path; } return this.edgesPaths[edge]; }
void CreateVisuals(ITextViewLine line) { var text = view.TextSnapshot.GetText(line.Start, line.Length); if (hasUsing == false) UpdateUsing(text); var regex = hasUsing == true ? usingColorRegex : colorRegex; var matches = regex.Matches(text); foreach (Match match in matches) { var mode = match.Groups["mode"].Value; Func<Match, Eto.Drawing.Color> translateColor; if (!colorMatching.TryGetValue(mode, out translateColor)) continue; var color = translateColor(match).ToWpf(); if (color.A <= 0) continue; var span = new SnapshotSpan(view.TextSnapshot, line.Start + match.Index, match.Length); var geometry = view.TextViewLines.GetMarkerGeometry(span); if (geometry == null || !view.TextViewModel.IsPointInVisualBuffer(span.Start, PositionAffinity.Successor) || !view.TextViewModel.IsPointInVisualBuffer(span.End, PositionAffinity.Predecessor)) continue; var pen = GetPen(color); var bounds = geometry.Bounds; var underline = new LineGeometry(bounds.BottomLeft, bounds.BottomRight); underline.Freeze(); var drawing = new GeometryDrawing(null, pen, underline); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image(); image.Source = drawingImage; Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Bottom - 2); layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } }