public void DrawingGraphics(Geometry positiveGroup, Geometry negativeGroup, bool IsDrawingLine, double CustomDrawLineWidth, DoubleCollection guidlinesX, DoubleCollection guidlinesY) { positiveGroup.Freeze(); negativeGroup.Freeze(); DrawingVisual drawingVisual = new DrawingVisual(); RedBrush.Freeze(); GreenBrush.Freeze(); Pen RedPen = new Pen(RedBrush, CustomDrawLineWidth); Pen GreenPen = new Pen(GreenBrush, CustomDrawLineWidth); RedPen.Freeze(); GreenPen.Freeze(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.PushGuidelineSet(new GuidelineSet(guidlinesX.ToArray(), guidlinesY.ToArray())); if (IsDrawingLine) { drawingContext.DrawGeometry(null, RedPen, positiveGroup); drawingContext.DrawGeometry(null, GreenPen, negativeGroup); } else { Brush white = Brushes.White; white.Freeze(); drawingContext.DrawGeometry(white, RedPen, positiveGroup); drawingContext.DrawGeometry(GreenBrush, GreenPen, negativeGroup); } drawingContext.Pop(); drawingContext.Close(); BitmapCache bc = new BitmapCache(); bc.SnapsToDevicePixels = true; bc.Freeze(); drawingVisual.CacheMode = bc; this.AddVisualChild(drawingVisual); }
/// <summary> /// 画折线 /// </summary> /// <param name="LineGroup"></param> /// <param name="CustomDrawLineWidth"></param> public void DrawingGraphics(Geometry LineGroup, double CustomDrawLineWidth) { LineGroup.Freeze(); DrawingVisual drawingVisual = new DrawingVisual(); RedBrush.Freeze(); GreenBrush.Freeze(); Pen RedPen = new Pen(RedBrush, CustomDrawLineWidth); Pen GreenPen = new Pen(GreenBrush, CustomDrawLineWidth); RedPen.Freeze(); GreenPen.Freeze(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawGeometry(null, RedPen, LineGroup); drawingContext.Close(); BitmapCache bc = new BitmapCache(); bc.SnapsToDevicePixels = true; bc.Freeze(); drawingVisual.CacheMode = bc; this.AddVisualChild(drawingVisual); }