画边框线条,有些问题...... [英] Draw lines with border, some problems ...
本文介绍了画边框线条,有些问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我正在尝试绘制WPF Canvas,一些带边框的折线。
为此,我使用了StreamGeometry,一个PathGeometry和一个路径。
这是我的代码:
Hello,
I'm trying to draw in a WPF Canvas, some polylines with border.
For that purpose i've used a StreamGeometry, a PathGeometry and a "Path".
This is my code:
StreamGeometry geom = new StreamGeometry();
//this method fills the StreamGeometry with a polyline
DrawLines(geom, polyObj);
PathGeometry pathGeometry = geom.GetWidenedPathGeometry(new Pen(Brushes.Black, 10));
GeometryDrawing geoDrawing = new GeometryDrawing();
geoDrawing.Geometry = pathGeometry;
Path myPath = new Path();
myPath.Fill = Brushes.LightGreen;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 0.4;
myPath.Name = "tratta"+tratta.id;
myPath.Data = pathGeometry;
myPath.StrokeLineJoin = System.Windows.Media.PenLineJoin.Round;
canvas.Children.Add(myPath);
代码正常工作,但是当折线有两个以上的顶点时,我在结点上获得了这个图形问题:
图片 - 交汇点
如何解决这个问题?在此先感谢
The code is working, but when a polyline has more than two vertex, i obtain this graphic problems on a junction:
Image - Junction
How can i resolve this problems? Thanks in advance
推荐答案
canvasGeomentry.Child.Add(new Polyline())
{
Points=new PointCollection(new List(point))
{
new Point (x1,y1), new Point(x2,y2);
}
}
这篇关于画边框线条,有些问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文