public void AddShap(ShapeData shape) { InitImageSource(); DrawingContext drawingContext = _drawingVisual.RenderOpen(); ShapeBulder builder = ShapBuilderFactory.Instance.GetShapBilder(shape.ShapType); Rect drawRect = DrawShape(shape, builder); builder.Drawing(drawingContext, drawRect); drawingContext.Close(); if (ImageSource != null) { ImageSource.Render(_drawingVisual); } }
private ShapeData TranslateVisualPointToRangeIndicatorShapData(HeatMapVisualPoint point) { if (RangeRadius == null) { return null; } if (!point.IsNeedRangeIndicator) { return null; } ShapeData RangeShap = new ShapeData(); RangeShap.Position = point.VisualPoint; //for DE5970 RangeShap.Radius = RangeRadius.Value/4; RangeShap.ShapType = ShapeBuilderType.RangeEllipse; RangeShap.Brush = point.Brush; return RangeShap; }
//private Point? PrePenDownPoint //{ // get // { // return _prePenDownPoint; // } // set // { // _prePenDownPoint = value; // } //} private ShapeData TranslateVisualPointToPathShapData(HeatMapVisualPoint point) { ShapeData shape = new ShapeData(); if (point.IsDashArrowPoint && _prePenDownPoint == null) { shape.ShapType = ShapeBuilderType.StartEllipse; shape.Position = point.VisualPoint; _prePenDownPoint = point.VisualPoint; } else if (point.IsDashArrowPoint && _prePenDownPoint != null) { shape.ShapType = ShapeBuilderType.ArrowLine; shape.Start = _prePenDownPoint.Value; shape.End = point.VisualPoint; _prePenDownPoint = point.VisualPoint; } else { shape.ShapType = ShapeBuilderType.Rectangle; shape.Position = point.VisualPoint; } return shape; }
//private static readonly double StartEllipse_WIDTH = 18; private Rect DrawShape(ShapeData shape, ShapeBulder builder) { Rect drawRect = new Rect(0, 0, 0, 0); switch (shape.ShapType) { case ShapeBuilderType.Rectangle: drawRect = new Rect(CorrectPointX((shape.Position.X) * _scale - RECTANGLE_SIZE / 2), CoorrectPointY((shape.Position.Y) * _scale - RECTANGLE_SIZE / 2), RECTANGLE_SIZE, RECTANGLE_SIZE); break; case ShapeBuilderType.ArrowLine: drawRect = new Rect(shape.Start, shape.End); ((ArrowLineBuilder)builder).Start = CorrectPoint(new Point((shape.Start.X) * _scale, shape.Start.Y * _scale)); ((ArrowLineBuilder)builder).End = CorrectPoint(new Point(shape.End.X * _scale, shape.End.Y * _scale)); break; case ShapeBuilderType.StartEllipse: drawRect = new Rect(0, 0, 0, 0); ((EllipseBuilder)builder).Position = new Point(CorrectPointX((shape.Position.X) * _scale), CoorrectPointY((shape.Position.Y) * _scale)); ((EllipseBuilder)builder).Radius = STARTRADIUS; break; case ShapeBuilderType.RangeEllipse: drawRect = new Rect(0,0,0,0); ((GridLineEllipse)builder).Position = new Point(CorrectPointX((shape.Position.X) * _scale), CoorrectPointY((shape.Position.Y) * _scale)); ((GridLineEllipse)builder).Radius = ConvertToInt(shape.Radius * _scale); ((GridLineEllipse)builder).ShapeBrush = shape.Brush; ((GridLineEllipse)builder).PixelWidth = _pixelWidth; ((GridLineEllipse)builder).PixelHeight = _pixeHeight; break; default: break; } return drawRect; }