public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length != 3)
            {
                return(null);
            }
            double width  = (double)values[0];
            double height = (double)values[1];

            Template.RightSideFormEnum rightSideForm      = (Template.RightSideFormEnum)values[2];
            ISideCurveGenerator        rightSideGenerator = SideCurveGeneratorFactory.GetGeneratorFor(rightSideForm);

            return(new PointCollection(Drawing.GetRightPolyline(width, height, rightSideGenerator)));
        }
        public override RenderedSvg RenderColumn()
        {
            var result = base.RenderColumn();


            SvgGroup group = new SvgGroup();

            VisualLayerPresentingVM[] layers = vm.Layers.ToArray();



            for (int i = 0; i < layers.Length; i++)
            {
                VisualLayerPresentingVM lvm = layers[i];
                if (lvm.Origin.CurrentClass != null)
                {
                    ISideCurveGenerator sideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.Origin.CurrentClass.RightSideForm);

                    SvgPatternServer sps = lvm.Origin.CurrentClass.BackgroundPattern;
                    sps.PatternContentUnits = SvgCoordinateUnits.ObjectBoundingBox;
                    sps.PatternUnits        = SvgCoordinateUnits.UserSpaceOnUse;
                    float ratio = sps.Width.Value / 64f;
                    sps.Width  /= ratio;
                    sps.Height /= ratio;

                    SvgPolygon poly = new SvgPolygon();
                    poly.Stroke      = new SvgColourServer(System.Drawing.Color.Black);
                    poly.StrokeWidth = 1f;
                    poly.Fill        = sps;

                    var points = Drawing.GetPolygon(lvm.Width, lvm.Height, sideCurveGenerator).ToArray();

                    SvgPointCollection svgPoints = new SvgPointCollection();
                    for (int j = 0; j < points.Length; j++)
                    {
                        var point = points[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgPoints, point);
                    }

                    poly.Points = svgPoints;

                    group.Children.Add(poly);
                }
            }

            result.SVG = group;

            return(result);
        }
        public static IEnumerable <Point> GetPolygon(double width, double height, ISideCurveGenerator sideCurve)
        {
            List <Point> result = new List <Point>();

            result.Add(new Point(0.0, 0.0));
            result.Add(new Point(width, 0.0));

            IEnumerable <Point> sidePoints = sideCurve.GenerateSide(height).
                                             Select(p => new Point(p.Y + width, p.X)); // transposing, so that (0.0;0.0);(length;0.0) projected to (width;0.0);(width;length)

            result.AddRange(sidePoints);

            result.Add(new Point(width, height));
            result.Add(new Point(0.0, height));
            return(result);
        }
        public override RenderedSvg RenderColumn()
        {
            var result = base.RenderColumn();


            SvgGroup group = new SvgGroup();

            VisualLayerPresentingVM[] layers = vm.Layers.ToArray();



            for (int i = 0; i < layers.Length; i++)
            {
                VisualLayerPresentingVM lvm = layers[i];
                SvgGroup levelGroup         = new SvgGroup();
                if (lvm.BackgroundClass.CurrentClass != null)
                {
                    ISideCurveGenerator rightSideCurveGenerator = null;
                    if ((lvm.RightSideClass != null) && (lvm.RightSideClass.CurrentClass != null))
                    {
                        rightSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.RightSideClass.CurrentClass.RightSideForm);
                    }
                    else
                    {
                        rightSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.RightSideFormEnum.NotDefined);
                    }

                    SvgPolyline rightEdge = new SvgPolyline
                    {
                        Stroke      = new SvgColourServer(System.Drawing.Color.Black),
                        StrokeWidth = 1f
                    };

                    var rightPoints = Drawing.GetRightPolyline(lvm.Width, lvm.Height, rightSideCurveGenerator).ToArray();

                    SvgPointCollection svgPoints = new SvgPointCollection();
                    for (int j = 0; j < rightPoints.Length; j++)
                    {
                        var point = rightPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgPoints, point);
                    }

                    rightEdge.Points = svgPoints;

                    levelGroup.Children.Add(rightEdge);


                    ISideCurveGenerator bottomSideCurveGenerator = null;
                    if ((lvm.BottomSideClass != null) && (lvm.BottomSideClass.CurrentClass != null))
                    {
                        bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.BottomSideClass.CurrentClass.BottomSideForm);
                    }
                    else
                    {
                        bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.BottomSideFormEnum.NotDefined);
                    }

                    SvgPolyline bottomEdge = new SvgPolyline
                    {
                        Stroke        = new SvgColourServer(System.Drawing.Color.Black),
                        StrokeLineCap = SvgStrokeLineCap.Round,
                        StrokeWidth   = 1f
                    };
                    if (lvm.BottomSideClass.CurrentClass != null)
                    {
                        if (lvm.BottomSideClass.CurrentClass.BottomSideForm == AnnotationPlane.Template.BottomSideFormEnum.Dotted)
                        {
                            bottomEdge.StrokeDashArray = new List <float>()
                            {
                                3, 3
                            }.
                            Select(p => new SvgUnit(p)) as SvgUnitCollection;
                        }
                    }

                    var bottomPoints = Drawing.GetBottomPolyline(lvm.Width, lvm.Height, bottomSideCurveGenerator).ToArray();

                    SvgPointCollection svgBottomPoints = new SvgPointCollection();
                    for (int j = 0; j < bottomPoints.Length; j++)
                    {
                        var point = bottomPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgBottomPoints, point);
                    }

                    bottomEdge.Points = svgBottomPoints;

                    levelGroup.Children.Add(bottomEdge);


                    SvgPolygon bckgrPolygon = new SvgPolygon
                    {
                        StrokeWidth = 0f
                    };

                    SvgPatternServer sps = lvm.BackgroundClass.CurrentClass.BackgroundPattern;
                    sps.PatternContentUnits = SvgCoordinateUnits.ObjectBoundingBox;
                    sps.PatternUnits        = SvgCoordinateUnits.UserSpaceOnUse;
                    float ratio = sps.Width.Value / 64f;
                    sps.Width  /= ratio;
                    sps.Height /= ratio;

                    bckgrPolygon.Fill = sps;

                    var bckgrPoints = Drawing.GetBackgroundPolyline(lvm.Width, lvm.Height, rightSideCurveGenerator).ToArray();

                    SvgPointCollection svgBckgrPoints = new SvgPointCollection();
                    for (int j = 0; j < bckgrPoints.Length; j++)
                    {
                        var point = bckgrPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgBckgrPoints, point);
                    }

                    bckgrPolygon.Points = svgBckgrPoints;

                    levelGroup.Children.Add(bckgrPolygon);


                    group.Children.Add(levelGroup);
                }
            }

            result.SVG = group;

            return(result);
        }
Exemple #5
0
        public static IEnumerable <Point> GetBottomPolyline(double width, double height, ISideCurveGenerator bottomSideCurve)
        {
            List <Point> result = new List <Point>();

            IEnumerable <Point> bottomSidePoints = bottomSideCurve.GenerateSide(width).
                                                   Select(p => new Point(p.X, p.Y + height)); // parallel shift, so that (0.0;0.0);(width;0.0) is shifted to (0.0;height);(width;height)

            result.AddRange(bottomSidePoints);

            return(result);
        }