public ShapeBulder GetShapBilder(ShapeBuilderType type) { ShapeBulder builder = null; switch (type) { case ShapeBuilderType.Rectangle: builder = RectangleShapBuilder; break; case ShapeBuilderType.ArrowLine: builder = ArrowLineShapBuilder; break; case ShapeBuilderType.StartEllipse: builder = StartEllipseShapeBuilder; break; case ShapeBuilderType.RangeEllipse: builder = RangeEllipseShapeBuilder; break; default: break; } return builder; }
public void ReDrawShaps(List<ShapeData> shaps) { this.Dispose(); InitImageSource(); DrawingContext drawingContext = _drawingVisual.RenderOpen(); ShapeBuilderType[] typeSecquence = new ShapeBuilderType[4] { ShapeBuilderType.RangeEllipse, //step1: draw all rangeindicator ShapeBuilderType.ArrowLine, //step2: draw all dash ling with arrow ShapeBuilderType.Rectangle, //step3: draw all autosampling point ShapeBuilderType.StartEllipse //step4: draw start red ellipse }; foreach (var type in typeSecquence) { for (int i = 0; i < shaps.Count;) { ShapeData shape = shaps[i]; if (shape.ShapType != type) { i++; continue; } ShapeBulder builder = ShapBuilderFactory.Instance.GetShapBilder(shape.ShapType); Rect drawRect = DrawShape(shape, builder); builder.Drawing(drawingContext, drawRect); shaps.RemoveAt(i); } } drawingContext.Close(); if (ImageSource != null) { ImageSource.Render(_drawingVisual); } }