public void DrawLine(IEnumerable<Point> points, Color stroke, double thickness, double[] dashArray, bool aliased) { var pl = new Polyline(); if (stroke != null) pl.Stroke = new SolidColorBrush(stroke.ToColor()); pl.StrokeLineJoin = PenLineJoin.Miter; foreach (var p in points) pl.Points.Add(ToPoint(p)); pl.StrokeThickness = thickness; pl.Fill = null; if (dashArray != null) pl.StrokeDashArray = new DoubleCollection(dashArray); if (aliased) pl.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased); canvas.Children.Add(pl); }
public void DrawLine(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, OxyPenLineJoin lineJoin, bool aliased) { var e = new Polyline(); if (stroke != null && thickness > 0) { e.Stroke = GetCachedBrush(stroke); switch (lineJoin) { case OxyPenLineJoin.Round: e.StrokeLineJoin = PenLineJoin.Round; break; case OxyPenLineJoin.Bevel: e.StrokeLineJoin = PenLineJoin.Bevel; break; // The default StrokeLineJoin is Miter } if (thickness != 1) // default values is 1 e.StrokeThickness = thickness; if (dashArray != null) e.StrokeDashArray = new DoubleCollection(dashArray); } // pl.Fill = null; if (aliased) e.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased); var pc = new PointCollection(points.Count); foreach (var p in points) pc.Add(ToPoint(p)); e.Points = pc; Add(e); }
/// <summary> /// 刷新背景网格线,显示曲线 /// </summary> public void ShowCurve() { //绘制曲线 //判断数组中是否有两个以上的数值 //绘制直线 if (this.noteNow > 1) { PointCollection pc = new PointCollection(); //int pointI = 0; for (int i = 0; i <= this.noteNow - 1; i++) { if (this.noteMessages[i].X >= this.coordinate) { Point p = new Point(this.noteMessages[i].X, this.noteMessages[i].Y); pc.Add(p); //pointI++; } } Polyline pl = new Polyline(); pl.Stroke = new SolidColorBrush(Colors.Yellow); pl.StrokeThickness = 2; pl.Points = pc; if (this.ScreenElement != null) { if (this.ScreenElement.ElementID != 0) { pl.Name = "ShowLinePolyline" + this.ScreenElement.ElementID; var v = picCurveShow.FindName("ShowLinePolyline" + this.ScreenElement.ElementID); picCurveShow.Children.Remove((Polyline)v); } } else { pl.Name = _ReGuid; var v = picCurveShow.FindName(_ReGuid); picCurveShow.Children.Remove((Polyline)v); } pl.SetValue(Canvas.ZIndexProperty, 999); picCurveShow.Children.Add(pl); } labShowTime.Text = DateTime.Now.ToString("hh:mm:ss"); }